@dexhq/canvas 0.16.0 → 0.18.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 +89 -0
- package/README.md +4 -4
- package/app/app.tsx +21 -3
- package/app/base.ts +8 -3
- package/app/canvas/activity-bar.tsx +34 -14
- package/app/canvas/activity-model.ts +112 -53
- package/app/canvas/activity-parts.tsx +30 -8
- package/app/canvas/activity.tsx +153 -35
- package/app/canvas/add-to-spec.ts +14 -5
- package/app/canvas/agent-changes.ts +59 -4
- package/app/canvas/anchoring.ts +165 -49
- package/app/canvas/canvas-chrome.tsx +44 -13
- package/app/canvas/canvas-clipboard.ts +38 -8
- package/app/canvas/canvas-commands.ts +185 -22
- package/app/canvas/canvas-context-menu.tsx +3 -0
- package/app/canvas/canvas-context.tsx +28 -4
- package/app/canvas/canvas-corners.tsx +2 -0
- package/app/canvas/canvas-document.ts +145 -24
- package/app/canvas/canvas-input.ts +277 -36
- package/app/canvas/canvas-keys.ts +165 -68
- package/app/canvas/canvas-menus.tsx +29 -5
- package/app/canvas/canvas-merge.ts +141 -29
- package/app/canvas/canvas-model.ts +432 -217
- package/app/canvas/canvas-panels.ts +10 -0
- package/app/canvas/canvas-scene.ts +640 -205
- package/app/canvas/canvas-ui.ts +62 -7
- package/app/canvas/canvas.css +449 -102
- package/app/canvas/change-notice.tsx +16 -7
- package/app/canvas/change-pictures.tsx +156 -0
- package/app/canvas/command-menu.tsx +12 -0
- package/app/canvas/comment-drafts.ts +31 -0
- package/app/canvas/comment-layer.tsx +189 -176
- package/app/canvas/comments.tsx +369 -129
- package/app/canvas/device-edits.ts +19 -2
- package/app/canvas/device-icons.ts +1 -0
- package/app/canvas/device-picker.tsx +5 -2
- package/app/canvas/devices-panel.tsx +14 -8
- package/app/canvas/draw-layer.tsx +49 -10
- package/app/canvas/draw-model.ts +15 -12
- package/app/canvas/editable-text.tsx +36 -15
- package/app/canvas/element-link.ts +25 -6
- package/app/canvas/element-picker.ts +123 -481
- package/app/canvas/engine/camera.ts +24 -3
- package/app/canvas/engine/canvas-gestures.ts +238 -56
- package/app/canvas/engine/canvas-store.ts +41 -0
- package/app/canvas/engine/canvas-view.tsx +59 -6
- package/app/canvas/export-dialog.tsx +17 -3
- package/app/canvas/find-bar.tsx +167 -53
- package/app/canvas/find-model.ts +20 -4
- package/app/canvas/floating-panel.tsx +16 -0
- package/app/canvas/flow-canvas.tsx +395 -278
- package/app/canvas/flow-renames.ts +9 -0
- package/app/canvas/follow-pin.ts +11 -0
- package/app/canvas/forced-states.ts +25 -4
- package/app/canvas/frame-choices.tsx +4 -0
- package/app/canvas/frame-code.ts +139 -0
- package/app/canvas/frame-context-menu.tsx +267 -31
- package/app/canvas/frame-copies.ts +94 -26
- package/app/canvas/frame-drops.ts +71 -14
- package/app/canvas/frame-inspector.ts +305 -0
- package/app/canvas/frame-node.tsx +403 -127
- package/app/canvas/frame-pictures.ts +96 -13
- package/app/canvas/frame-resize.tsx +337 -82
- 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 +30 -14
- package/app/canvas/inspect-layer.tsx +139 -26
- package/app/canvas/inspect-tools.ts +15 -4
- package/app/canvas/jpeg-pdf.ts +30 -3
- package/app/canvas/label-action.tsx +15 -3
- package/app/canvas/large-canvas-notice.tsx +7 -1
- package/app/canvas/layout.ts +881 -353
- package/app/canvas/linked-element.tsx +24 -1
- package/app/canvas/live-page.ts +231 -29
- package/app/canvas/measure-box.tsx +1 -0
- package/app/canvas/mentions.tsx +12 -0
- package/app/canvas/new-frame.ts +62 -15
- package/app/canvas/note-placing.ts +155 -28
- 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 +6 -0
- package/app/canvas/picks-menu.tsx +27 -15
- 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/readable-colour.ts +52 -0
- package/app/canvas/removed-views-panel.tsx +39 -8
- package/app/canvas/request-node.tsx +40 -17
- package/app/canvas/review-marker.tsx +9 -2
- package/app/canvas/review-panel.tsx +145 -42
- package/app/canvas/row-node.tsx +15 -3
- package/app/canvas/scene-context.tsx +16 -1
- package/app/canvas/scrolling-page.ts +45 -0
- package/app/canvas/section-node.tsx +68 -26
- package/app/canvas/selection.ts +3 -1
- package/app/canvas/server-notice.tsx +10 -4
- package/app/canvas/settle.ts +21 -0
- 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 +122 -9
- package/app/canvas/spec-copies.ts +13 -2
- package/app/canvas/spec-frame.tsx +204 -63
- package/app/canvas/spec-full-screen.tsx +39 -17
- package/app/canvas/spec-margin.tsx +32 -7
- package/app/canvas/spec-mode.tsx +28 -20
- package/app/canvas/spec-placing.tsx +32 -7
- package/app/canvas/spec-threads.ts +14 -0
- package/app/canvas/spec-title.tsx +12 -5
- package/app/canvas/spot-pins.tsx +23 -3
- package/app/canvas/stack-frame.tsx +313 -0
- package/app/canvas/stack-model.ts +272 -0
- package/app/canvas/stack-toggle.tsx +89 -0
- 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 +79 -81
- package/app/canvas/teammates-layer.tsx +21 -3
- package/app/canvas/tell-open-page.tsx +12 -0
- package/app/canvas/testing/must.ts +11 -0
- package/app/canvas/testing/stand-in.ts +9 -0
- package/app/canvas/testing/waits.ts +17 -0
- package/app/canvas/text-layer.tsx +80 -23
- package/app/canvas/thread-focus.tsx +65 -18
- package/app/canvas/thread-place.ts +27 -3
- package/app/canvas/tip.tsx +4 -0
- package/app/canvas/tool-cursors.ts +15 -1
- package/app/canvas/tool-icons.tsx +17 -4
- package/app/canvas/toolbar-parts.tsx +56 -10
- package/app/canvas/toolbar.tsx +140 -89
- package/app/canvas/tools.ts +32 -9
- package/app/canvas/typing.ts +6 -1
- package/app/canvas/unknown-frame.tsx +39 -12
- package/app/canvas/use-activity.ts +57 -2
- package/app/canvas/use-agent-changes.tsx +60 -15
- package/app/canvas/use-canvas-clipboard.tsx +203 -69
- package/app/canvas/use-canvas-commands.ts +14 -0
- package/app/canvas/use-canvas-editor.ts +39 -14
- package/app/canvas/use-component-drops.ts +21 -5
- package/app/canvas/use-reveal.ts +86 -0
- 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 +18 -5
- package/app/editor/line-break-caret.ts +57 -0
- package/app/editor/markdown-source.ts +42 -8
- package/app/editor/node-views.tsx +39 -12
- package/app/editor/quote-bubble.tsx +10 -1
- package/app/editor/two-versions.ts +24 -9
- package/app/export/player-model.ts +37 -9
- package/app/export/player.tsx +21 -4
- package/app/frame/file-errors.ts +4 -0
- package/app/frame/frame-app.tsx +15 -1
- package/app/frame/frame-history.ts +9 -0
- package/app/frame/frame-links.ts +7 -0
- package/app/frame/hold-window-focus.ts +4 -0
- package/app/frame/left-view.tsx +6 -0
- package/app/frame/start-frame.tsx +8 -2
- package/app/frame/studio-view.tsx +2 -0
- package/app/frame/view-exports.ts +240 -0
- package/app/frame/view-loads.ts +37 -11
- package/app/frame/views.ts +79 -8
- package/app/git/branch-panel.tsx +132 -45
- 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 +170 -10
- package/app/i18n/locales/en/messages.ts +1 -1
- package/app/i18n/locales/pseudo/messages.po +167 -7
- package/app/i18n/locales/pseudo/messages.ts +1 -1
- package/app/i18n/locales.ts +4 -0
- package/app/i18n/provider.tsx +9 -5
- package/app/icons/dex-glyphs.tsx +38 -0
- package/app/icons/glyphs.tsx +7 -0
- package/app/icons/index.tsx +3 -1
- package/app/icons/types.ts +1 -0
- package/app/kit/inspect-runtime.ts +50 -5
- package/app/kit/sample-people.ts +6 -0
- package/app/kit/use-simulated-load.ts +6 -2
- package/app/kit/use-simulated-stream.ts +8 -2
- package/app/kit/use-view-control.ts +1 -0
- package/app/live/canvas-teammates.ts +14 -1
- package/app/live/deployed-preview.ts +1 -0
- package/app/live/focus-reporter.ts +8 -0
- package/app/live/guest-review.ts +115 -23
- package/app/live/restart-wait.ts +14 -2
- package/app/live/server-connection.ts +21 -4
- package/app/live/studio-action.ts +6 -1
- package/app/live/studio-api.ts +191 -54
- package/app/live/studio-data.ts +26 -1
- package/app/live/studio-live.ts +72 -16
- package/app/live/studio-request.ts +15 -1
- package/app/live/thread-state.ts +8 -0
- package/app/live/use-devices.ts +11 -2
- package/app/live/use-focus.ts +5 -2
- package/app/live/use-last-edited.ts +2 -0
- package/app/live/use-show-requests.ts +3 -0
- package/app/live/use-workspace.ts +10 -2
- package/app/main.tsx +9 -3
- package/app/next/fonts.ts +1 -0
- package/app/next/image.tsx +17 -10
- package/app/next/navigation.ts +9 -6
- package/app/next/router.ts +4 -4
- package/app/pages/agent-settings.tsx +11 -3
- package/app/pages/ask-the-agent.tsx +2 -0
- package/app/pages/canvas-settings.tsx +3 -0
- package/app/pages/canvas.tsx +230 -71
- package/app/pages/chrome-extension.tsx +4 -2
- package/app/pages/commands-settings.tsx +126 -83
- 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 +33 -20
- package/app/pages/play-size.ts +31 -11
- package/app/pages/play.tsx +164 -63
- package/app/pages/profile.tsx +6 -2
- package/app/pages/prototype.tsx +10 -4
- package/app/pages/render.tsx +33 -8
- package/app/pages/settings.tsx +5 -1
- package/app/pages/workspace-general.tsx +29 -5
- package/app/pages/workspace-git.tsx +38 -10
- package/app/pages/your-guidelines.tsx +7 -0
- package/app/pages/your-picture.tsx +33 -10
- package/app/registry-files.ts +6 -1
- package/app/registry.ts +73 -13
- package/app/renamed-storage.ts +8 -1
- package/app/shell/about.tsx +10 -4
- package/app/shell/agent-logos.tsx +4 -0
- package/app/shell/agent-manual.tsx +13 -5
- package/app/shell/avatar-pictures.ts +18 -6
- package/app/shell/avatar.tsx +11 -1
- package/app/shell/bell.tsx +27 -13
- package/app/shell/broke.tsx +1 -1
- package/app/shell/chrome-theme.tsx +4 -0
- package/app/shell/connect-agent.tsx +76 -38
- package/app/shell/copy-text.tsx +3 -1
- package/app/shell/deployed-preview-bar.tsx +4 -6
- package/app/shell/desktop-app.tsx +30 -15
- package/app/shell/empty-state.tsx +2 -2
- package/app/shell/feedback-details.ts +8 -1
- package/app/shell/feedback-form.tsx +67 -35
- package/app/shell/feedback-link.tsx +3 -0
- package/app/shell/file-bytes.ts +3 -1
- package/app/shell/host.ts +37 -8
- package/app/shell/info-tip.tsx +2 -1
- package/app/shell/install-prompt.ts +10 -1
- package/app/shell/instructions-editor.tsx +184 -78
- package/app/shell/instructions.tsx +7 -1
- package/app/shell/main-sidebar.tsx +27 -6
- package/app/shell/open-agent.tsx +8 -2
- package/app/shell/page-header.tsx +6 -3
- package/app/shell/page-title.ts +36 -14
- package/app/shell/presence-style.ts +8 -0
- package/app/shell/presence.tsx +74 -10
- package/app/shell/prototype-menu.tsx +84 -27
- package/app/shell/quick-start.tsx +21 -3
- package/app/shell/recents.ts +21 -2
- package/app/shell/report-issue.ts +29 -23
- package/app/shell/restart-toast.tsx +37 -4
- package/app/shell/save-state.tsx +4 -0
- package/app/shell/scaled-frame.tsx +22 -1
- package/app/shell/settings-sections.ts +12 -11
- package/app/shell/settings-sidebar.tsx +7 -1
- package/app/shell/settings-ui.tsx +11 -7
- package/app/shell/shell-bar.ts +2 -5
- package/app/shell/sidebar.tsx +2 -2
- package/app/shell/skeleton.ts +80 -22
- package/app/shell/status-badge.tsx +2 -0
- package/app/shell/studio-shell.tsx +11 -4
- package/app/shell/thread-list.tsx +18 -7
- package/app/shell/time-ago.ts +7 -0
- package/app/shell/toasts.tsx +20 -13
- package/app/shell/update-notice.tsx +241 -41
- package/app/shell/use-copied.ts +4 -0
- package/app/shell/use-space.ts +5 -0
- package/app/shell/watch-switch.tsx +4 -1
- package/app/shell/welcome.tsx +18 -3
- package/app/shell/window-buttons.tsx +17 -3
- package/app/shell/working-on.tsx +10 -2
- package/app/shell/workspace-mark.tsx +59 -25
- package/app/studio-ui.d.ts +2 -1
- package/app/styles.css +4 -12
- package/app/types.ts +8 -6
- package/app/ui/boundary.tsx +6 -1
- package/app/ui/file-drop.ts +32 -18
- package/app/ui/prompt-editor.tsx +83 -25
- package/app/ui/reference.tsx +6 -1
- package/app/ui/segmented.tsx +3 -1
- package/app/ui/theme-switch.tsx +1 -0
- package/app/ui/theme.css +17 -0
- package/app/ui/use-field-list.ts +90 -0
- package/app/ui/use-latest.ts +13 -0
- package/app/ui/use-once.ts +9 -0
- package/bin/dex.mjs +6 -1
- package/bin/sudio.mjs +1 -0
- package/dist/cli/banner.mjs +0 -1
- package/dist/cli/command.d.mts +237 -5
- package/dist/cli/command.mjs +8 -3
- package/dist/cli/commands/agents/add.mjs +1 -1
- package/dist/cli/commands/app.mjs +13 -16
- package/dist/cli/commands/claude.d.mts +3 -3
- package/dist/cli/commands/claude.mjs +10 -9
- package/dist/cli/commands/cloud/publish.mjs +1 -1
- package/dist/cli/commands/dev.mjs +64 -19
- package/dist/cli/commands/doctor.mjs +3 -1
- package/dist/cli/commands/hook.mjs +1 -1
- package/dist/cli/commands/mcp.mjs +12 -4
- package/dist/cli/commands/merge-canvas.d.mts +29 -0
- package/dist/cli/commands/merge-canvas.mjs +101 -0
- package/dist/cli/commands/merge-contributors.d.mts +0 -7
- package/dist/cli/commands/merge-contributors.mjs +2 -1
- package/dist/cli/commands/merge-spec.d.mts +0 -7
- package/dist/cli/commands/merge-spec.mjs +2 -1
- package/dist/cli/help.mjs +7 -13
- package/dist/cli/main.d.mts +26 -0
- package/dist/cli/main.mjs +4 -2
- package/dist/cli/mcp-relay.d.mts +5 -5
- package/dist/cli/mcp-relay.mjs +46 -30
- package/dist/cli/recovery-server.mjs +2 -2
- package/dist/cli/strict-flags.mjs +6 -6
- package/dist/cli/supervise.mjs +37 -26
- package/dist/cli/ui.d.mts +21 -21
- package/dist/cli/ui.mjs +2 -1
- package/dist/config/design-system.mjs +19 -14
- package/dist/config/load.mjs +10 -7
- package/dist/config/project-files.d.mts +3 -2
- package/dist/config/project-files.mjs +35 -41
- package/dist/config/renamed.d.mts +4 -8
- package/dist/config/renamed.mjs +4 -17
- package/dist/content/biome.mjs +15 -10
- package/dist/content/capture.mjs +43 -42
- package/dist/content/commands.d.mts +10 -4
- package/dist/content/commands.mjs +49 -21
- package/dist/content/comments-log.mjs +102 -19
- package/dist/content/component-props.mjs +6 -10
- package/dist/content/content.d.mts +291 -38
- package/dist/content/content.mjs +267 -151
- package/dist/content/devices.mjs +2 -2
- package/dist/content/element-words.mjs +7 -7
- package/dist/content/file-turns.mjs +1 -1
- package/dist/content/first-run.mjs +3 -5
- package/dist/content/flow-specs.mjs +18 -16
- package/dist/content/format-check.d.mts +46 -0
- package/dist/content/format-check.mjs +338 -0
- package/dist/content/hosted-person.mjs +4 -3
- package/dist/content/insert-edit.mjs +7 -6
- package/dist/content/jsx-source.d.mts +5 -1
- package/dist/content/jsx-source.mjs +8 -7
- package/dist/content/last-edited.mjs +1 -1
- package/dist/content/layout.d.mts +44 -2
- package/dist/content/layout.mjs +65 -6
- package/dist/content/merge-rules.d.mts +11 -4
- package/dist/content/merge-rules.mjs +31 -18
- package/dist/content/prop-edit.mjs +4 -4
- package/dist/content/prototype-checks.mjs +13 -12
- package/dist/content/prototype-summary.d.mts +1 -1
- package/dist/content/prototype-summary.mjs +8 -8
- package/dist/content/prototypes.d.mts +8 -1
- package/dist/content/prototypes.mjs +41 -27
- package/dist/content/review-import.mjs +1 -1
- package/dist/content/review-pages.mjs +19 -16
- package/dist/content/screenshot.d.mts +6 -1
- package/dist/content/screenshot.mjs +21 -14
- package/dist/content/snapshot-client.d.mts +2 -0
- package/dist/content/snapshot-client.mjs +14 -4
- package/dist/content/store.d.mts +16 -8
- package/dist/content/store.mjs +99 -26
- package/dist/content/sub-agents.d.mts +12 -0
- package/dist/content/sub-agents.mjs +52 -0
- package/dist/content/text-edit.mjs +6 -6
- package/dist/content/text-replace.mjs +13 -15
- package/dist/content/thread-module.d.mts +9 -1
- package/dist/content/thread-module.mjs +19 -1
- package/dist/content/threads.d.mts +13 -0
- package/dist/content/threads.mjs +59 -14
- package/dist/content/trash.d.mts +4 -2
- package/dist/content/trash.mjs +31 -31
- package/dist/desktop/src/app.d.mts +40 -0
- package/dist/desktop/src/app.mjs +80 -0
- package/dist/desktop/src/contract.d.mts +7 -0
- package/dist/desktop/src/contract.mjs +22 -0
- package/dist/desktop/src/host.d.mts +48 -0
- package/dist/desktop/src/index.d.mts +32 -0
- package/dist/desktop/src/index.mjs +69 -0
- package/dist/desktop/src/mac/bundle.mjs +116 -0
- package/dist/desktop/src/mac/icon.mjs +53 -0
- package/dist/desktop/src/mac/launcher.mjs +69 -0
- package/dist/desktop/src/mac/plist.mjs +73 -0
- package/dist/desktop/src/mac/program/constants.mjs +62 -0
- package/dist/desktop/src/mac/program/delegate.mjs +214 -0
- package/dist/desktop/src/mac/program/downloads.mjs +19 -0
- package/dist/desktop/src/mac/program/index.mjs +26 -0
- package/dist/desktop/src/mac/program/menu.mjs +125 -0
- package/dist/desktop/src/mac/program/server-pages.mjs +140 -0
- package/dist/desktop/src/mac/program/web-view.mjs +59 -0
- package/dist/desktop/src/mac/program/window.mjs +197 -0
- package/dist/desktop/src/mac/services.mjs +28 -0
- package/dist/desktop/src/plug-in/http.d.mts +11 -0
- package/dist/desktop/src/plug-in/http.mjs +51 -0
- package/dist/desktop/src/plug-in/page-head.d.mts +8 -0
- package/dist/desktop/src/plug-in/page-head.mjs +31 -0
- package/dist/desktop/src/service.d.mts +15 -0
- package/dist/desktop/src/service.mjs +151 -0
- package/dist/desktop/src/start.d.mts +42 -0
- package/dist/{setup/desktop-app-start.mjs → desktop/src/start.mjs} +14 -39
- package/dist/harness/src/agents/adapter.d.mts +11 -0
- package/dist/harness/src/agents/adapter.mjs +6 -0
- package/dist/harness/src/agents/claude-code.mjs +179 -0
- package/dist/harness/src/agents/codex.mjs +189 -0
- package/dist/harness/src/agents/copilot.mjs +20 -0
- package/dist/harness/src/agents/cursor.mjs +21 -0
- package/dist/harness/src/agents/opencode.mjs +27 -0
- package/dist/harness/src/agents/other.mjs +21 -0
- package/dist/harness/src/agents/registry.mjs +21 -0
- package/dist/harness/src/agents/sub-agent.d.mts +14 -0
- package/dist/harness/src/agents.mjs +7 -0
- package/dist/harness/src/checks.mjs +9 -0
- package/dist/harness/src/connect/agent-config.mjs +252 -0
- package/dist/{server → harness/src/connect}/agent-env.mjs +3 -4
- package/dist/harness/src/connect/agent-root.mjs +30 -0
- package/dist/harness/src/connect/json-layout.mjs +52 -0
- package/dist/harness/src/connect/launch.mjs +67 -0
- package/dist/harness/src/connect/launched.d.mts +23 -0
- package/dist/harness/src/connect/package-manager.d.mts +1 -0
- package/dist/{config → harness/src/connect}/package-manager.mjs +17 -6
- package/dist/harness/src/connect/setups.d.mts +24 -0
- package/dist/harness/src/connect/setups.mjs +98 -0
- package/dist/harness/src/connect/workspace-root.d.mts +20 -0
- package/dist/harness/src/connect/workspace-root.mjs +110 -0
- package/dist/harness/src/events/channel-server.mjs +10 -0
- package/dist/harness/src/events/channel.d.mts +104 -0
- package/dist/harness/src/events/channel.mjs +457 -0
- package/dist/harness/src/events/connected-agent.d.mts +35 -0
- package/dist/harness/src/events/place.d.mts +21 -0
- package/dist/harness/src/mcp/define-tool.d.mts +26 -0
- package/dist/harness/src/mcp/define-tool.mjs +11 -0
- package/dist/harness/src/mcp/mcp-handover.d.mts +11 -0
- package/dist/{server → harness/src/mcp}/mcp-handover.mjs +6 -4
- package/dist/harness/src/mcp/mcp.d.mts +15 -0
- package/dist/harness/src/mcp/mcp.mjs +97 -0
- package/dist/harness/src/paths.d.mts +4 -0
- package/dist/harness/src/paths.mjs +15 -0
- package/dist/harness/src/project.d.mts +6 -0
- package/dist/harness/src/renamed.d.mts +9 -0
- package/dist/harness/src/renamed.mjs +22 -0
- package/dist/harness/src/session/session.d.mts +31 -0
- package/dist/harness/src/version.d.mts +13 -0
- package/dist/harness/src/version.mjs +47 -0
- package/dist/inspector.js +675 -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 +7 -2
- package/dist/paste/paste.mjs +23 -17
- 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 +18 -0
- package/dist/server/agent-tools.mjs +32 -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/change-picture-store.d.mts +13 -0
- package/dist/server/change-picture-store.mjs +42 -0
- package/dist/server/change-pictures.d.mts +25 -0
- package/dist/server/change-pictures.mjs +104 -0
- package/dist/server/changelog.mjs +5 -4
- package/dist/server/claimed-presence.mjs +10 -7
- package/dist/server/close-check.d.mts +11 -0
- package/dist/server/close-check.mjs +54 -20
- package/dist/server/cloud.d.mts +1 -1
- package/dist/server/cloud.mjs +5 -4
- package/dist/server/command-settings.d.mts +4 -2
- package/dist/server/command-settings.mjs +11 -7
- package/dist/server/comments/actions.d.mts +17 -56
- package/dist/server/comments/actions.mjs +65 -59
- package/dist/server/comments/agent-actions.d.mts +77 -0
- package/dist/server/comments/agent-actions.mjs +85 -0
- package/dist/server/comments/close-tools.d.mts +31 -0
- package/dist/server/comments/close-tools.mjs +126 -0
- package/dist/server/comments/files.d.mts +57 -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 +49 -0
- package/dist/server/comments/push.d.mts +35 -0
- package/dist/server/comments/push.mjs +253 -0
- package/dist/server/comments/routes.d.mts +12 -0
- package/dist/server/comments/routes.mjs +21 -11
- package/dist/server/comments/studio-files.d.mts +27 -0
- package/dist/server/comments/studio-files.mjs +93 -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 +85 -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 +51 -35
- package/dist/server/export/build.mjs +3 -3
- package/dist/server/export/page.mjs +4 -4
- package/dist/server/export/plugin.d.mts +4 -2
- package/dist/server/export/plugin.mjs +4 -1
- package/dist/server/features.d.mts +0 -5
- package/dist/server/features.mjs +1 -6
- package/dist/server/file-errors.mjs +4 -4
- package/dist/server/file-lock.mjs +14 -9
- package/dist/server/git-host.mjs +6 -9
- package/dist/server/git-paused.mjs +4 -1
- package/dist/server/git-settings.d.mts +1 -1
- package/dist/server/git-settings.mjs +5 -5
- package/dist/server/git-sync.d.mts +8 -0
- package/dist/server/git-sync.mjs +77 -19
- package/dist/server/git.d.mts +0 -5
- package/dist/server/git.mjs +53 -48
- package/dist/server/instructions.mjs +9 -8
- package/dist/server/live-mirror.mjs +20 -13
- package/dist/server/live.mjs +8 -6
- package/dist/server/machine-update.mjs +32 -32
- package/dist/server/me.mjs +4 -2
- package/dist/server/merge-check.d.mts +14 -0
- package/dist/server/merge-check.mjs +80 -0
- package/dist/server/next.mjs +9 -6
- package/dist/server/notices.d.mts +6 -6
- package/dist/server/notices.mjs +11 -9
- package/dist/server/open-page.mjs +11 -10
- package/dist/server/outcome.d.mts +7 -8
- package/dist/server/own-copies.mjs +10 -19
- package/dist/server/people.mjs +4 -4
- package/dist/server/pictures.mjs +14 -8
- package/dist/server/port.mjs +5 -9
- package/dist/server/prebundle.mjs +16 -13
- package/dist/server/preferences.mjs +1 -1
- package/dist/server/presence.d.mts +3 -3
- package/dist/server/presence.mjs +2 -4
- package/dist/server/project-public.mjs +1 -1
- package/dist/server/prototype-brief.d.mts +36 -3
- package/dist/server/prototype-brief.mjs +6 -6
- package/dist/server/push-notice.d.mts +1 -1
- package/dist/server/quiet-run.mjs +1 -1
- package/dist/server/registry.mjs +9 -8
- package/dist/server/requests.d.mts +9 -20
- package/dist/server/requests.mjs +192 -132
- package/dist/server/response-budget.d.mts +18 -8
- package/dist/server/response-budget.mjs +10 -8
- package/dist/server/restart.mjs +3 -1
- package/dist/server/roster.d.mts +21 -10
- package/dist/server/roster.mjs +55 -28
- package/dist/server/source-stamp.d.mts +5 -4
- package/dist/server/source-stamp.mjs +43 -15
- package/dist/server/spec-decisions.mjs +2 -2
- package/dist/server/state.d.mts +6 -6
- package/dist/server/state.mjs +3 -5
- package/dist/server/studio-for.d.mts +7 -0
- package/dist/server/studio-for.mjs +23 -7
- 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 +10 -8
- package/dist/server/thread-forms.mjs +33 -14
- package/dist/server/thread-place.d.mts +2 -2
- package/dist/server/thread-place.mjs +28 -18
- package/dist/server/thread-source.d.mts +35 -5
- package/dist/server/thread-source.mjs +43 -40
- package/dist/server/tools/context.d.mts +53 -35
- package/dist/server/tools/context.mjs +17 -32
- package/dist/server/tools/describe.d.mts +3 -5
- package/dist/server/tools/describe.mjs +4 -24
- package/dist/server/tools/export.d.mts +14 -2
- package/dist/server/tools/export.mjs +30 -25
- package/dist/server/tools/feedback.d.mts +20 -4
- package/dist/server/tools/feedback.mjs +70 -62
- package/dist/server/tools/place-frame.d.mts +16 -3
- package/dist/server/tools/place-frame.mjs +97 -66
- 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/result.mjs +2 -2
- 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 +65 -59
- package/dist/server/tools/studio-context.d.mts +9 -0
- package/dist/server/tools/studio-context.mjs +45 -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 +192 -125
- package/dist/server/unresolved-imports.mjs +4 -1
- package/dist/server/update-branch.mjs +2 -2
- package/dist/server/update-studio.d.mts +3 -1
- package/dist/server/update-studio.mjs +30 -19
- package/dist/server/updates.mjs +10 -10
- package/dist/server/vite.mjs +29 -24
- package/dist/server/web-app.mjs +17 -30
- package/dist/server/welcome.mjs +4 -2
- package/dist/server/work-groups.d.mts +13 -2
- package/dist/server/work-groups.mjs +58 -23
- package/dist/server/workspace-settings.d.mts +9 -5
- package/dist/server/workspace-settings.mjs +40 -39
- package/dist/server/zip.mjs +1 -1
- package/dist/setup/apply.d.mts +6 -1
- package/dist/setup/apply.mjs +26 -23
- package/dist/setup/cancelled.d.mts +6 -0
- package/dist/setup/cancelled.mjs +10 -0
- package/dist/setup/commit-lint.d.mts +6 -4
- package/dist/setup/commit-lint.mjs +23 -27
- package/dist/setup/components.mjs +3 -3
- package/dist/setup/config-source.d.mts +16 -5
- package/dist/setup/config-source.mjs +36 -27
- package/dist/setup/create.mjs +64 -52
- package/dist/setup/design-md-setup.d.mts +6 -4
- package/dist/setup/design-md-setup.mjs +14 -12
- package/dist/setup/design-md.mjs +50 -52
- package/dist/setup/design-system-checks.mjs +8 -8
- package/dist/setup/detect/workspace.d.mts +3 -17
- package/dist/setup/detect/workspace.mjs +23 -126
- package/dist/setup/detect.mjs +24 -18
- package/dist/setup/doctor.d.mts +1 -1
- package/dist/setup/doctor.mjs +15 -14
- package/dist/setup/existing-setup.mjs +20 -15
- package/dist/setup/git-checks.mjs +5 -5
- package/dist/setup/hash.d.mts +4 -0
- package/dist/setup/hash.mjs +6 -0
- package/dist/setup/hints.mjs +5 -4
- package/dist/setup/host-format.mjs +2 -6
- package/dist/setup/json.d.mts +12 -0
- package/dist/setup/json.mjs +9 -0
- package/dist/setup/migrate/agent-files.mjs +8 -7
- package/dist/setup/migrate/config-name.mjs +1 -1
- package/dist/setup/migrate/design-system.mjs +37 -34
- package/dist/setup/migrate/dex-folder.d.mts +1 -1
- package/dist/setup/migrate/dex-folder.mjs +27 -23
- package/dist/setup/migrate/explorations.mjs +7 -5
- package/dist/setup/migrate/files-folder.mjs +35 -20
- package/dist/setup/migrate/frame-notes.d.mts +20 -0
- package/dist/setup/migrate/frame-notes.mjs +126 -0
- package/dist/setup/migrate/frame-uids.d.mts +24 -0
- package/dist/setup/migrate/frame-uids.mjs +144 -0
- package/dist/setup/migrate/guides.mjs +1 -1
- package/dist/setup/migrate/manifest-name.d.mts +23 -0
- package/dist/setup/migrate/manifest-name.mjs +93 -0
- package/dist/setup/migrate/migrations.mjs +12 -2
- package/dist/setup/migrate/people-folders.d.mts +3 -3
- package/dist/setup/migrate/people-folders.mjs +25 -36
- package/dist/setup/migrate/picks-file.d.mts +33 -0
- package/dist/setup/migrate/picks-file.mjs +172 -0
- package/dist/setup/migrate/project-files.mjs +10 -8
- package/dist/setup/migrate/row-titles.mjs +5 -2
- package/dist/setup/migrate/setup-files.mjs +18 -12
- package/dist/setup/migrate/studio-state.mjs +8 -6
- package/dist/setup/own-app.d.mts +2 -1
- package/dist/setup/own-app.mjs +17 -15
- package/dist/setup/placement.mjs +20 -18
- package/dist/setup/plan.d.mts +5 -3
- package/dist/setup/plan.mjs +7 -6
- package/dist/setup/project.mjs +11 -8
- package/dist/setup/prompts.d.mts +1 -5
- package/dist/setup/prompts.mjs +54 -53
- package/dist/setup/provider.mjs +3 -2
- package/dist/setup/questions.d.mts +13 -7
- package/dist/setup/questions.mjs +2 -4
- package/dist/setup/starters.mjs +6 -3
- package/dist/setup/templates.d.mts +3 -3
- package/dist/setup/templates.mjs +18 -14
- package/dist/setup/workspace-setup.mjs +4 -5
- package/dist/setup/write.d.mts +10 -2
- package/dist/setup/write.mjs +17 -16
- package/dist/shared/block-merge.d.mts +5 -4
- package/dist/shared/block-merge.mjs +5 -5
- package/dist/shared/built-pictures.d.mts +13 -4
- package/dist/shared/built-pictures.mjs +16 -8
- package/dist/shared/canvas-core.d.mts +153 -59
- package/dist/shared/canvas-core.mjs +236 -78
- package/dist/shared/canvas-file.d.mts +18 -6
- package/dist/shared/canvas-merge.d.mts +28 -0
- package/dist/shared/canvas-merge.mjs +384 -0
- package/dist/shared/change-pictures-core.d.mts +6 -0
- package/dist/shared/change-pictures-core.mjs +5 -0
- package/dist/shared/checks.d.mts +8 -0
- package/dist/shared/checks.mjs +9 -1
- package/dist/shared/code-anchor.d.mts +16 -0
- package/dist/shared/code-anchor.mjs +33 -0
- package/dist/shared/commands-core.d.mts +25 -0
- package/dist/shared/commands-core.mjs +31 -7
- package/dist/shared/comments/routes.d.mts +4 -2
- package/dist/shared/comments/routes.mjs +6 -4
- package/dist/shared/comments/state.d.mts +71 -0
- package/dist/shared/comments/state.mjs +66 -0
- package/dist/shared/contributors-merge.mjs +4 -4
- package/dist/shared/devices.d.mts +5 -4
- package/dist/shared/devices.mjs +1 -1
- package/dist/shared/export-core.d.mts +0 -1
- package/dist/shared/export-core.mjs +20 -21
- package/dist/shared/feedback.mjs +5 -7
- package/dist/shared/file-errors.mjs +3 -3
- package/dist/shared/file-names.d.mts +6 -0
- package/dist/shared/file-names.mjs +521 -0
- package/dist/shared/fix-prompt.mjs +1 -1
- package/dist/shared/front-matter.mjs +8 -9
- package/dist/shared/generated-sections.mjs +7 -7
- package/dist/shared/git-core.mjs +11 -11
- package/dist/shared/json-style.mjs +5 -4
- package/dist/shared/live-core.d.mts +10 -5
- package/dist/shared/live-core.mjs +5 -4
- package/dist/shared/live-presence.mjs +12 -9
- package/dist/shared/markup-prompt.d.mts +7 -3
- package/dist/shared/markup-prompt.mjs +9 -5
- package/dist/shared/open-page-core.mjs +6 -5
- package/dist/shared/page-looks.d.mts +12 -0
- package/dist/shared/page-looks.mjs +49 -0
- package/dist/shared/page-messages.d.mts +16 -4
- package/dist/shared/page-messages.mjs +26 -14
- package/dist/shared/page-review.mjs +8 -10
- package/dist/shared/people-core.d.mts +37 -29
- package/dist/shared/people-core.mjs +49 -24
- package/dist/shared/{annotations-core.d.mts → picks-core.d.mts} +24 -29
- package/dist/shared/{annotations-core.mjs → picks-core.mjs} +48 -62
- package/dist/shared/prototypes-core.d.mts +70 -15
- package/dist/shared/prototypes-core.mjs +184 -100
- package/dist/shared/references-core.mjs +5 -6
- package/dist/shared/removed-views-core.mjs +6 -6
- package/dist/shared/review-file.mjs +3 -3
- package/dist/shared/server-page.mjs +4 -4
- package/dist/shared/signup.mjs +3 -2
- package/dist/shared/sketch-core.mjs +7 -7
- package/dist/shared/snapshot-clipboard.d.mts +11 -4
- package/dist/shared/snapshot-clipboard.mjs +2 -2
- package/dist/shared/snapshot-images.d.mts +10 -1
- package/dist/shared/snapshot-images.mjs +62 -14
- package/dist/shared/spec-quote.mjs +4 -4
- package/dist/shared/studio-events.d.mts +5 -36
- package/dist/shared/studio-events.mjs +5 -5
- package/dist/shared/studio-files.d.mts +3 -3
- package/dist/shared/studio-files.mjs +7 -7
- package/dist/shared/studio-routes.d.mts +39 -30
- package/dist/shared/studio-routes.mjs +6 -1
- package/dist/shared/threads-core.d.mts +346 -32
- package/dist/shared/threads-core.mjs +223 -76
- package/dist/shared/unknown-fields.d.mts +10 -0
- package/dist/shared/unknown-fields.mjs +74 -0
- package/dist/shared/unzip.d.mts +4 -2
- package/dist/shared/unzip.mjs +9 -7
- package/dist/shared/word-diff.mjs +6 -6
- package/dist/shared/xray.d.mts +4 -0
- package/dist/shared/xray.mjs +11 -0
- package/extension/dist/background.js +1 -1
- package/extension/dist/manifest.json +2 -3
- package/extension/dist/picker.js +122 -106
- package/package.json +83 -60
- package/schema/canvas.json +390 -0
- package/schema/comment-event.json +441 -0
- package/schema/contributors.json +30 -0
- package/schema/defs.json +66 -0
- package/schema/file.json +59 -0
- package/schema/picks.json +45 -0
- package/src/cli/banner.ts +46 -5
- package/src/cli/command.ts +25 -12
- package/src/cli/commands/agents/add.ts +4 -1
- package/src/cli/commands/agents.ts +1 -0
- package/src/cli/commands/app.ts +33 -24
- package/src/cli/commands/build.ts +4 -0
- package/src/cli/commands/claude.ts +20 -10
- package/src/cli/commands/cloud/link.ts +2 -0
- package/src/cli/commands/cloud/live.ts +2 -0
- package/src/cli/commands/cloud/login.ts +1 -0
- package/src/cli/commands/cloud/publish.ts +23 -9
- package/src/cli/commands/cloud/push.ts +2 -0
- package/src/cli/commands/cloud/status.ts +2 -0
- package/src/cli/commands/cloud/unlink.ts +2 -0
- package/src/cli/commands/cloud.ts +1 -0
- package/src/cli/commands/components.ts +1 -0
- package/src/cli/commands/create.ts +3 -0
- package/src/cli/commands/dev.ts +148 -32
- package/src/cli/commands/doctor.ts +9 -1
- package/src/cli/commands/export.ts +10 -1
- package/src/cli/commands/extension.ts +1 -0
- package/src/cli/commands/hook.ts +17 -1
- package/src/cli/commands/init.ts +3 -0
- package/src/cli/commands/mcp.ts +33 -4
- package/src/cli/commands/merge-canvas.ts +134 -0
- package/src/cli/commands/merge-contributors.ts +10 -4
- package/src/cli/commands/merge-spec.ts +7 -1
- package/src/cli/commands/preview.ts +2 -0
- package/src/cli/commands/stop.ts +6 -0
- package/src/cli/commands/upgrade.ts +11 -0
- package/src/cli/commands/work/check.ts +2 -0
- package/src/cli/commands/work/contributor.ts +3 -1
- package/src/cli/commands/work/new.ts +3 -1
- package/src/cli/commands/work/presence.ts +3 -1
- package/src/cli/commands/work/scope.ts +3 -1
- package/src/cli/commands/work/snapshot.ts +3 -1
- package/src/cli/commands/work/thread.ts +3 -1
- package/src/cli/commands/work/threads.ts +3 -1
- package/src/cli/commands/work/whoami.ts +3 -1
- package/src/cli/help.ts +32 -10
- package/src/cli/main.ts +31 -3
- package/src/cli/mcp-relay.ts +163 -55
- package/src/cli/recovery-server.ts +23 -9
- package/src/cli/strict-flags.ts +41 -6
- package/src/cli/supervise.ts +119 -37
- package/src/cli/ui.ts +55 -26
- package/src/config/design-system.ts +65 -18
- package/src/config/index.ts +1 -0
- package/src/config/load.ts +37 -6
- package/src/config/project-files.ts +180 -43
- package/src/config/renamed.ts +15 -20
- package/src/config/schema.ts +8 -0
- package/src/content/biome.ts +31 -17
- package/src/content/capture.ts +200 -56
- package/src/content/commands.ts +85 -27
- package/src/content/comments-log.ts +183 -34
- package/src/content/component-props.ts +134 -23
- package/src/content/content.ts +794 -230
- package/src/content/devices.ts +12 -3
- package/src/content/element-words.ts +33 -8
- package/src/content/file-turns.ts +12 -4
- package/src/content/first-run.ts +10 -10
- package/src/content/flow-specs.ts +88 -40
- package/src/content/format-check.ts +599 -0
- package/src/content/hosted-person.ts +31 -7
- package/src/content/insert-edit.ts +52 -17
- package/src/content/jsx-source.ts +17 -6
- package/src/content/last-edited.ts +15 -4
- package/src/content/layout.ts +131 -9
- package/src/content/merge-rules.ts +71 -37
- package/src/content/prop-edit.ts +60 -4
- package/src/content/prototype-checks.ts +52 -18
- package/src/content/prototype-summary.ts +37 -20
- package/src/content/prototypes.ts +138 -52
- package/src/content/review-import.ts +8 -1
- package/src/content/review-pages.ts +63 -8
- package/src/content/screenshot.ts +91 -25
- package/src/content/snapshot-client.ts +42 -3
- package/src/content/store.ts +177 -55
- package/src/content/sub-agents.ts +107 -0
- package/src/content/text-edit.ts +41 -5
- package/src/content/text-replace.ts +130 -32
- package/src/content/thread-module.ts +84 -12
- package/src/content/threads.ts +146 -16
- package/src/content/trash.ts +100 -40
- package/src/paste/figma/appearance.ts +39 -6
- package/src/paste/figma/captures.ts +21 -6
- package/src/paste/figma/decode.ts +82 -15
- package/src/paste/figma/document.ts +73 -5
- package/src/paste/figma/layout.ts +44 -5
- package/src/paste/figma/paint.ts +52 -8
- package/src/paste/figma/render.ts +18 -3
- package/src/paste/figma/styles.ts +20 -5
- package/src/paste/figma/text.ts +97 -29
- package/src/paste/figma/vector.ts +74 -12
- package/src/paste/fonts.ts +30 -9
- package/src/paste/paste.ts +63 -16
- package/src/paths.ts +66 -87
- package/src/server/agent-session.ts +451 -20
- package/src/server/agent-tools.ts +53 -0
- package/src/server/agents-place.ts +22 -0
- package/src/server/allowed-request.ts +7 -1
- package/src/server/avatars.ts +18 -6
- package/src/server/brief.ts +75 -16
- package/src/server/briefing.ts +19 -9
- package/src/server/build-pictures.ts +57 -9
- package/src/server/build-settings.ts +10 -4
- package/src/server/canvas-presence.ts +31 -2
- package/src/server/change-picture-store.ts +71 -0
- package/src/server/change-pictures.ts +244 -0
- package/src/server/changelog.ts +15 -3
- package/src/server/claimed-presence.ts +32 -8
- package/src/server/close-check.ts +125 -25
- package/src/server/cloud.ts +61 -12
- package/src/server/command-settings.ts +30 -12
- package/src/server/comments/actions.ts +137 -133
- package/src/server/comments/agent-actions.ts +217 -0
- package/src/server/comments/close-tools.ts +250 -0
- package/src/server/comments/files.ts +74 -0
- package/src/server/comments/hand-out.ts +105 -0
- package/src/server/comments/push.ts +551 -0
- package/src/server/comments/routes.ts +39 -9
- package/src/server/comments/studio-files.ts +159 -0
- package/src/server/comments/tools.ts +103 -301
- package/src/server/comments/workflow.ts +18 -0
- package/src/server/comments/workspace.ts +124 -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 +131 -57
- package/src/server/export/build.ts +37 -3
- package/src/server/export/page.ts +16 -7
- package/src/server/export/plugin.ts +28 -9
- package/src/server/export/run.ts +12 -0
- package/src/server/export/save.ts +5 -0
- package/src/server/features.ts +4 -6
- package/src/server/file-errors.ts +35 -5
- package/src/server/file-lock.ts +53 -19
- package/src/server/git-asks.ts +13 -4
- package/src/server/git-host.ts +51 -12
- package/src/server/git-paused.ts +39 -3
- package/src/server/git-settings.ts +15 -5
- package/src/server/git-sync.ts +229 -36
- package/src/server/git.ts +236 -116
- package/src/server/hosted.ts +11 -0
- package/src/server/instructions.ts +32 -7
- package/src/server/live-mirror.ts +109 -10
- package/src/server/live.ts +85 -16
- package/src/server/machine-update.ts +167 -35
- package/src/server/me.ts +8 -3
- package/src/server/merge-check.ts +125 -0
- package/src/server/next.ts +30 -8
- package/src/server/notices.ts +77 -15
- package/src/server/open-page.ts +44 -19
- package/src/server/outcome.ts +8 -7
- package/src/server/own-copies.ts +83 -20
- package/src/server/people.ts +22 -7
- package/src/server/personal-folder.ts +3 -0
- package/src/server/pictures.ts +76 -8
- package/src/server/port.ts +38 -6
- package/src/server/prebundle.ts +53 -18
- package/src/server/preferences.ts +6 -1
- package/src/server/presence.ts +17 -6
- package/src/server/problems.ts +2 -0
- package/src/server/project-id.ts +2 -0
- package/src/server/project-public.ts +12 -1
- package/src/server/prototype-brief.ts +36 -17
- package/src/server/push-notice.ts +11 -1
- package/src/server/quiet-run.ts +10 -3
- package/src/server/registry.ts +34 -7
- package/src/server/requests.ts +625 -254
- package/src/server/response-budget.ts +34 -9
- package/src/server/restart.ts +36 -3
- package/src/server/roster.ts +125 -33
- package/src/server/saved.ts +15 -5
- package/src/server/source-stamp.ts +116 -12
- package/src/server/spec-decisions.ts +11 -2
- package/src/server/state.ts +21 -9
- package/src/server/stop-studio.ts +9 -1
- package/src/server/studio-for.ts +70 -16
- package/src/server/studio-server.ts +233 -0
- package/src/server/sync-install.ts +8 -3
- package/src/server/thread-forms.ts +125 -28
- package/src/server/thread-place.ts +61 -19
- package/src/server/thread-source.ts +114 -50
- package/src/server/tools/context.ts +95 -112
- package/src/server/tools/describe.ts +10 -35
- package/src/server/tools/export.ts +13 -11
- package/src/server/tools/feedback.ts +47 -22
- package/src/server/tools/place-frame.ts +112 -26
- package/src/server/tools/prototype-name.ts +11 -7
- package/src/server/tools/reading.ts +215 -177
- package/src/server/tools/result.ts +5 -2
- package/src/server/tools/show.ts +35 -12
- package/src/server/tools/snapshot.ts +26 -13
- package/src/server/tools/studio-context.ts +82 -0
- package/src/server/tools/thread-list.ts +58 -43
- package/src/server/tools/watch.ts +267 -93
- package/src/server/unresolved-imports.ts +18 -3
- package/src/server/update-branch.ts +29 -4
- package/src/server/update-studio.ts +54 -20
- package/src/server/updates.ts +55 -9
- package/src/server/vite.ts +154 -29
- package/src/server/web-app.ts +27 -46
- package/src/server/welcome.ts +8 -3
- package/src/server/work-groups.ts +150 -34
- package/src/server/workspace-settings.ts +133 -45
- package/src/server/zip.ts +21 -3
- package/src/setup/apply.ts +132 -40
- package/src/setup/cancelled.ts +7 -0
- package/src/setup/commit-lint.ts +104 -28
- package/src/setup/components.ts +18 -3
- package/src/setup/config-choices.ts +7 -0
- package/src/setup/config-source.ts +226 -61
- package/src/setup/create.ts +281 -64
- package/src/setup/design-md-setup.ts +48 -11
- package/src/setup/design-md.ts +276 -80
- package/src/setup/design-system-checks.ts +70 -12
- package/src/setup/design-system-guide.ts +7 -0
- package/src/setup/detect/workspace.ts +219 -192
- package/src/setup/detect.ts +95 -26
- package/src/setup/doctor.ts +86 -22
- package/src/setup/existing-setup.ts +114 -22
- package/src/setup/git-checks.ts +60 -7
- package/src/setup/hash.ts +5 -0
- package/src/setup/hints.ts +42 -4
- package/src/setup/host-format.ts +31 -7
- package/src/setup/json.ts +23 -0
- package/src/setup/migrate/agent-files.ts +45 -9
- package/src/setup/migrate/config-name.ts +13 -1
- package/src/setup/migrate/design-system.ts +198 -50
- package/src/setup/migrate/dex-folder.ts +145 -30
- package/src/setup/migrate/explorations.ts +7 -3
- package/src/setup/migrate/files-folder.ts +145 -43
- package/src/setup/migrate/frame-notes.ts +253 -0
- package/src/setup/migrate/frame-uids.ts +274 -0
- package/src/setup/migrate/guides.ts +18 -15
- package/src/setup/migrate/manifest-name.ts +183 -0
- package/src/setup/migrate/migrations.ts +28 -6
- package/src/setup/migrate/people-folders.ts +76 -48
- package/src/setup/migrate/picks-file.ts +297 -0
- package/src/setup/migrate/project-files.ts +8 -3
- package/src/setup/migrate/row-titles.ts +8 -4
- package/src/setup/migrate/setup-files.ts +41 -16
- package/src/setup/migrate/studio-state.ts +26 -5
- package/src/setup/own-app.ts +74 -20
- package/src/setup/placement.ts +80 -21
- package/src/setup/plan.ts +96 -17
- package/src/setup/project.ts +75 -11
- package/src/setup/prompts.ts +201 -54
- package/src/setup/provider.ts +20 -2
- package/src/setup/questions.ts +71 -23
- package/src/setup/starters.ts +55 -14
- package/src/setup/templates.ts +66 -20
- package/src/setup/workspace-setup.ts +50 -5
- package/src/setup/write.ts +63 -25
- package/src/shared/agent-prompts.ts +1 -1
- package/src/shared/block-merge.ts +65 -8
- package/src/shared/built-pictures.ts +38 -9
- package/src/shared/canvas-core.ts +690 -155
- package/src/shared/canvas-file.ts +18 -6
- package/src/shared/canvas-merge.ts +784 -0
- package/src/shared/change-pictures-core.ts +8 -0
- package/src/shared/checks.ts +18 -0
- package/src/shared/code-anchor.ts +73 -0
- package/src/shared/commands-core.ts +62 -8
- package/src/shared/comments/routes.ts +7 -5
- package/src/shared/comments/state.ts +146 -0
- package/src/shared/contributors-merge.ts +26 -12
- package/src/shared/devices.ts +63 -16
- package/src/shared/export-core.ts +51 -29
- package/src/shared/feedback.ts +56 -8
- package/src/shared/file-errors.ts +4 -4
- package/src/shared/file-names.ts +528 -0
- package/src/shared/fix-prompt.ts +3 -1
- package/src/shared/frame-grids.ts +33 -8
- package/src/shared/front-matter.ts +24 -7
- package/src/shared/generated-sections.ts +30 -7
- package/src/shared/git-core.ts +40 -14
- package/src/shared/json-style.ts +24 -6
- package/src/shared/listing.ts +1 -0
- package/src/shared/live-core.ts +55 -12
- package/src/shared/live-presence.ts +66 -15
- package/src/shared/markup-prompt.ts +9 -4
- package/src/shared/open-page-core.ts +15 -8
- package/src/shared/page-looks.ts +133 -0
- package/src/shared/page-messages.ts +57 -17
- package/src/shared/page-review.ts +60 -35
- package/src/shared/paste-arrangement.ts +4 -0
- package/src/shared/people-core.ts +251 -59
- package/src/shared/{annotations-core.ts → picks-core.ts} +125 -96
- package/src/shared/prototypes-core.ts +323 -128
- package/src/shared/references-core.ts +20 -8
- package/src/shared/removed-views-core.ts +30 -7
- package/src/shared/review-file.ts +38 -19
- package/src/shared/server-page.ts +13 -5
- package/src/shared/signup.ts +12 -2
- package/src/shared/sketch-core.ts +55 -7
- package/src/shared/snapshot-clipboard.ts +26 -3
- package/src/shared/snapshot-images.ts +114 -14
- package/src/shared/spec-quote.ts +36 -5
- package/src/shared/studio-events.ts +24 -37
- package/src/shared/studio-files.ts +28 -10
- package/src/shared/studio-routes.ts +34 -32
- package/src/shared/threads-core.ts +597 -164
- package/src/shared/unknown-fields.ts +118 -0
- package/src/shared/unzip.ts +22 -8
- package/src/shared/update-core.ts +3 -0
- package/src/shared/word-diff.ts +31 -6
- package/src/shared/xray.ts +14 -0
- package/templates/agents/dex-checker.md +25 -0
- package/templates/agents/dex-riffer.md +16 -0
- package/templates/agents/dex-worker.md +25 -0
- package/templates/feedback-workflow.md +1 -1
- package/templates/methods/handoff.md +1 -1
- package/templates/methods/review.md +14 -9
- package/templates/rules/always.md +1 -1
- package/templates/rules/canvas-frames.md +10 -2
- package/templates/rules/canvas.md +23 -13
- package/templates/rules/prototypes.md +11 -8
- package/templates/rules/scope.md +2 -2
- package/templates/skills/boil/SKILL.md +40 -0
- package/templates/skills/comprehend/SKILL.md +1 -0
- package/templates/skills/distill/SKILL.md +1 -0
- package/templates/skills/export-prototype/SKILL.md +1 -0
- package/templates/skills/restrain/SKILL.md +76 -0
- package/templates/skills/riff/SKILL.md +2 -0
- package/templates/skills/riff-deep/SKILL.md +2 -0
- package/templates/skills/riff-max/SKILL.md +2 -0
- package/templates/skills/riff-state/SKILL.md +2 -0
- package/templates/skills/riff-up/SKILL.md +2 -0
- package/templates/skills/riff-wide/SKILL.md +2 -0
- package/templates/starter-prototype/welcome.tsx +8 -4
- package/templates/starters/standalone/package.json +1 -1
- package/templates/starters/turborepo/apps/web/package.json +1 -1
- package/templates/starters/turborepo/apps/web/src/app.tsx +3 -3
- package/templates/starters/turborepo/apps/web/src/main.tsx +4 -1
- package/templates/starters/turborepo/apps/web/vite.config.ts +2 -1
- package/templates/starters/turborepo/package.json +2 -2
- package/templates/starters/turborepo/packages/ui/package.json +3 -3
- package/templates/starters/vite/package.json +1 -1
- package/templates/starters/vite/src/app.tsx +3 -2
- package/templates/starters/vite/src/components/ui/button.tsx +1 -1
- package/templates/starters/vite/src/index.css +1 -1
- package/templates/starters/vite/src/main.tsx +4 -1
- package/templates/starters/vite/vite.config.ts +2 -1
- package/app/canvas/pass-wheel.ts +0 -48
- package/app/canvas/stack-node.tsx +0 -92
- package/dist/config/package-manager.d.mts +0 -15
- package/dist/server/agent-env.d.mts +0 -16
- package/dist/server/agents.d.mts +0 -143
- package/dist/server/agents.mjs +0 -786
- package/dist/server/channel.d.mts +0 -239
- package/dist/server/channel.mjs +0 -687
- package/dist/server/mcp-handover.d.mts +0 -37
- package/dist/server/mcp.d.mts +0 -61
- package/dist/server/mcp.mjs +0 -157
- package/dist/server/spec-suggestions.d.mts +0 -21
- package/dist/server/spec-suggestions.mjs +0 -59
- package/dist/setup/desktop-app-script.d.mts +0 -28
- package/dist/setup/desktop-app-script.mjs +0 -775
- package/dist/setup/desktop-app-start.d.mts +0 -65
- package/dist/setup/desktop-app.d.mts +0 -174
- package/dist/setup/desktop-app.mjs +0 -551
- package/dist/shared/element-steps.d.mts +0 -38
- package/dist/shared/element-steps.mjs +0 -40
- package/extension/dist/feedback.html +0 -19
- package/extension/dist/feedback.js +0 -519
- package/src/config/package-manager.ts +0 -93
- package/src/server/agent-env.ts +0 -70
- package/src/server/agents.ts +0 -1251
- package/src/server/channel.ts +0 -1161
- package/src/server/mcp-handover.ts +0 -147
- package/src/server/mcp.ts +0 -295
- package/src/server/spec-suggestions.ts +0 -87
- package/src/setup/desktop-app-script.ts +0 -815
- package/src/setup/desktop-app-start.ts +0 -220
- package/src/setup/desktop-app.ts +0 -849
- package/src/shared/element-steps.ts +0 -99
package/src/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,21 +20,17 @@ 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 {
|
|
33
|
+
type AskedCell,
|
|
34
34
|
appendOwnFrame,
|
|
35
35
|
type CanvasPoint,
|
|
36
36
|
type Cell,
|
|
@@ -38,16 +38,19 @@ import {
|
|
|
38
38
|
canvasProblems,
|
|
39
39
|
type PageSize,
|
|
40
40
|
placeViewInCell,
|
|
41
|
-
|
|
42
|
-
|
|
41
|
+
canvasFormProblems,
|
|
42
|
+
stackPiles,
|
|
43
|
+
parseFrameKey,
|
|
44
|
+
stepAsked,
|
|
43
45
|
uniqueId,
|
|
44
46
|
type Viewport,
|
|
45
47
|
viewOf,
|
|
48
|
+
whereInRow,
|
|
46
49
|
} from "../shared/canvas-core.ts";
|
|
47
50
|
import type { Canvas, Section, ViewFrame } from "../shared/canvas-file.ts";
|
|
48
51
|
import { isOneOf, isRecord, isText } from "../shared/checks.ts";
|
|
49
52
|
import { defaultDevice } from "../shared/devices.ts";
|
|
50
|
-
import {
|
|
53
|
+
import { jsonInLayout } from "../shared/json-style.ts";
|
|
51
54
|
import { LARGE_CANVAS_BYTES } from "../shared/live-core.ts";
|
|
52
55
|
import { targetForPath } from "../shared/live-presence.ts";
|
|
53
56
|
import {
|
|
@@ -62,6 +65,13 @@ import {
|
|
|
62
65
|
savedPart,
|
|
63
66
|
withFrameUids,
|
|
64
67
|
} from "../shared/people-core.ts";
|
|
68
|
+
import {
|
|
69
|
+
type Authored,
|
|
70
|
+
checkFrameAnchor,
|
|
71
|
+
readPicks,
|
|
72
|
+
withoutPick,
|
|
73
|
+
withPick,
|
|
74
|
+
} from "../shared/picks-core.ts";
|
|
65
75
|
import type { PresenceTarget } from "../shared/presence-core.ts";
|
|
66
76
|
import {
|
|
67
77
|
framePage,
|
|
@@ -69,6 +79,7 @@ import {
|
|
|
69
79
|
newFileId,
|
|
70
80
|
PROTOTYPES_FOLDER,
|
|
71
81
|
type PrototypeFiles,
|
|
82
|
+
placeOf,
|
|
72
83
|
prototypeFiles,
|
|
73
84
|
prototypePage,
|
|
74
85
|
slugify,
|
|
@@ -84,12 +95,16 @@ import {
|
|
|
84
95
|
type AgentAction,
|
|
85
96
|
agentChange,
|
|
86
97
|
describeThread,
|
|
98
|
+
targetFrameKey,
|
|
87
99
|
type ThreadChange,
|
|
88
100
|
} from "../shared/threads-core.ts";
|
|
101
|
+
import { withUnknownFields } from "../shared/unknown-fields.ts";
|
|
89
102
|
import { findBiome, formatText } from "./biome.ts";
|
|
90
103
|
import { loadDevices } from "./devices.ts";
|
|
91
104
|
import { inTurn, replaceFile } from "./file-turns.ts";
|
|
105
|
+
import { fileFolderFindings, studioFindings } from "./format-check.ts";
|
|
92
106
|
import { hostedPerson, isHosted } from "./hosted-person.ts";
|
|
107
|
+
import { LAYOUT_FILE, type LayoutState, studioLayout } from "./layout.ts";
|
|
93
108
|
import { checkPrototype, errorLines, findingLine } from "./prototype-checks.ts";
|
|
94
109
|
import {
|
|
95
110
|
clashingViews,
|
|
@@ -172,6 +187,8 @@ export interface CommandValues {
|
|
|
172
187
|
}
|
|
173
188
|
|
|
174
189
|
/** A path as people see it: relative to where they ran the command. */
|
|
190
|
+
const execFileAsync = promisify(execFile);
|
|
191
|
+
|
|
175
192
|
const display = (path: string): string => relative(process.cwd(), path) || ".";
|
|
176
193
|
|
|
177
194
|
const shownIn = (root: string, file: string): string =>
|
|
@@ -179,43 +196,78 @@ const shownIn = (root: string, file: string): string =>
|
|
|
179
196
|
|
|
180
197
|
export const STATUSES = ["exploring", "in-review", "handed-off", "archived"];
|
|
181
198
|
|
|
182
|
-
const DATE_RE = /^\d{4}-\d{2}-\d{2}
|
|
199
|
+
const DATE_RE = /^\d{4}-\d{2}-\d{2}$/u;
|
|
200
|
+
|
|
183
201
|
// A GitHub username, and after it the `_company` that an enterprise's own
|
|
184
202
|
// accounts end with (ana_acme): the only place GitHub puts an underscore.
|
|
185
203
|
const GITHUB_LOGIN_RE =
|
|
186
|
-
/^[a-z\d](?:[a-z\d]|-(?=[a-z\d])){0,38}(?:_[a-z\d]+)?$/
|
|
187
|
-
|
|
188
|
-
const
|
|
204
|
+
/^[a-z\d](?:[a-z\d]|-(?=[a-z\d])){0,38}(?:_[a-z\d]+)?$/iu;
|
|
205
|
+
|
|
206
|
+
const GITHUB_NOREPLY_RE =
|
|
207
|
+
/^(?:\d+\+)?(?<login>[^@]+)@users\.noreply\.github\.com$/iu;
|
|
208
|
+
|
|
209
|
+
const LEADING_AT_RE = /^@/u;
|
|
189
210
|
const GH_TIMEOUT_MS = 5000;
|
|
190
|
-
const DOC_FILE_RE = /\.md
|
|
211
|
+
const DOC_FILE_RE = /\.md$/u;
|
|
191
212
|
|
|
192
213
|
/** A JSON file, as the shape the caller reads it into. */
|
|
193
214
|
const readJson = async <T>(path: string): Promise<T> => {
|
|
194
215
|
try {
|
|
195
216
|
return JSON.parse(await readFile(path, "utf8"));
|
|
196
217
|
} catch (error) {
|
|
197
|
-
|
|
218
|
+
// SAFETY: readFile and JSON.parse fail with Errors.
|
|
219
|
+
throw new Error(`${display(path)}: ${(error as Error).message}`, {
|
|
220
|
+
cause: error,
|
|
221
|
+
});
|
|
198
222
|
}
|
|
199
223
|
};
|
|
200
224
|
|
|
201
|
-
|
|
202
|
-
|
|
225
|
+
/**
|
|
226
|
+
* One of the format's JSON files, laid out as jsonInLayout lays out every
|
|
227
|
+
* one Dex writes: as it was, or as Biome and Prettier would lay a new one.
|
|
228
|
+
*/
|
|
229
|
+
// oxlint-disable-next-line anti-slop/no-unknown-parameters -- any JSON value: jsonInLayout writes whatever it is given
|
|
230
|
+
const writeJson = async (path: string, value: unknown): Promise<void> =>
|
|
231
|
+
writeFile(
|
|
232
|
+
path,
|
|
233
|
+
jsonInLayout(value, await readFile(path, "utf8").catch(() => undefined))
|
|
234
|
+
);
|
|
203
235
|
|
|
204
236
|
const listFiles = async (path: string, pattern: RegExp): Promise<string[]> => {
|
|
205
237
|
if (!existsSync(path)) {
|
|
206
238
|
return [];
|
|
207
239
|
}
|
|
240
|
+
|
|
208
241
|
const entries = await readdir(path, { withFileTypes: true });
|
|
242
|
+
|
|
209
243
|
return entries
|
|
210
244
|
.filter((entry) => entry.isFile() && pattern.test(entry.name))
|
|
211
245
|
.map((entry) => entry.name.replace(pattern, ""))
|
|
212
|
-
.
|
|
246
|
+
.toSorted();
|
|
213
247
|
};
|
|
214
248
|
|
|
215
249
|
// --- Validation -------------------------------------------------------------
|
|
216
250
|
|
|
217
|
-
/**
|
|
218
|
-
|
|
251
|
+
/** A contributor's fields, as read from JSON before they are checked. */
|
|
252
|
+
interface UncheckedContributor {
|
|
253
|
+
discipline?: unknown;
|
|
254
|
+
git?: unknown;
|
|
255
|
+
github?: unknown;
|
|
256
|
+
name?: unknown;
|
|
257
|
+
slug?: unknown;
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
/** A file's manifest fields, as read from JSON before they are checked. */
|
|
261
|
+
interface UncheckedManifest {
|
|
262
|
+
cover?: unknown;
|
|
263
|
+
created?: unknown;
|
|
264
|
+
description?: unknown;
|
|
265
|
+
status?: unknown;
|
|
266
|
+
tags?: unknown;
|
|
267
|
+
title?: unknown;
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
/* oxlint-disable anti-slop/no-unknown-parameters -- these check JSON as it is read, before it is trusted */
|
|
219
271
|
|
|
220
272
|
/**
|
|
221
273
|
* What is wrong with a contributor's `github`, or undefined: not a GitHub
|
|
@@ -229,13 +281,17 @@ function githubProblem(
|
|
|
229
281
|
if (github === undefined) {
|
|
230
282
|
return;
|
|
231
283
|
}
|
|
284
|
+
|
|
232
285
|
if (!(isText(github) && GITHUB_LOGIN_RE.test(github))) {
|
|
233
286
|
return '"github" must be a GitHub username';
|
|
234
287
|
}
|
|
288
|
+
|
|
235
289
|
const account = github.toLowerCase();
|
|
290
|
+
|
|
236
291
|
if (accounts.has(account)) {
|
|
237
292
|
return `"github" (${github}) is another contributor's too`;
|
|
238
293
|
}
|
|
294
|
+
|
|
239
295
|
accounts.add(account);
|
|
240
296
|
}
|
|
241
297
|
|
|
@@ -243,66 +299,97 @@ export function contributorProblems(contributors: unknown): string[] {
|
|
|
243
299
|
if (!Array.isArray(contributors)) {
|
|
244
300
|
return ["contributors.json must be an array"];
|
|
245
301
|
}
|
|
302
|
+
|
|
246
303
|
const problems: string[] = [];
|
|
247
304
|
const slugs = new Set<unknown>();
|
|
248
305
|
const accounts = new Set<string>();
|
|
249
|
-
|
|
306
|
+
|
|
307
|
+
// SAFETY: each field is checked before it is trusted, and an entry that is
|
|
308
|
+
// null or not an object reads as one with no fields.
|
|
309
|
+
for (const contributor of contributors as (
|
|
310
|
+
| UncheckedContributor
|
|
311
|
+
| null
|
|
312
|
+
| undefined
|
|
313
|
+
)[]) {
|
|
250
314
|
const label = contributor?.slug ?? "(no slug)";
|
|
315
|
+
|
|
251
316
|
if (!isSlug(contributor?.slug)) {
|
|
252
317
|
problems.push(`contributor ${label}: "slug" must be kebab-case`);
|
|
253
318
|
} else if (slugs.has(contributor.slug)) {
|
|
254
319
|
problems.push(`contributor ${label} is listed twice`);
|
|
255
320
|
}
|
|
321
|
+
|
|
256
322
|
slugs.add(contributor?.slug);
|
|
323
|
+
|
|
257
324
|
if (!isText(contributor?.name)) {
|
|
258
325
|
problems.push(`contributor ${label}: "name" is required`);
|
|
259
326
|
}
|
|
327
|
+
|
|
260
328
|
if (!isOneOf(DISCIPLINES, contributor?.discipline)) {
|
|
261
329
|
problems.push(
|
|
262
330
|
`contributor ${label}: "discipline" must be one of ${DISCIPLINES.join(", ")}`
|
|
263
331
|
);
|
|
264
332
|
}
|
|
333
|
+
|
|
265
334
|
const git = contributor?.git;
|
|
335
|
+
|
|
266
336
|
if (!(Array.isArray(git) && git.every(isText))) {
|
|
267
337
|
problems.push(
|
|
268
338
|
`contributor ${label}: "git" must be a list of git user names`
|
|
269
339
|
);
|
|
270
340
|
}
|
|
341
|
+
|
|
271
342
|
const github = githubProblem(contributor?.github, accounts);
|
|
343
|
+
|
|
272
344
|
if (github) {
|
|
273
345
|
problems.push(`contributor ${label}: ${github}`);
|
|
274
346
|
}
|
|
275
347
|
}
|
|
348
|
+
|
|
276
349
|
return problems;
|
|
277
350
|
}
|
|
278
351
|
|
|
279
352
|
export function manifestProblems(manifest: unknown): string[] {
|
|
280
|
-
|
|
353
|
+
// SAFETY: each field is checked before it is trusted, and a manifest that
|
|
354
|
+
// is null or not an object reads as one with no fields.
|
|
355
|
+
const fields = manifest as UncheckedManifest | null | undefined;
|
|
281
356
|
const problems: string[] = [];
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
}
|
|
357
|
+
|
|
358
|
+
if (!isText(fields?.title)) {
|
|
359
|
+
problems.push('"title" must be a non-empty string');
|
|
286
360
|
}
|
|
361
|
+
|
|
362
|
+
// The question the file answers, when there is one to put in it.
|
|
363
|
+
if (fields?.description !== undefined && !isText(fields.description)) {
|
|
364
|
+
problems.push('"description" must be a non-empty string when given');
|
|
365
|
+
}
|
|
366
|
+
|
|
287
367
|
if (!isOneOf(STATUSES, fields?.status)) {
|
|
288
368
|
problems.push(`"status" must be one of ${STATUSES.join(", ")}`);
|
|
289
369
|
}
|
|
370
|
+
|
|
290
371
|
// test() reads whatever it is given as a string.
|
|
291
372
|
if (!DATE_RE.test(String(fields?.created ?? ""))) {
|
|
292
373
|
problems.push('"created" must be a YYYY-MM-DD date');
|
|
293
374
|
}
|
|
375
|
+
|
|
294
376
|
const tags = fields?.tags;
|
|
377
|
+
|
|
295
378
|
if (tags !== undefined && !(Array.isArray(tags) && tags.every(isText))) {
|
|
296
379
|
problems.push('"tags" must be a list of strings');
|
|
297
380
|
}
|
|
381
|
+
|
|
298
382
|
if (fields?.cover !== undefined) {
|
|
299
383
|
const cover = checkFrameAnchor(fields.cover, "cover");
|
|
384
|
+
|
|
300
385
|
if ("problems" in cover) {
|
|
301
386
|
problems.push(...cover.problems);
|
|
302
387
|
}
|
|
303
388
|
}
|
|
389
|
+
|
|
304
390
|
return problems;
|
|
305
391
|
}
|
|
392
|
+
/* oxlint-enable anti-slop/no-unknown-parameters */
|
|
306
393
|
|
|
307
394
|
/** contributors.json is missing until Dex first starts there or someone joins. */
|
|
308
395
|
const readContributors = (path: string): Promise<Contributor[]> =>
|
|
@@ -312,14 +399,18 @@ export async function loadStudio(
|
|
|
312
399
|
root: string
|
|
313
400
|
): Promise<{ contributors: Contributor[]; root: string }> {
|
|
314
401
|
const contributors = await readContributors(join(root, "contributors.json"));
|
|
402
|
+
|
|
315
403
|
return { root, contributors };
|
|
316
404
|
}
|
|
317
405
|
|
|
318
406
|
/** The views and docs a prototype's canvas may point at. */
|
|
319
407
|
export async function knownFor(slug: string, root: string): Promise<Known> {
|
|
320
408
|
const paths = prototypePaths(root, slug);
|
|
409
|
+
|
|
410
|
+
const views = await viewFiles(root, slug);
|
|
411
|
+
|
|
321
412
|
return {
|
|
322
|
-
views: [...
|
|
413
|
+
views: [...views.keys()].toSorted(),
|
|
323
414
|
docs: await listFiles(paths.docs, DOC_FILE_RE),
|
|
324
415
|
};
|
|
325
416
|
}
|
|
@@ -334,35 +425,65 @@ export interface CheckReport {
|
|
|
334
425
|
async function prototypeIssues(
|
|
335
426
|
root: string,
|
|
336
427
|
{ slug, path, manifest, problem }: PrototypeFolder,
|
|
337
|
-
designSystem: ResolvedDesignSystem | undefined
|
|
428
|
+
designSystem: ResolvedDesignSystem | undefined,
|
|
429
|
+
layout: LayoutState
|
|
338
430
|
): Promise<CheckReport> {
|
|
339
431
|
// A bad name, or a manifest that is missing or cannot be read.
|
|
340
432
|
if (problem) {
|
|
341
433
|
return { problems: [`${path}: ${problem}`], warnings: [] };
|
|
342
434
|
}
|
|
435
|
+
|
|
343
436
|
// Where each part is on disk, and as the problems name it. prototypePaths
|
|
344
437
|
// has thrown for any name prototypeFiles refuses.
|
|
345
438
|
const paths = prototypePaths(root, slug);
|
|
439
|
+
// SAFETY: prototypePaths has thrown for any name prototypeFiles refuses.
|
|
346
440
|
const files = prototypeFiles(slug) as PrototypeFiles;
|
|
441
|
+
|
|
442
|
+
// The manifest the folder has, prototype.json in one from before.
|
|
443
|
+
const manifestPath =
|
|
444
|
+
paths.manifest === join(root, files.manifest)
|
|
445
|
+
? files.manifest
|
|
446
|
+
: files.legacyManifest;
|
|
447
|
+
|
|
347
448
|
const problems = manifestProblems(manifest).map(
|
|
348
|
-
(
|
|
449
|
+
(each) => `${manifestPath}: ${each}`
|
|
349
450
|
);
|
|
451
|
+
|
|
452
|
+
// Files whose own checks found a problem: the schema needn't say it too.
|
|
453
|
+
const quiet = new Set(problems.length > 0 ? [manifestPath] : []);
|
|
454
|
+
const warnings: string[] = [];
|
|
455
|
+
|
|
456
|
+
// An older studio is said once, of its .layout; a file left behind in a
|
|
457
|
+
// studio that is in this version is said of itself.
|
|
458
|
+
if (manifestPath === files.legacyManifest && layout === "known") {
|
|
459
|
+
warnings.push(
|
|
460
|
+
`${manifestPath}: the manifest's name before file.json; \`npx dex upgrade\` renames it.`
|
|
461
|
+
);
|
|
462
|
+
}
|
|
463
|
+
|
|
350
464
|
const { views, docs } = await knownFor(slug, root);
|
|
465
|
+
|
|
351
466
|
for (const [name, people] of await clashingViews(root, slug)) {
|
|
352
467
|
problems.push(
|
|
353
468
|
`${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.`
|
|
354
469
|
);
|
|
355
470
|
}
|
|
471
|
+
|
|
356
472
|
// A new file has no view until its first frame is drawn: that is no
|
|
357
473
|
// problem.
|
|
358
474
|
const copied: string[] = [];
|
|
475
|
+
|
|
359
476
|
for (const part of await canvasParts(slug, root)) {
|
|
477
|
+
const found = canvasProblems(part.canvas, { views, docs });
|
|
478
|
+
|
|
479
|
+
if (found.length > 0) {
|
|
480
|
+
quiet.add(shownIn(root, part.file));
|
|
481
|
+
}
|
|
482
|
+
|
|
360
483
|
problems.push(
|
|
361
|
-
...
|
|
362
|
-
...canvasProblems(part.canvas, { views, docs }),
|
|
363
|
-
...rowTitleProblems(part.canvas),
|
|
364
|
-
].map((problem) => `${shownIn(root, part.file)}: ${problem}`)
|
|
484
|
+
...found.map((each) => `${shownIn(root, part.file)}: ${each}`)
|
|
365
485
|
);
|
|
486
|
+
|
|
366
487
|
// The canvas still reads, at worst showing the row twice: only a warning.
|
|
367
488
|
for (const { section, row, author } of othersRowsIn(
|
|
368
489
|
part.canvas,
|
|
@@ -373,15 +494,28 @@ async function prototypeIssues(
|
|
|
373
494
|
);
|
|
374
495
|
}
|
|
375
496
|
}
|
|
497
|
+
|
|
376
498
|
// Picks never change what a prototype shows, so a broken file only warns.
|
|
377
|
-
const
|
|
499
|
+
const { problems: picks } = await readPrototypePicks(slug, root);
|
|
500
|
+
|
|
501
|
+
// Each line names its file first: "files/…/picks.json: …".
|
|
502
|
+
for (const line of picks) {
|
|
503
|
+
quiet.add(line.slice(0, line.indexOf(": ")));
|
|
504
|
+
}
|
|
505
|
+
|
|
378
506
|
const findings = await checkPrototype(root, paths.folder, designSystem);
|
|
379
507
|
problems.push(...errorLines(findings));
|
|
508
|
+
// Each path's place, and each file against the published schemas.
|
|
509
|
+
const format = await fileFolderFindings(root, paths.folder, quiet);
|
|
510
|
+
problems.push(...format.problems);
|
|
511
|
+
|
|
380
512
|
return {
|
|
381
513
|
problems,
|
|
382
514
|
warnings: [
|
|
515
|
+
...warnings,
|
|
516
|
+
...format.warnings,
|
|
383
517
|
...copied,
|
|
384
|
-
...
|
|
518
|
+
...picks,
|
|
385
519
|
...findings
|
|
386
520
|
.filter((finding) => finding.level === "warning")
|
|
387
521
|
.map(findingLine),
|
|
@@ -400,54 +534,103 @@ export async function checkStudio(
|
|
|
400
534
|
{ designSystem }: { designSystem?: ResolvedDesignSystem } = {}
|
|
401
535
|
): Promise<CheckReport> {
|
|
402
536
|
const { contributors } = await loadStudio(root);
|
|
537
|
+
const devices = await loadDevices(root);
|
|
538
|
+
|
|
403
539
|
const report: CheckReport = {
|
|
404
540
|
problems: contributorProblems(contributors).map(
|
|
405
541
|
(problem) => `contributors.json: ${problem}`
|
|
406
542
|
),
|
|
407
543
|
// The studio reads past them, so they are only warned of.
|
|
408
|
-
warnings:
|
|
544
|
+
warnings: devices.problems,
|
|
409
545
|
};
|
|
546
|
+
|
|
547
|
+
// files/ itself, the .layout's text and contributors.json, as published.
|
|
548
|
+
const studio = await studioFindings(root, {
|
|
549
|
+
quiet: report.problems.length > 0,
|
|
550
|
+
});
|
|
551
|
+
|
|
552
|
+
report.problems.push(...studio.problems);
|
|
553
|
+
report.warnings.push(...studio.warnings);
|
|
554
|
+
// Files newer than this Dex reads can't be checked by it; older ones are
|
|
555
|
+
// read all the same, and upgrade moves them on.
|
|
556
|
+
const layout = await studioLayout(root);
|
|
557
|
+
|
|
558
|
+
if (layout.state === "newer" && layout.message) {
|
|
559
|
+
report.problems.push(`${LAYOUT_FILE}: ${layout.message}`);
|
|
560
|
+
|
|
561
|
+
return report;
|
|
562
|
+
}
|
|
563
|
+
|
|
564
|
+
const unreadable = studio.problems.some((line) =>
|
|
565
|
+
line.startsWith(LAYOUT_FILE)
|
|
566
|
+
);
|
|
567
|
+
|
|
568
|
+
if (layout.state === "older" && layout.message && !unreadable) {
|
|
569
|
+
report.warnings.push(`${LAYOUT_FILE}: ${layout.message}`);
|
|
570
|
+
}
|
|
571
|
+
|
|
410
572
|
for (const folder of await walkPrototypes(root)) {
|
|
411
573
|
const { problems, warnings } = await prototypeIssues(
|
|
412
574
|
root,
|
|
413
575
|
folder,
|
|
414
|
-
designSystem
|
|
576
|
+
designSystem,
|
|
577
|
+
layout.state
|
|
415
578
|
);
|
|
579
|
+
|
|
416
580
|
report.problems.push(...problems);
|
|
417
581
|
report.warnings.push(
|
|
418
582
|
...warnings,
|
|
419
583
|
...(await twoVersionsIn(root, folder.folder))
|
|
420
584
|
);
|
|
421
585
|
}
|
|
586
|
+
|
|
422
587
|
return report;
|
|
423
588
|
}
|
|
424
589
|
|
|
425
|
-
|
|
590
|
+
/** Whether Dex's spec merge merges a path in a file's folder. */
|
|
591
|
+
const mergedBySpecs = (path: string): boolean =>
|
|
592
|
+
["spec", "doc"].includes(placeOf(path)?.part ?? "");
|
|
426
593
|
|
|
427
|
-
/**
|
|
594
|
+
/**
|
|
595
|
+
* Specs, notes, slides and docs in a prototype's folder still holding two
|
|
596
|
+
* versions to choose from.
|
|
597
|
+
*/
|
|
428
598
|
async function twoVersionsIn(root: string, folder: string): Promise<string[]> {
|
|
429
599
|
const names = await readdir(folder, { recursive: true }).catch(
|
|
430
|
-
()
|
|
600
|
+
(): string[] => []
|
|
431
601
|
);
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
);
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
602
|
+
|
|
603
|
+
const merged = names
|
|
604
|
+
.map((name) => name.split(sep).join("/"))
|
|
605
|
+
.filter(mergedBySpecs)
|
|
606
|
+
.toSorted();
|
|
607
|
+
|
|
608
|
+
const warnings = await Promise.all(
|
|
609
|
+
merged.map(async (name) => {
|
|
610
|
+
const file = join(folder, name);
|
|
611
|
+
const text = await readFile(file, "utf8").catch(() => "");
|
|
612
|
+
const pairs = text.split(TWO_VERSIONS_LEAD).length - 1;
|
|
613
|
+
|
|
614
|
+
return pairs > 0
|
|
615
|
+
? [
|
|
616
|
+
`${relative(root, file)}: ${pairs === 1 ? "a paragraph has" : `${pairs} paragraphs have`} two versions, written at the same time: keep one in the spec.`,
|
|
617
|
+
]
|
|
618
|
+
: [];
|
|
619
|
+
})
|
|
620
|
+
);
|
|
621
|
+
|
|
622
|
+
return warnings.flat();
|
|
444
623
|
}
|
|
445
624
|
|
|
446
625
|
/** Every problem in the studio (checkStudio's), without the warnings. */
|
|
447
626
|
export const check = async (
|
|
448
627
|
root: string,
|
|
449
628
|
options: { designSystem?: ResolvedDesignSystem } = {}
|
|
450
|
-
): Promise<string[]> =>
|
|
629
|
+
): Promise<string[]> => {
|
|
630
|
+
const { problems } = await checkStudio(root, options);
|
|
631
|
+
|
|
632
|
+
return problems;
|
|
633
|
+
};
|
|
451
634
|
|
|
452
635
|
// --- Saving the canvas --------------------------------------------------------
|
|
453
636
|
//
|
|
@@ -464,9 +647,11 @@ interface CanvasPart {
|
|
|
464
647
|
}
|
|
465
648
|
|
|
466
649
|
/**
|
|
467
|
-
* Each person's canvas.json in a prototype
|
|
468
|
-
*
|
|
469
|
-
*
|
|
650
|
+
* Each person's canvas.json in a prototype, as this Dex reads it: with the
|
|
651
|
+
* piles a development Dex marked made stacks (stackPiles), which their next
|
|
652
|
+
* save writes. A canvas.json beside the manifest, from before people/, is
|
|
653
|
+
* not read: `dex upgrade` moves it into its person's folder
|
|
654
|
+
* (people-folders.ts).
|
|
470
655
|
*/
|
|
471
656
|
export async function canvasParts(
|
|
472
657
|
slug: string,
|
|
@@ -474,12 +659,16 @@ export async function canvasParts(
|
|
|
474
659
|
): Promise<CanvasPart[]> {
|
|
475
660
|
const paths = prototypePaths(root, slug);
|
|
476
661
|
const parts: CanvasPart[] = [];
|
|
662
|
+
|
|
477
663
|
for (const person of await peopleOf(root, slug)) {
|
|
478
664
|
const file = paths.person(person)?.canvas;
|
|
665
|
+
|
|
479
666
|
if (file && existsSync(file)) {
|
|
480
|
-
|
|
667
|
+
const canvas = stackPiles(await readJson<Canvas>(file));
|
|
668
|
+
parts.push({ person, file, canvas });
|
|
481
669
|
}
|
|
482
670
|
}
|
|
671
|
+
|
|
483
672
|
return parts;
|
|
484
673
|
}
|
|
485
674
|
|
|
@@ -491,9 +680,11 @@ export async function canvasParts(
|
|
|
491
680
|
*/
|
|
492
681
|
const revisionOf = (parts: CanvasPart[], person: string) => {
|
|
493
682
|
const part = parts.find((each) => each.person === person);
|
|
683
|
+
|
|
494
684
|
const hash = part
|
|
495
685
|
? createHash("sha1").update(JSON.stringify(part.canvas)).digest("hex")
|
|
496
686
|
: "";
|
|
687
|
+
|
|
497
688
|
return `${person}:${hash}`;
|
|
498
689
|
};
|
|
499
690
|
|
|
@@ -504,6 +695,7 @@ export async function readCanvasRevision(
|
|
|
504
695
|
root: string
|
|
505
696
|
): Promise<CanvasRevision> {
|
|
506
697
|
const parts = await canvasParts(slug, root);
|
|
698
|
+
|
|
507
699
|
return {
|
|
508
700
|
canvas: combineCanvases(parts),
|
|
509
701
|
person,
|
|
@@ -521,6 +713,7 @@ export async function readCanvas(slug: string, root: string): Promise<Canvas> {
|
|
|
521
713
|
|
|
522
714
|
// A save formats with Biome, which may take its whole timeout.
|
|
523
715
|
const CANVAS_LOCK_STALE_MS = 15_000;
|
|
716
|
+
|
|
524
717
|
/** Run `work` in turn with a prototype's canvas saves (trash.ts too). */
|
|
525
718
|
export const queued = <T>(
|
|
526
719
|
root: string,
|
|
@@ -576,38 +769,53 @@ const rowBefore = <R extends { id: string }>(
|
|
|
576
769
|
above?: string
|
|
577
770
|
): R | undefined => {
|
|
578
771
|
const at = rows.findIndex((row) => row.id === above);
|
|
579
|
-
|
|
772
|
+
|
|
773
|
+
return at === -1 ? rows.at(-1) : rows[Math.max(0, at - 1)];
|
|
580
774
|
};
|
|
581
775
|
|
|
776
|
+
/** A canvas and a cell on it. */
|
|
777
|
+
export interface CanvasCell<C extends Omit<Cell, "step"> = Cell> {
|
|
778
|
+
canvas: Canvas;
|
|
779
|
+
cell: C;
|
|
780
|
+
}
|
|
781
|
+
|
|
582
782
|
/**
|
|
583
783
|
* A cell the person may add to: theirs, or, in someone else's row, the same
|
|
584
784
|
* step of the person's own row right below it (ownRow; a new one with
|
|
585
785
|
* `newRow`). A new row in someone else's section goes where the cell asks
|
|
586
786
|
* (rowBefore): in the person's own row there, or one right below theirs.
|
|
587
787
|
*/
|
|
588
|
-
export function ownCell(
|
|
788
|
+
export function ownCell<C extends Omit<Cell, "step">>(
|
|
589
789
|
canvas: Canvas,
|
|
590
|
-
cell:
|
|
790
|
+
cell: C,
|
|
591
791
|
person: string,
|
|
592
792
|
{ newRow = false }: { newRow?: boolean } = {}
|
|
593
|
-
):
|
|
793
|
+
): CanvasCell<C> {
|
|
594
794
|
const section = canvas.sections.find((entry) => entry.id === cell.section);
|
|
595
795
|
const row = section?.rows.find((entry) => entry.id === cell.row);
|
|
796
|
+
|
|
596
797
|
const theirs = row
|
|
597
798
|
? section && isOthersRow(section, row, person)
|
|
598
799
|
: section && isOthers(section, person);
|
|
800
|
+
|
|
599
801
|
if (!(section && theirs)) {
|
|
600
802
|
return { canvas, cell };
|
|
601
803
|
}
|
|
804
|
+
|
|
602
805
|
const anchor = row ?? rowBefore(section.rows, cell.above);
|
|
806
|
+
|
|
603
807
|
// A new row's place is the person's own row already: it goes in that.
|
|
604
808
|
if (!row && anchor && !isOthersRow(section, anchor, person)) {
|
|
605
809
|
return { canvas, cell: { ...cell, row: anchor.id } };
|
|
606
810
|
}
|
|
811
|
+
|
|
607
812
|
const own = ownRow(section, anchor?.id ?? "main", person, { newRow });
|
|
813
|
+
|
|
608
814
|
return {
|
|
609
815
|
canvas: {
|
|
610
816
|
sections: canvas.sections.map((entry) =>
|
|
817
|
+
// SAFETY: ownRow gives back the section it was given, a Section,
|
|
818
|
+
// with its rows changed.
|
|
611
819
|
entry === section ? (own.section as Section) : entry
|
|
612
820
|
),
|
|
613
821
|
},
|
|
@@ -615,23 +823,90 @@ export function ownCell(
|
|
|
615
823
|
};
|
|
616
824
|
}
|
|
617
825
|
|
|
826
|
+
/**
|
|
827
|
+
* The key a frame is at now, found by its uid first, then its key
|
|
828
|
+
* (targetFrameKey); none when no one frame has it.
|
|
829
|
+
*/
|
|
830
|
+
export const frameKeyOn = (
|
|
831
|
+
canvas: Canvas,
|
|
832
|
+
target: { frame: string; uid?: string }
|
|
833
|
+
): string | undefined =>
|
|
834
|
+
targetFrameKey(
|
|
835
|
+
target,
|
|
836
|
+
canvasFrames(canvas).map(({ key, frame }) => ({ key, uid: frame.uid }))
|
|
837
|
+
);
|
|
838
|
+
|
|
839
|
+
/** The cell a frame is in now (frameKeyOn); none when it is gone. */
|
|
840
|
+
export function cellOfFrame(
|
|
841
|
+
canvas: Canvas,
|
|
842
|
+
target: { frame: string; uid?: string }
|
|
843
|
+
): Cell | undefined {
|
|
844
|
+
const key = frameKeyOn(canvas, target);
|
|
845
|
+
const where = key === undefined ? undefined : whereInRow(canvas, key);
|
|
846
|
+
|
|
847
|
+
if (!(key && where)) {
|
|
848
|
+
return;
|
|
849
|
+
}
|
|
850
|
+
|
|
851
|
+
const { section, row } = parseFrameKey(key);
|
|
852
|
+
|
|
853
|
+
return { section, row, step: where.step };
|
|
854
|
+
}
|
|
855
|
+
|
|
856
|
+
/**
|
|
857
|
+
* The cell asked for, before the person's own row is found: right of the
|
|
858
|
+
* frame `rightOf` names (its uid or key), where it is now; or, with no row,
|
|
859
|
+
* step or `above`, at the end of the section's first row, its main path.
|
|
860
|
+
*/
|
|
861
|
+
function cellWanted(
|
|
862
|
+
canvas: Canvas,
|
|
863
|
+
asked: AskedCell | { rightOf: string }
|
|
864
|
+
): AskedCell | { problem: string } {
|
|
865
|
+
if ("rightOf" in asked) {
|
|
866
|
+
const { rightOf } = asked;
|
|
867
|
+
const frame = cellOfFrame(canvas, { frame: rightOf, uid: rightOf });
|
|
868
|
+
|
|
869
|
+
if (!frame) {
|
|
870
|
+
return {
|
|
871
|
+
problem: `No frame "${rightOf}" on the canvas, or more than one with that uid. Name it by its key ("section/row/frame") as canvas.json has it now.`,
|
|
872
|
+
};
|
|
873
|
+
}
|
|
874
|
+
|
|
875
|
+
return { section: frame.section, row: frame.row, after: frame.step };
|
|
876
|
+
}
|
|
877
|
+
|
|
878
|
+
const { above, row, step } = asked;
|
|
879
|
+
|
|
880
|
+
if (row !== undefined || step !== undefined || above !== undefined) {
|
|
881
|
+
return asked;
|
|
882
|
+
}
|
|
883
|
+
|
|
884
|
+
const main = canvas.sections.find((each) => each.id === asked.section)
|
|
885
|
+
?.rows[0];
|
|
886
|
+
|
|
887
|
+
return main ? { ...asked, row: main.id } : asked;
|
|
888
|
+
}
|
|
889
|
+
|
|
618
890
|
/**
|
|
619
891
|
* Put a frame for a view in a cell of a prototype's canvas (placeViewInCell),
|
|
620
892
|
* reading and writing canvas.json in one turn, so agents placing frames at
|
|
621
|
-
* once never lose each other's
|
|
622
|
-
*
|
|
893
|
+
* once never lose each other's, and a frame asked for right of another
|
|
894
|
+
* (`rightOf`) or with no step (stepAsked) is placed by the canvas as it is
|
|
895
|
+
* then. A frame for the view already in the cell is kept. Returns its key,
|
|
896
|
+
* its uid and whether it was added, or { problems }.
|
|
623
897
|
*/
|
|
624
898
|
export function placeViewFrame(
|
|
625
899
|
{
|
|
626
900
|
slug,
|
|
627
|
-
cell,
|
|
901
|
+
cell: asked,
|
|
628
902
|
view,
|
|
629
903
|
viewport,
|
|
630
904
|
size,
|
|
631
905
|
person,
|
|
632
906
|
newRow,
|
|
907
|
+
stack,
|
|
633
908
|
}: {
|
|
634
|
-
cell:
|
|
909
|
+
cell: AskedCell | { rightOf: string };
|
|
635
910
|
/**
|
|
636
911
|
* In someone else's row, put it in a new row of the person's right
|
|
637
912
|
* below it, not the one they have there.
|
|
@@ -642,6 +917,8 @@ export function placeViewFrame(
|
|
|
642
917
|
/** The size asked for it: a request's, set on the canvas. */
|
|
643
918
|
size?: PageSize;
|
|
644
919
|
slug: string;
|
|
920
|
+
/** On top of the stack in the cell, rather than a column of its own. */
|
|
921
|
+
stack?: boolean;
|
|
645
922
|
view: string;
|
|
646
923
|
viewport?: Viewport;
|
|
647
924
|
},
|
|
@@ -652,24 +929,34 @@ export function placeViewFrame(
|
|
|
652
929
|
> {
|
|
653
930
|
return queued(root, slug, async () => {
|
|
654
931
|
const saver = person;
|
|
655
|
-
const
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
{
|
|
660
|
-
|
|
932
|
+
const read = await readCanvas(slug, root);
|
|
933
|
+
const wanted = cellWanted(read, asked);
|
|
934
|
+
|
|
935
|
+
if ("problem" in wanted) {
|
|
936
|
+
return { problems: [wanted.problem] };
|
|
937
|
+
}
|
|
938
|
+
|
|
939
|
+
const { canvas, cell: own } = ownCell(read, wanted, saver, { newRow });
|
|
940
|
+
// Moved into the person's own row: not left of the end of the one asked.
|
|
941
|
+
const past = own.row === wanted.row ? undefined : wanted.row;
|
|
942
|
+
const cell = { ...own, step: stepAsked(canvas, own, view, past) };
|
|
661
943
|
const { devices } = await loadDevices(root);
|
|
662
|
-
|
|
944
|
+
|
|
945
|
+
const placed = placeViewInCell(canvas, cell, {
|
|
663
946
|
view,
|
|
664
947
|
viewport,
|
|
665
948
|
size,
|
|
949
|
+
stack,
|
|
666
950
|
fallback: defaultDevice(devices),
|
|
667
951
|
});
|
|
952
|
+
|
|
668
953
|
if ("problem" in placed) {
|
|
669
954
|
return { problems: [placed.problem] };
|
|
670
955
|
}
|
|
956
|
+
|
|
671
957
|
const uidAt = (on: Canvas | undefined) =>
|
|
672
958
|
canvasFrames(on).find((entry) => entry.key === placed.key)?.frame.uid;
|
|
959
|
+
|
|
673
960
|
if (!placed.added) {
|
|
674
961
|
return {
|
|
675
962
|
key: placed.key,
|
|
@@ -678,13 +965,16 @@ export function placeViewFrame(
|
|
|
678
965
|
uid: uidAt(canvas),
|
|
679
966
|
};
|
|
680
967
|
}
|
|
968
|
+
|
|
681
969
|
const saved = await saveCanvasNow(
|
|
682
970
|
{ slug, canvas: placed.canvas, person: saver },
|
|
683
971
|
root
|
|
684
972
|
);
|
|
973
|
+
|
|
685
974
|
if (saved.problems) {
|
|
686
975
|
return { problems: saved.problems };
|
|
687
976
|
}
|
|
977
|
+
|
|
688
978
|
return {
|
|
689
979
|
key: placed.key,
|
|
690
980
|
added: true,
|
|
@@ -694,6 +984,13 @@ export function placeViewFrame(
|
|
|
694
984
|
});
|
|
695
985
|
}
|
|
696
986
|
|
|
987
|
+
/** A save's canvas and files, its views renamed where they clash. */
|
|
988
|
+
interface FreedNames {
|
|
989
|
+
canvas: Canvas;
|
|
990
|
+
stylesheets: Record<string, string>;
|
|
991
|
+
views: Record<string, string>;
|
|
992
|
+
}
|
|
993
|
+
|
|
697
994
|
/**
|
|
698
995
|
* New views by names someone else's views already have, renamed to the next
|
|
699
996
|
* free name, with the frames in the person's own sections that show them.
|
|
@@ -703,13 +1000,10 @@ function freeViewNames(
|
|
|
703
1000
|
{ views = {}, stylesheets = {} }: CanvasSave,
|
|
704
1001
|
existing: Map<string, ViewFile>,
|
|
705
1002
|
person: string
|
|
706
|
-
): {
|
|
707
|
-
canvas: Canvas;
|
|
708
|
-
stylesheets: Record<string, string>;
|
|
709
|
-
views: Record<string, string>;
|
|
710
|
-
} {
|
|
1003
|
+
): FreedNames {
|
|
711
1004
|
const taken = new Set([...existing.keys(), ...Object.keys(views)]);
|
|
712
1005
|
const renamed = new Map<string, string>();
|
|
1006
|
+
|
|
713
1007
|
for (const name of Object.keys(views)) {
|
|
714
1008
|
if ((existing.get(name)?.person ?? person) !== person) {
|
|
715
1009
|
const free = uniqueId(name, taken);
|
|
@@ -717,14 +1011,18 @@ function freeViewNames(
|
|
|
717
1011
|
renamed.set(name, free);
|
|
718
1012
|
}
|
|
719
1013
|
}
|
|
1014
|
+
|
|
720
1015
|
if (renamed.size === 0) {
|
|
721
1016
|
return { canvas, views, stylesheets };
|
|
722
1017
|
}
|
|
1018
|
+
|
|
723
1019
|
const to = (name: string) => renamed.get(name) ?? name;
|
|
1020
|
+
|
|
724
1021
|
const rename = (files: Record<string, string>) =>
|
|
725
1022
|
Object.fromEntries(
|
|
726
1023
|
Object.entries(files).map(([name, text]) => [to(name), text])
|
|
727
1024
|
);
|
|
1025
|
+
|
|
728
1026
|
return {
|
|
729
1027
|
views: rename(views),
|
|
730
1028
|
stylesheets: rename(stylesheets),
|
|
@@ -738,6 +1036,7 @@ function freeViewNames(
|
|
|
738
1036
|
...row,
|
|
739
1037
|
frames: row.frames.map((frame) => {
|
|
740
1038
|
const view = viewOf(frame);
|
|
1039
|
+
|
|
741
1040
|
return view ? { ...view, view: to(view.view) } : frame;
|
|
742
1041
|
}),
|
|
743
1042
|
}
|
|
@@ -756,18 +1055,23 @@ async function saveCanvasNow(
|
|
|
756
1055
|
const paths = prototypePaths(root, slug);
|
|
757
1056
|
const { person } = save;
|
|
758
1057
|
const own = paths.person(person);
|
|
1058
|
+
|
|
759
1059
|
if (!own) {
|
|
760
1060
|
return { problems: [`"${person}" is not a contributor's slug.`] };
|
|
761
1061
|
}
|
|
1062
|
+
|
|
762
1063
|
const parts = await canvasParts(slug, root);
|
|
1064
|
+
|
|
763
1065
|
if (
|
|
764
1066
|
save.revision !== undefined &&
|
|
765
1067
|
save.revision !== revisionOf(parts, person)
|
|
766
1068
|
) {
|
|
767
1069
|
return { stale: true };
|
|
768
1070
|
}
|
|
1071
|
+
|
|
769
1072
|
const existing = await viewFiles(root, slug);
|
|
770
1073
|
const onDisk = combineCanvases(parts);
|
|
1074
|
+
|
|
771
1075
|
// Whose each row is, from disk only: by its own author, else its
|
|
772
1076
|
// section's. What the body claims is not asked, and a row that is not on
|
|
773
1077
|
// disk yet is the saver's.
|
|
@@ -779,14 +1083,20 @@ async function saveCanvasNow(
|
|
|
779
1083
|
])
|
|
780
1084
|
)
|
|
781
1085
|
);
|
|
782
|
-
|
|
1086
|
+
|
|
1087
|
+
const malformed = canvasFormProblems(save.canvas, (section, row) => {
|
|
783
1088
|
const owner = owners.get(`${section.id}/${row.id}`);
|
|
1089
|
+
|
|
784
1090
|
return owner !== undefined && owner !== person;
|
|
785
1091
|
});
|
|
1092
|
+
|
|
786
1093
|
if (malformed.length > 0) {
|
|
787
1094
|
return { problems: malformed };
|
|
788
1095
|
}
|
|
1096
|
+
|
|
1097
|
+
// SAFETY: canvasFormProblems found nothing wrong with it, so it is a Canvas.
|
|
789
1098
|
const sent = (save.canvas as Canvas).sections;
|
|
1099
|
+
|
|
790
1100
|
const labelled: Canvas = {
|
|
791
1101
|
sections: labelAuthors(
|
|
792
1102
|
sent,
|
|
@@ -795,12 +1105,15 @@ async function saveCanvasNow(
|
|
|
795
1105
|
save.revision !== undefined
|
|
796
1106
|
),
|
|
797
1107
|
};
|
|
1108
|
+
|
|
798
1109
|
const renamed = Object.fromEntries(
|
|
799
1110
|
sent.flatMap((section, index) => {
|
|
800
1111
|
const id = labelled.sections[index]?.id;
|
|
1112
|
+
|
|
801
1113
|
return id === undefined || id === section.id ? [] : [[section.id, id]];
|
|
802
1114
|
})
|
|
803
1115
|
);
|
|
1116
|
+
|
|
804
1117
|
// Nobody picks names: a new view by a name someone else has takes the
|
|
805
1118
|
// next free one, and the person's frames follow it.
|
|
806
1119
|
const {
|
|
@@ -808,75 +1121,97 @@ async function saveCanvasNow(
|
|
|
808
1121
|
views,
|
|
809
1122
|
stylesheets,
|
|
810
1123
|
} = freeViewNames(labelled, save, existing, person);
|
|
1124
|
+
|
|
811
1125
|
// A change to someone else's section goes into a copy of it that is the
|
|
812
1126
|
// saver's; then only the saver's sections are written, without others'
|
|
813
1127
|
// rows, and everyone else's stay as their files have them.
|
|
814
1128
|
const now = new Date().toISOString();
|
|
1129
|
+
|
|
815
1130
|
const lifted = liftRows(
|
|
816
1131
|
savedPart(onDisk, named, person, {
|
|
817
1132
|
onRevision: save.revision !== undefined,
|
|
818
1133
|
}),
|
|
819
1134
|
person
|
|
820
1135
|
);
|
|
821
|
-
|
|
822
|
-
//
|
|
823
|
-
//
|
|
1136
|
+
|
|
1137
|
+
// Uids keep a frame the same frame when it moves, so picks and comments
|
|
1138
|
+
// follow it: each save gives the saver's frames theirs, and marks the file
|
|
1139
|
+
// as having given them.
|
|
824
1140
|
const given =
|
|
825
1141
|
parts.find((part) => part.person === person)?.canvas.frameUids === true;
|
|
826
|
-
|
|
1142
|
+
|
|
827
1143
|
const sections = ownSections(
|
|
828
|
-
|
|
1144
|
+
withFrameUids(lifted, person, { given, previous: onDisk }),
|
|
829
1145
|
person,
|
|
830
1146
|
now
|
|
831
1147
|
);
|
|
832
|
-
|
|
833
|
-
|
|
1148
|
+
|
|
1149
|
+
const mine: Canvas = { frameUids: true, ...sections };
|
|
834
1150
|
// A teammate's frame, such as one made in a newer Dex, never stops
|
|
835
1151
|
// anyone else saving.
|
|
836
1152
|
const known = await knownFor(slug, root);
|
|
1153
|
+
|
|
837
1154
|
const problems = canvasProblems(mine, {
|
|
838
1155
|
...known,
|
|
839
1156
|
views: [...known.views, ...Object.keys(views)],
|
|
840
1157
|
});
|
|
1158
|
+
|
|
841
1159
|
if (problems.length > 0) {
|
|
842
1160
|
return { problems };
|
|
843
1161
|
}
|
|
1162
|
+
|
|
844
1163
|
const images = save.images ?? {};
|
|
1164
|
+
|
|
845
1165
|
// What the save takes off their canvas, so a removed view can say where it was.
|
|
846
|
-
const
|
|
847
|
-
|
|
848
|
-
|
|
1166
|
+
const current = await canvasParts(slug, root);
|
|
1167
|
+
const before = current.find((part) => part.person === person)?.canvas;
|
|
1168
|
+
|
|
849
1169
|
const removed = nextRemovals(
|
|
850
1170
|
before?.sections ?? [],
|
|
851
1171
|
mine.sections,
|
|
852
1172
|
removalsOf(before),
|
|
853
1173
|
{ by: person, now }
|
|
854
1174
|
);
|
|
1175
|
+
|
|
855
1176
|
const file = own.canvas;
|
|
856
1177
|
const biome = findBiome(root);
|
|
1178
|
+
|
|
857
1179
|
const text: string = await formatText(
|
|
858
1180
|
biome,
|
|
859
1181
|
file,
|
|
860
|
-
|
|
1182
|
+
jsonInLayout(
|
|
1183
|
+
// What a newer Dex wrote that this one doesn't know stays as it was.
|
|
1184
|
+
withUnknownFields(
|
|
1185
|
+
before,
|
|
1186
|
+
removed.length > 0 ? { ...mine, removed } : mine
|
|
1187
|
+
),
|
|
1188
|
+
await readFile(file, "utf8").catch(() => undefined)
|
|
1189
|
+
)
|
|
861
1190
|
);
|
|
1191
|
+
|
|
862
1192
|
// Parsed before anything is written, so a bad format never lands on disk.
|
|
863
1193
|
JSON.parse(text);
|
|
864
1194
|
// The views first, so the canvas never points at a view not yet there,
|
|
865
1195
|
// and each view's images and stylesheet before the view that imports them.
|
|
866
1196
|
const pictures = Object.entries(images);
|
|
1197
|
+
|
|
867
1198
|
if (pictures.length > 0) {
|
|
868
1199
|
await mkdir(paths.images, { recursive: true });
|
|
869
1200
|
}
|
|
870
|
-
|
|
871
|
-
|
|
1201
|
+
|
|
1202
|
+
for (const [name, bytes] of pictures) {
|
|
1203
|
+
await writeFile(paths.image(name), bytes);
|
|
872
1204
|
}
|
|
1205
|
+
|
|
873
1206
|
// A view saved again stays where it is; a new one goes in their views/.
|
|
874
1207
|
const viewFile = (name: string, extension = ".tsx") => {
|
|
875
1208
|
const found = existing.get(name)?.file;
|
|
1209
|
+
|
|
876
1210
|
return found
|
|
877
1211
|
? `${found.slice(0, -".tsx".length)}${extension}`
|
|
878
1212
|
: own.view(name, extension);
|
|
879
1213
|
};
|
|
1214
|
+
|
|
880
1215
|
const unformatted = [
|
|
881
1216
|
...Object.entries(stylesheets).map(([name, css]) => [
|
|
882
1217
|
viewFile(name, ".css"),
|
|
@@ -884,9 +1219,11 @@ async function saveCanvasNow(
|
|
|
884
1219
|
]),
|
|
885
1220
|
...Object.entries(views).map(([name, source]) => [viewFile(name), source]),
|
|
886
1221
|
];
|
|
1222
|
+
|
|
887
1223
|
if (unformatted.length > 0) {
|
|
888
1224
|
await mkdir(own.views, { recursive: true });
|
|
889
1225
|
}
|
|
1226
|
+
|
|
890
1227
|
// Written formatted: a rewrite of a view no page has loaded yet makes Vite
|
|
891
1228
|
// reload every page, the canvas and all its frames.
|
|
892
1229
|
const files = await Promise.all(
|
|
@@ -895,11 +1232,14 @@ async function saveCanvasNow(
|
|
|
895
1232
|
await formatText(biome, path, source),
|
|
896
1233
|
])
|
|
897
1234
|
);
|
|
1235
|
+
|
|
898
1236
|
for (const [path, contents] of files) {
|
|
899
1237
|
await writeFile(path, contents);
|
|
900
1238
|
}
|
|
1239
|
+
|
|
901
1240
|
await mkdir(own.folder, { recursive: true });
|
|
902
1241
|
await replaceFile(file, text);
|
|
1242
|
+
|
|
903
1243
|
return {
|
|
904
1244
|
...(await readCanvasRevision(slug, person, root)),
|
|
905
1245
|
renamed,
|
|
@@ -907,76 +1247,95 @@ async function saveCanvasNow(
|
|
|
907
1247
|
};
|
|
908
1248
|
}
|
|
909
1249
|
|
|
910
|
-
// ---
|
|
1250
|
+
// --- Picks --------------------------------------------------------------------
|
|
911
1251
|
|
|
912
|
-
/** Everyone's
|
|
913
|
-
export interface
|
|
914
|
-
|
|
1252
|
+
/** Everyone's picks on a prototype, each with its author. */
|
|
1253
|
+
export interface PrototypePicks {
|
|
1254
|
+
picks: Authored[];
|
|
915
1255
|
/** What is wrong with each file, by its path in the studio. */
|
|
916
1256
|
problems: string[];
|
|
917
1257
|
}
|
|
918
1258
|
|
|
919
|
-
export type
|
|
920
|
-
| {
|
|
921
|
-
| {
|
|
1259
|
+
export type SavedPicks =
|
|
1260
|
+
| { picks: Authored[]; problems?: undefined }
|
|
1261
|
+
| { picks?: undefined; problems: string[] };
|
|
1262
|
+
|
|
1263
|
+
const PICKS_LOCK_STALE_MS = 5000;
|
|
1264
|
+
const NOT_PICKS = 'must be { "picks": [...] }.';
|
|
922
1265
|
|
|
923
|
-
|
|
924
|
-
|
|
1266
|
+
// 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
|
|
1267
|
+
type PicksJson = Record<string, unknown>;
|
|
925
1268
|
|
|
926
|
-
async function
|
|
1269
|
+
async function picksFile(
|
|
927
1270
|
file: string
|
|
928
|
-
): Promise<{ file?:
|
|
1271
|
+
): Promise<{ file?: PicksJson } | { problem: string }> {
|
|
929
1272
|
let text: string;
|
|
1273
|
+
|
|
930
1274
|
try {
|
|
931
1275
|
text = await readFile(file, "utf8");
|
|
932
1276
|
} catch (error) {
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
|
|
1277
|
+
// SAFETY: readFile fails with a Node system error, an Error with a code.
|
|
1278
|
+
const { code, message } = error as NodeJS.ErrnoException;
|
|
1279
|
+
|
|
1280
|
+
return code === "ENOENT" ? {} : { problem: message };
|
|
936
1281
|
}
|
|
1282
|
+
|
|
937
1283
|
try {
|
|
938
1284
|
const parsed: unknown = JSON.parse(text);
|
|
939
|
-
|
|
1285
|
+
|
|
1286
|
+
return isRecord(parsed) && Array.isArray(parsed.picks)
|
|
940
1287
|
? { file: parsed }
|
|
941
|
-
: { problem:
|
|
1288
|
+
: { problem: NOT_PICKS };
|
|
942
1289
|
} catch (error) {
|
|
1290
|
+
// SAFETY: JSON.parse fails with a SyntaxError.
|
|
943
1291
|
return { problem: (error as Error).message };
|
|
944
1292
|
}
|
|
945
1293
|
}
|
|
946
1294
|
|
|
947
1295
|
/**
|
|
948
|
-
* Every person's
|
|
949
|
-
*
|
|
950
|
-
*
|
|
951
|
-
* older Dex wrote, are left in the file and not read.
|
|
1296
|
+
* Every person's picks on a prototype, by person, each with its author. A
|
|
1297
|
+
* file that cannot be read gives problems, never an error, so one person's
|
|
1298
|
+
* broken file hides only their picks.
|
|
952
1299
|
*/
|
|
953
|
-
export async function
|
|
1300
|
+
export async function readPrototypePicks(
|
|
954
1301
|
slug: string,
|
|
955
1302
|
root: string
|
|
956
|
-
): Promise<
|
|
1303
|
+
): Promise<PrototypePicks> {
|
|
957
1304
|
const paths = prototypePaths(root, slug);
|
|
958
|
-
const read:
|
|
959
|
-
|
|
960
|
-
|
|
961
|
-
|
|
962
|
-
|
|
963
|
-
|
|
964
|
-
|
|
1305
|
+
const read: PrototypePicks = { picks: [], problems: [] };
|
|
1306
|
+
|
|
1307
|
+
const people = await peopleOf(root, slug);
|
|
1308
|
+
|
|
1309
|
+
const files = people.flatMap((person) => {
|
|
1310
|
+
const file = paths.person(person)?.picks;
|
|
1311
|
+
|
|
1312
|
+
return file ? [{ file, person }] : [];
|
|
1313
|
+
});
|
|
1314
|
+
|
|
1315
|
+
const opened = await Promise.all(
|
|
1316
|
+
files.map(async (each) => ({
|
|
1317
|
+
...each,
|
|
1318
|
+
found: await picksFile(each.file),
|
|
1319
|
+
}))
|
|
1320
|
+
);
|
|
1321
|
+
|
|
1322
|
+
for (const { file, found, person } of opened) {
|
|
965
1323
|
if ("problem" in found) {
|
|
966
1324
|
read.problems.push(`${shownIn(root, file)}: ${found.problem}`);
|
|
967
1325
|
continue;
|
|
968
1326
|
}
|
|
1327
|
+
|
|
969
1328
|
if (!found.file) {
|
|
970
1329
|
continue;
|
|
971
1330
|
}
|
|
972
|
-
|
|
973
|
-
|
|
974
|
-
|
|
975
|
-
);
|
|
1331
|
+
|
|
1332
|
+
const { picks, problems } = readPicks(found.file);
|
|
1333
|
+
read.picks.push(...picks.map((pick) => ({ ...pick, author: person })));
|
|
976
1334
|
read.problems.push(
|
|
977
1335
|
...problems.map((problem) => `${shownIn(root, file)}: ${problem}`)
|
|
978
1336
|
);
|
|
979
1337
|
}
|
|
1338
|
+
|
|
980
1339
|
return read;
|
|
981
1340
|
}
|
|
982
1341
|
|
|
@@ -986,73 +1345,87 @@ interface PicksOf {
|
|
|
986
1345
|
slug: string;
|
|
987
1346
|
}
|
|
988
1347
|
|
|
989
|
-
async function
|
|
1348
|
+
async function changePicks(
|
|
990
1349
|
{ slug, person }: PicksOf,
|
|
991
1350
|
change: (
|
|
992
|
-
file:
|
|
993
|
-
) => {
|
|
1351
|
+
file: PicksJson | undefined
|
|
1352
|
+
) => { picks: unknown[] } | { problems: string[] },
|
|
994
1353
|
root: string
|
|
995
|
-
): Promise<
|
|
1354
|
+
): Promise<SavedPicks> {
|
|
996
1355
|
if (person === undefined) {
|
|
997
|
-
return
|
|
1356
|
+
return { problems: [NOT_RECOGNISED] };
|
|
998
1357
|
}
|
|
1358
|
+
|
|
999
1359
|
const own = prototypePaths(root, slug).person(person);
|
|
1360
|
+
|
|
1000
1361
|
if (!own) {
|
|
1001
|
-
return
|
|
1362
|
+
return {
|
|
1002
1363
|
problems: [`"${person}" is not a contributor's slug.`],
|
|
1003
|
-
}
|
|
1364
|
+
};
|
|
1004
1365
|
}
|
|
1366
|
+
|
|
1005
1367
|
const written = await inTurn(
|
|
1006
1368
|
root,
|
|
1007
|
-
`
|
|
1008
|
-
|
|
1369
|
+
`picks-${slug}-${person}`,
|
|
1370
|
+
PICKS_LOCK_STALE_MS,
|
|
1009
1371
|
async (): Promise<{ problems: string[] } | undefined> => {
|
|
1010
|
-
const found = await
|
|
1372
|
+
const found = await picksFile(own.picks);
|
|
1373
|
+
|
|
1011
1374
|
if ("problem" in found) {
|
|
1012
1375
|
return {
|
|
1013
1376
|
problems: [
|
|
1014
|
-
`${shownIn(root, own.
|
|
1377
|
+
`${shownIn(root, own.picks)}: ${found.problem} Fix it or remove it to pick frames.`,
|
|
1015
1378
|
],
|
|
1016
1379
|
};
|
|
1017
1380
|
}
|
|
1381
|
+
|
|
1018
1382
|
const changed = change(found.file);
|
|
1383
|
+
|
|
1019
1384
|
if ("problems" in changed) {
|
|
1020
1385
|
return changed;
|
|
1021
1386
|
}
|
|
1022
|
-
|
|
1023
|
-
|
|
1387
|
+
|
|
1388
|
+
const before = found.file?.picks ?? [];
|
|
1389
|
+
|
|
1390
|
+
if (JSON.stringify(changed.picks) !== JSON.stringify(before)) {
|
|
1024
1391
|
await mkdir(own.folder, { recursive: true });
|
|
1025
1392
|
await replaceFile(
|
|
1026
|
-
own.
|
|
1027
|
-
|
|
1393
|
+
own.picks,
|
|
1394
|
+
jsonInLayout(
|
|
1395
|
+
{ ...found.file, ...changed },
|
|
1396
|
+
await readFile(own.picks, "utf8").catch(() => undefined)
|
|
1397
|
+
)
|
|
1028
1398
|
);
|
|
1029
1399
|
}
|
|
1030
1400
|
}
|
|
1031
1401
|
);
|
|
1032
|
-
|
|
1033
|
-
|
|
1034
|
-
|
|
1035
|
-
|
|
1036
|
-
|
|
1402
|
+
|
|
1403
|
+
if (written) {
|
|
1404
|
+
return written;
|
|
1405
|
+
}
|
|
1406
|
+
|
|
1407
|
+
const { picks } = await readPrototypePicks(slug, root);
|
|
1408
|
+
|
|
1409
|
+
return { picks };
|
|
1037
1410
|
}
|
|
1038
1411
|
|
|
1039
1412
|
/**
|
|
1040
|
-
* Put one of the person's picks in their
|
|
1041
|
-
*
|
|
1413
|
+
* Put one of the person's picks in their picks.json, in place of the one
|
|
1414
|
+
* with its id or added, after checking it (pickProblems).
|
|
1042
1415
|
*/
|
|
1043
|
-
export const
|
|
1044
|
-
{
|
|
1416
|
+
export const savePick = (
|
|
1417
|
+
{ pick, ...whose }: PicksOf & { pick: unknown },
|
|
1045
1418
|
root: string
|
|
1046
|
-
): Promise<
|
|
1047
|
-
|
|
1419
|
+
): Promise<SavedPicks> =>
|
|
1420
|
+
changePicks(whose, (file) => withPick(file, pick), root);
|
|
1048
1421
|
|
|
1049
|
-
/** Take one of the person's picks out of their
|
|
1050
|
-
export const
|
|
1422
|
+
/** Take one of the person's picks out of their picks.json. */
|
|
1423
|
+
export const removePick = (
|
|
1051
1424
|
{ id, ...whose }: PicksOf & { id: unknown },
|
|
1052
1425
|
root: string
|
|
1053
|
-
): Promise<
|
|
1426
|
+
): Promise<SavedPicks> =>
|
|
1054
1427
|
isText(id)
|
|
1055
|
-
?
|
|
1428
|
+
? changePicks(whose, (file) => withoutPick(file, id), root)
|
|
1056
1429
|
: Promise.resolve({ problems: ["Say which pick to remove."] });
|
|
1057
1430
|
|
|
1058
1431
|
// --- Creating things ----------------------------------------------------------
|
|
@@ -1120,40 +1493,48 @@ export async function createPrototype(
|
|
|
1120
1493
|
root: string
|
|
1121
1494
|
): Promise<{ folder: string; href: string | undefined; slug: string }> {
|
|
1122
1495
|
const usage = 'Usage: npx dex new --title "<title>" [--person <slug>]';
|
|
1496
|
+
|
|
1123
1497
|
if (!isText(title)) {
|
|
1124
1498
|
throw new Error(`Name the file. ${usage}`);
|
|
1125
1499
|
}
|
|
1500
|
+
|
|
1126
1501
|
if (!isText(person)) {
|
|
1127
1502
|
throw new Error(usage);
|
|
1128
1503
|
}
|
|
1504
|
+
|
|
1129
1505
|
const { contributors } = await loadStudio(root);
|
|
1506
|
+
|
|
1130
1507
|
if (!contributors.some((contributor) => contributor.slug === person)) {
|
|
1131
1508
|
throw new Error(
|
|
1132
1509
|
`"${person}" is not a contributor. Run \`npx dex whoami\` or add them with \`npx dex contributor\`.`
|
|
1133
1510
|
);
|
|
1134
1511
|
}
|
|
1512
|
+
|
|
1135
1513
|
const prototypeSlug = slug === undefined ? freeFileId(root) : slugify(slug);
|
|
1136
1514
|
const paths = prototypePaths(root, prototypeSlug);
|
|
1515
|
+
|
|
1137
1516
|
if (existsSync(paths.folder)) {
|
|
1138
1517
|
throw new Error(`${prototypeFiles(prototypeSlug)?.folder} already exists.`);
|
|
1139
1518
|
}
|
|
1519
|
+
|
|
1140
1520
|
await mkdir(paths.docs, { recursive: true });
|
|
1141
1521
|
// Where the person's views go, there before the first one is.
|
|
1142
1522
|
const views = paths.person(person)?.views;
|
|
1523
|
+
|
|
1143
1524
|
if (views) {
|
|
1144
1525
|
await mkdir(views, { recursive: true });
|
|
1145
1526
|
}
|
|
1146
1527
|
|
|
1147
1528
|
await writeJson(paths.manifest, {
|
|
1148
1529
|
title: title.trim(),
|
|
1149
|
-
|
|
1150
|
-
|
|
1151
|
-
: "What question does this file answer?",
|
|
1530
|
+
// Only a question someone gave: never a placeholder for one.
|
|
1531
|
+
...(isText(description) && { description: description.trim() }),
|
|
1152
1532
|
status: "exploring",
|
|
1153
1533
|
created: today ?? new Date().toISOString().slice(0, 10),
|
|
1154
1534
|
createdBy: person,
|
|
1155
1535
|
tags: [],
|
|
1156
1536
|
});
|
|
1537
|
+
|
|
1157
1538
|
const { problems } = await writeCanvas(
|
|
1158
1539
|
{
|
|
1159
1540
|
person,
|
|
@@ -1165,10 +1546,13 @@ export async function createPrototype(
|
|
|
1165
1546
|
},
|
|
1166
1547
|
root
|
|
1167
1548
|
);
|
|
1549
|
+
|
|
1168
1550
|
if (problems) {
|
|
1169
1551
|
throw new Error(problems.join(" "));
|
|
1170
1552
|
}
|
|
1553
|
+
|
|
1171
1554
|
await writeFile(join(paths.docs, ".gitkeep"), "");
|
|
1555
|
+
|
|
1172
1556
|
return {
|
|
1173
1557
|
folder: paths.folder,
|
|
1174
1558
|
slug: prototypeSlug,
|
|
@@ -1182,12 +1566,16 @@ const UNTITLED = "Untitled";
|
|
|
1182
1566
|
const freeFileId = (root: string): string => {
|
|
1183
1567
|
const taken = (candidate: string): boolean => {
|
|
1184
1568
|
const files = prototypeFiles(candidate);
|
|
1569
|
+
|
|
1185
1570
|
return files !== undefined && existsSync(join(root, files.folder));
|
|
1186
1571
|
};
|
|
1572
|
+
|
|
1187
1573
|
let id = newFileId();
|
|
1574
|
+
|
|
1188
1575
|
while (taken(id)) {
|
|
1189
1576
|
id = newFileId();
|
|
1190
1577
|
}
|
|
1578
|
+
|
|
1191
1579
|
return id;
|
|
1192
1580
|
};
|
|
1193
1581
|
|
|
@@ -1208,6 +1596,7 @@ const existingPaths = (root: string, slug: string): PrototypeFiles => {
|
|
|
1208
1596
|
if (!prototypeExists(root, slug)) {
|
|
1209
1597
|
throw new Error("That file does not exist.");
|
|
1210
1598
|
}
|
|
1599
|
+
|
|
1211
1600
|
return prototypePaths(root, slug);
|
|
1212
1601
|
};
|
|
1213
1602
|
|
|
@@ -1219,9 +1608,11 @@ export async function setPrototypeTitle(
|
|
|
1219
1608
|
root: string
|
|
1220
1609
|
): Promise<void> {
|
|
1221
1610
|
const name = String(title ?? "").trim();
|
|
1611
|
+
|
|
1222
1612
|
if (!name) {
|
|
1223
1613
|
throw new Error("Name the file.");
|
|
1224
1614
|
}
|
|
1615
|
+
|
|
1225
1616
|
const file = existingPaths(root, slug).manifest;
|
|
1226
1617
|
await writeJson(file, {
|
|
1227
1618
|
...(await readJson<object>(file)),
|
|
@@ -1237,6 +1628,7 @@ export async function setPrototypeStatus(
|
|
|
1237
1628
|
if (!isOneOf(STATUSES, status)) {
|
|
1238
1629
|
throw new Error(`The status must be one of ${STATUSES.join(", ")}.`);
|
|
1239
1630
|
}
|
|
1631
|
+
|
|
1240
1632
|
const file = existingPaths(root, slug).manifest;
|
|
1241
1633
|
await writeJson(file, { ...(await readJson<object>(file)), status });
|
|
1242
1634
|
}
|
|
@@ -1251,17 +1643,23 @@ export async function setPrototypeCover(
|
|
|
1251
1643
|
root: string
|
|
1252
1644
|
): Promise<void> {
|
|
1253
1645
|
const file = existingPaths(root, slug).manifest;
|
|
1646
|
+
|
|
1254
1647
|
const { cover: _old, ...manifest } = await readJson<{ cover?: unknown }>(
|
|
1255
1648
|
file
|
|
1256
1649
|
);
|
|
1650
|
+
|
|
1257
1651
|
if (cover === null) {
|
|
1258
1652
|
await writeJson(file, manifest);
|
|
1653
|
+
|
|
1259
1654
|
return;
|
|
1260
1655
|
}
|
|
1656
|
+
|
|
1261
1657
|
const checked = checkFrameAnchor(cover, "cover");
|
|
1658
|
+
|
|
1262
1659
|
if ("problems" in checked) {
|
|
1263
1660
|
throw new Error(checked.problems.join(" "));
|
|
1264
1661
|
}
|
|
1662
|
+
|
|
1265
1663
|
await writeJson(file, { ...manifest, cover: checked.frame });
|
|
1266
1664
|
}
|
|
1267
1665
|
|
|
@@ -1282,18 +1680,27 @@ export async function duplicatePrototype(
|
|
|
1282
1680
|
recursive: true,
|
|
1283
1681
|
filter: (path) => splitPrototypeFile(root, path)?.part !== "comments",
|
|
1284
1682
|
});
|
|
1285
|
-
// A copy was never anything else: no name from before files
|
|
1683
|
+
// A copy was never anything else: no name from before files/, and its
|
|
1684
|
+
// manifest is file.json, whatever the original's is called.
|
|
1685
|
+
const copied = prototypePaths(root, copy).manifest;
|
|
1686
|
+
|
|
1286
1687
|
const { was: _was, ...manifest } = await readJson<{
|
|
1287
1688
|
title?: unknown;
|
|
1288
1689
|
was?: unknown;
|
|
1289
|
-
}>(
|
|
1690
|
+
}>(copied);
|
|
1691
|
+
|
|
1692
|
+
if (copied !== to.manifest) {
|
|
1693
|
+
await rm(copied);
|
|
1694
|
+
}
|
|
1695
|
+
|
|
1290
1696
|
await writeJson(to.manifest, {
|
|
1291
1697
|
...manifest,
|
|
1292
1698
|
title: `${manifest.title} (copy)`,
|
|
1293
1699
|
status: "exploring",
|
|
1294
1700
|
created: today ?? new Date().toISOString().slice(0, 10),
|
|
1295
|
-
...(person
|
|
1701
|
+
...(person && { createdBy: person }),
|
|
1296
1702
|
});
|
|
1703
|
+
|
|
1297
1704
|
return { href: prototypePage(copy) };
|
|
1298
1705
|
}
|
|
1299
1706
|
|
|
@@ -1325,24 +1732,31 @@ export async function addContributor(
|
|
|
1325
1732
|
`Usage: npx dex contributor --name "<name>" --git "<git user>" --discipline <${DISCIPLINES.join("|")}>`
|
|
1326
1733
|
);
|
|
1327
1734
|
}
|
|
1735
|
+
|
|
1328
1736
|
const login = isText(github) ? github.trim().replace(LEADING_AT_RE, "") : "";
|
|
1737
|
+
|
|
1329
1738
|
if (github !== undefined && !GITHUB_LOGIN_RE.test(login)) {
|
|
1330
1739
|
throw new Error(`"${github}" is not a GitHub username.`);
|
|
1331
1740
|
}
|
|
1741
|
+
|
|
1332
1742
|
const slug = slugify(name);
|
|
1743
|
+
|
|
1333
1744
|
const added: Contributor = {
|
|
1334
1745
|
slug,
|
|
1335
1746
|
name: name.trim(),
|
|
1336
1747
|
git: [git.trim()],
|
|
1337
1748
|
discipline,
|
|
1338
|
-
...(login
|
|
1749
|
+
...(login && { github: login }),
|
|
1339
1750
|
};
|
|
1751
|
+
|
|
1340
1752
|
await changeContributors(root, (contributors) => {
|
|
1341
1753
|
if (contributors.some((contributor) => contributor.slug === slug)) {
|
|
1342
1754
|
throw new Error(`"${slug}" is already a contributor.`);
|
|
1343
1755
|
}
|
|
1756
|
+
|
|
1344
1757
|
return { result: undefined, write: [...contributors, added] };
|
|
1345
1758
|
});
|
|
1759
|
+
|
|
1346
1760
|
return slug;
|
|
1347
1761
|
}
|
|
1348
1762
|
|
|
@@ -1361,9 +1775,14 @@ const changeContributors = <T>(
|
|
|
1361
1775
|
inTurn(root, "contributors", CONTRIBUTORS_LOCK_STALE_MS, async () => {
|
|
1362
1776
|
const path = join(root, "contributors.json");
|
|
1363
1777
|
const { result, write } = change(await readContributors(path));
|
|
1778
|
+
|
|
1364
1779
|
if (write) {
|
|
1365
|
-
await replaceFile(
|
|
1780
|
+
await replaceFile(
|
|
1781
|
+
path,
|
|
1782
|
+
jsonInLayout(write, await readFile(path, "utf8").catch(() => undefined))
|
|
1783
|
+
);
|
|
1366
1784
|
}
|
|
1785
|
+
|
|
1367
1786
|
return result;
|
|
1368
1787
|
});
|
|
1369
1788
|
|
|
@@ -1393,7 +1812,7 @@ export const currentPerson = async (
|
|
|
1393
1812
|
try {
|
|
1394
1813
|
return youOf(await identify(root))?.slug;
|
|
1395
1814
|
} catch {
|
|
1396
|
-
|
|
1815
|
+
// Dex can't tell who you are: undefined.
|
|
1397
1816
|
}
|
|
1398
1817
|
};
|
|
1399
1818
|
|
|
@@ -1406,19 +1825,23 @@ export const currentPerson = async (
|
|
|
1406
1825
|
export async function joinCurrentPerson(
|
|
1407
1826
|
root: string
|
|
1408
1827
|
): Promise<Contributor | undefined> {
|
|
1409
|
-
const [
|
|
1828
|
+
const [gitUser, github] = await Promise.all([
|
|
1410
1829
|
yourGitUser(root),
|
|
1411
1830
|
githubAccountLogin(),
|
|
1412
1831
|
]);
|
|
1832
|
+
|
|
1413
1833
|
const { contributors } = await loadStudio(root);
|
|
1414
|
-
const known = identityFrom(contributors,
|
|
1834
|
+
const known = identityFrom(contributors, gitUser, github);
|
|
1835
|
+
|
|
1415
1836
|
if (!known.newcomer) {
|
|
1416
1837
|
return known.contributor;
|
|
1417
1838
|
}
|
|
1839
|
+
|
|
1418
1840
|
// Decided again from the file as it is now: another save, or another
|
|
1419
1841
|
// process, may have added you, or taken the slug you would have.
|
|
1420
1842
|
const joined = await changeContributors(root, (current) => {
|
|
1421
|
-
const { contributor, newcomer } = identityFrom(current,
|
|
1843
|
+
const { contributor, newcomer } = identityFrom(current, gitUser, github);
|
|
1844
|
+
|
|
1422
1845
|
return newcomer
|
|
1423
1846
|
? {
|
|
1424
1847
|
result: { you: newcomer, added: true },
|
|
@@ -1426,10 +1849,12 @@ export async function joinCurrentPerson(
|
|
|
1426
1849
|
}
|
|
1427
1850
|
: { result: { you: contributor, added: false } };
|
|
1428
1851
|
});
|
|
1852
|
+
|
|
1429
1853
|
if (joined.added && joined.you) {
|
|
1430
1854
|
// Afterwards: a slow or missing GitHub CLI never holds up joining.
|
|
1431
1855
|
linkGithub(root).catch(() => undefined);
|
|
1432
1856
|
}
|
|
1857
|
+
|
|
1433
1858
|
return joined.you;
|
|
1434
1859
|
}
|
|
1435
1860
|
|
|
@@ -1445,6 +1870,7 @@ const gitFolders = new Map<string, string[]>();
|
|
|
1445
1870
|
*/
|
|
1446
1871
|
const gitConfigFiles = (root: string): string[] => {
|
|
1447
1872
|
let folders = gitFolders.get(root);
|
|
1873
|
+
|
|
1448
1874
|
if (!folders) {
|
|
1449
1875
|
const found = git(["rev-parse", "--git-dir", "--git-common-dir"], root);
|
|
1450
1876
|
folders = [
|
|
@@ -1455,12 +1881,15 @@ const gitConfigFiles = (root: string): string[] => {
|
|
|
1455
1881
|
.map((folder) => resolve(root, folder))
|
|
1456
1882
|
),
|
|
1457
1883
|
];
|
|
1884
|
+
|
|
1458
1885
|
if (folders.length > 0) {
|
|
1459
1886
|
gitFolders.set(root, folders);
|
|
1460
1887
|
}
|
|
1461
1888
|
}
|
|
1889
|
+
|
|
1462
1890
|
const home = homedir();
|
|
1463
1891
|
const global = process.env.GIT_CONFIG_GLOBAL;
|
|
1892
|
+
|
|
1464
1893
|
return [
|
|
1465
1894
|
...(global ? [resolve(root, global)] : []),
|
|
1466
1895
|
join(home, ".gitconfig"),
|
|
@@ -1473,17 +1902,17 @@ const gitConfigFiles = (root: string): string[] => {
|
|
|
1473
1902
|
};
|
|
1474
1903
|
|
|
1475
1904
|
/** When and how big each file is, as one string: "" for a file not there. */
|
|
1476
|
-
const stamp = async (files: string[]): Promise<string> =>
|
|
1477
|
-
(
|
|
1478
|
-
|
|
1479
|
-
|
|
1480
|
-
|
|
1481
|
-
|
|
1482
|
-
() => ""
|
|
1483
|
-
)
|
|
1484
|
-
)
|
|
1905
|
+
const stamp = async (files: string[]): Promise<string> => {
|
|
1906
|
+
const stamps = await Promise.all(
|
|
1907
|
+
files.map((file) =>
|
|
1908
|
+
stat(file)
|
|
1909
|
+
.then(({ mtimeMs, size }) => `${mtimeMs}:${size}`)
|
|
1910
|
+
.catch(() => "")
|
|
1485
1911
|
)
|
|
1486
|
-
)
|
|
1912
|
+
);
|
|
1913
|
+
|
|
1914
|
+
return stamps.join("|");
|
|
1915
|
+
};
|
|
1487
1916
|
|
|
1488
1917
|
const FILE_ORIGIN = "file:";
|
|
1489
1918
|
|
|
@@ -1508,20 +1937,26 @@ const readGitUser = (root: string): GitUser & { files: string[] } => {
|
|
|
1508
1937
|
const fields = git(["config", "--list", "--show-origin", "-z"], root).split(
|
|
1509
1938
|
"\0"
|
|
1510
1939
|
);
|
|
1940
|
+
|
|
1511
1941
|
const files = new Set<string>();
|
|
1512
1942
|
const found: Record<string, string> = {};
|
|
1943
|
+
|
|
1513
1944
|
for (let at = 0; at + 1 < fields.length; at += 2) {
|
|
1514
1945
|
const origin = fields[at] ?? "";
|
|
1515
1946
|
const entry = fields[at + 1] ?? "";
|
|
1947
|
+
|
|
1516
1948
|
if (origin.startsWith(FILE_ORIGIN)) {
|
|
1517
1949
|
files.add(resolve(root, origin.slice(FILE_ORIGIN.length)));
|
|
1518
1950
|
}
|
|
1951
|
+
|
|
1519
1952
|
const split = entry.indexOf("\n");
|
|
1520
1953
|
const key = split === -1 ? entry : entry.slice(0, split);
|
|
1954
|
+
|
|
1521
1955
|
if (key === "user.name" || key === "user.email") {
|
|
1522
1956
|
found[key] = split === -1 ? "" : entry.slice(split + 1);
|
|
1523
1957
|
}
|
|
1524
1958
|
}
|
|
1959
|
+
|
|
1525
1960
|
return {
|
|
1526
1961
|
name: found["user.name"]?.trim() ?? "",
|
|
1527
1962
|
email: found["user.email"]?.trim() ?? "",
|
|
@@ -1543,21 +1978,27 @@ const gitUsers = new Map<
|
|
|
1543
1978
|
async function yourGitUser(root: string): Promise<GitUser> {
|
|
1544
1979
|
// Hosted, "you" is whoever this request is from, never the machine's git.
|
|
1545
1980
|
const person = hostedPerson();
|
|
1981
|
+
|
|
1546
1982
|
if (person) {
|
|
1547
1983
|
return { name: person.name, email: person.email, accountEmail: true };
|
|
1548
1984
|
}
|
|
1985
|
+
|
|
1549
1986
|
const base = gitConfigFiles(root);
|
|
1550
1987
|
const global = process.env.GIT_CONFIG_GLOBAL ?? "";
|
|
1551
1988
|
const kept = gitUsers.get(root);
|
|
1989
|
+
|
|
1552
1990
|
if (kept) {
|
|
1553
1991
|
const now = `${global}>${await stamp([...base, ...kept.files])}`;
|
|
1992
|
+
|
|
1554
1993
|
if (kept.stamp === now) {
|
|
1555
1994
|
return kept;
|
|
1556
1995
|
}
|
|
1557
1996
|
}
|
|
1997
|
+
|
|
1558
1998
|
const read = readGitUser(root);
|
|
1559
1999
|
const at = `${global}>${await stamp([...base, ...read.files])}`;
|
|
1560
2000
|
gitUsers.set(root, { ...read, stamp: at });
|
|
2001
|
+
|
|
1561
2002
|
return read;
|
|
1562
2003
|
}
|
|
1563
2004
|
|
|
@@ -1571,6 +2012,7 @@ const githubHostsFile = (): string => {
|
|
|
1571
2012
|
(process.platform === "win32" && process.env.AppData
|
|
1572
2013
|
? join(process.env.AppData, "GitHub CLI")
|
|
1573
2014
|
: join(process.env.XDG_CONFIG_HOME || join(homedir(), ".config"), "gh"));
|
|
2015
|
+
|
|
1574
2016
|
return join(folder, "hosts.yml");
|
|
1575
2017
|
};
|
|
1576
2018
|
|
|
@@ -1590,23 +2032,27 @@ const SIGNED_OUT_EXIT = 1;
|
|
|
1590
2032
|
* signed out or no CLI; throws when the CLI could not answer (it timed out,
|
|
1591
2033
|
* or was stopped), so that is never taken for signed out.
|
|
1592
2034
|
*/
|
|
1593
|
-
const askGithubCli = (host: string): Promise<string | undefined> =>
|
|
1594
|
-
|
|
1595
|
-
|
|
2035
|
+
const askGithubCli = async (host: string): Promise<string | undefined> => {
|
|
2036
|
+
try {
|
|
2037
|
+
const { stdout } = await execFileAsync(
|
|
1596
2038
|
"gh",
|
|
1597
2039
|
["config", "get", "user", "--host", host],
|
|
1598
|
-
{ timeout: GH_TIMEOUT_MS }
|
|
1599
|
-
|
|
1600
|
-
|
|
1601
|
-
|
|
1602
|
-
|
|
1603
|
-
|
|
1604
|
-
|
|
1605
|
-
|
|
1606
|
-
|
|
1607
|
-
|
|
1608
|
-
|
|
1609
|
-
|
|
2040
|
+
{ timeout: GH_TIMEOUT_MS }
|
|
2041
|
+
);
|
|
2042
|
+
|
|
2043
|
+
return stdout.trim() || undefined;
|
|
2044
|
+
} catch (error) {
|
|
2045
|
+
// SAFETY: execFile fails with an ExecFileException: its code is the exit
|
|
2046
|
+
// code, or the system error's when gh could not start.
|
|
2047
|
+
const { code } = error as ExecFileException;
|
|
2048
|
+
|
|
2049
|
+
if (code === SIGNED_OUT_EXIT || code === "ENOENT") {
|
|
2050
|
+
return undefined;
|
|
2051
|
+
}
|
|
2052
|
+
|
|
2053
|
+
throw error;
|
|
2054
|
+
}
|
|
2055
|
+
};
|
|
1610
2056
|
|
|
1611
2057
|
/**
|
|
1612
2058
|
* The account the GitHub CLI is signed in to, or undefined when there is no
|
|
@@ -1620,23 +2066,28 @@ export async function githubAccountLogin(): Promise<string | undefined> {
|
|
|
1620
2066
|
if (isHosted()) {
|
|
1621
2067
|
return;
|
|
1622
2068
|
}
|
|
2069
|
+
|
|
1623
2070
|
const host = githubHost();
|
|
1624
2071
|
const file = githubHostsFile();
|
|
2072
|
+
|
|
1625
2073
|
const changed =
|
|
1626
2074
|
(await stamp([file])) ||
|
|
1627
2075
|
String(Math.floor(Date.now() / GITHUB_LOGIN_KEPT_MS));
|
|
2076
|
+
|
|
1628
2077
|
const key = `${host}>${file}>${changed}`;
|
|
2078
|
+
|
|
1629
2079
|
if (githubAccount?.key !== key) {
|
|
1630
2080
|
githubAccount = { key, login: askGithubCli(host) };
|
|
1631
2081
|
}
|
|
2082
|
+
|
|
1632
2083
|
const asked = githubAccount;
|
|
2084
|
+
|
|
1633
2085
|
try {
|
|
1634
2086
|
return await asked.login;
|
|
1635
2087
|
} catch {
|
|
1636
2088
|
if (githubAccount === asked) {
|
|
1637
2089
|
githubAccount = undefined;
|
|
1638
2090
|
}
|
|
1639
|
-
return;
|
|
1640
2091
|
}
|
|
1641
2092
|
}
|
|
1642
2093
|
|
|
@@ -1663,12 +2114,13 @@ export interface Identity {
|
|
|
1663
2114
|
|
|
1664
2115
|
/** Who you are in this workspace (identityFrom). */
|
|
1665
2116
|
export async function identify(root: string): Promise<Identity> {
|
|
1666
|
-
const [{ contributors },
|
|
2117
|
+
const [{ contributors }, gitUser, github] = await Promise.all([
|
|
1667
2118
|
loadStudio(root),
|
|
1668
2119
|
yourGitUser(root),
|
|
1669
2120
|
githubAccountLogin(),
|
|
1670
2121
|
]);
|
|
1671
|
-
|
|
2122
|
+
|
|
2123
|
+
return identityFrom(contributors, gitUser, github);
|
|
1672
2124
|
}
|
|
1673
2125
|
|
|
1674
2126
|
/** The contributor who has `value` among their git names and emails. */
|
|
@@ -1677,6 +2129,7 @@ const gitNamed = (
|
|
|
1677
2129
|
value: string
|
|
1678
2130
|
): Contributor | undefined => {
|
|
1679
2131
|
const said = value.trim().toLowerCase();
|
|
2132
|
+
|
|
1680
2133
|
return said
|
|
1681
2134
|
? contributors.find((contributor) =>
|
|
1682
2135
|
contributor.git.some((name) => name.trim().toLowerCase() === said)
|
|
@@ -1696,50 +2149,61 @@ const gitNamed = (
|
|
|
1696
2149
|
*/
|
|
1697
2150
|
export function identityFrom(
|
|
1698
2151
|
contributors: Contributor[],
|
|
1699
|
-
|
|
2152
|
+
gitUser: GitUser,
|
|
1700
2153
|
github: string | undefined
|
|
1701
2154
|
): Identity {
|
|
1702
2155
|
const account = github?.toLowerCase();
|
|
2156
|
+
|
|
1703
2157
|
const byGithub = account
|
|
1704
2158
|
? contributors.find(
|
|
1705
2159
|
(contributor) => contributor.github?.toLowerCase() === account
|
|
1706
2160
|
)
|
|
1707
2161
|
: undefined;
|
|
1708
|
-
|
|
1709
|
-
const
|
|
2162
|
+
|
|
2163
|
+
const byEmail = gitNamed(contributors, gitUser.email);
|
|
2164
|
+
|
|
2165
|
+
const byName = gitUser.accountEmail
|
|
1710
2166
|
? undefined
|
|
1711
|
-
: gitNamed(contributors,
|
|
2167
|
+
: gitNamed(contributors, gitUser.name);
|
|
2168
|
+
|
|
1712
2169
|
if (byGithub) {
|
|
1713
2170
|
const byGit = byEmail ?? byName;
|
|
2171
|
+
|
|
1714
2172
|
// Your git user is theirs when it names them too: two can share a
|
|
1715
2173
|
// name, never an email.
|
|
1716
2174
|
const theirs = byEmail
|
|
1717
2175
|
? byEmail.slug === byGithub.slug
|
|
1718
|
-
: gitNamed([byGithub],
|
|
2176
|
+
: gitNamed([byGithub], gitUser.name) !== undefined;
|
|
2177
|
+
|
|
1719
2178
|
return {
|
|
1720
2179
|
contributor: byGithub,
|
|
1721
2180
|
github,
|
|
1722
2181
|
via: "github",
|
|
1723
|
-
...(byGit && !theirs
|
|
2182
|
+
...(byGit && !theirs && { gitSays: byGit }),
|
|
1724
2183
|
};
|
|
1725
2184
|
}
|
|
2185
|
+
|
|
1726
2186
|
if (byEmail) {
|
|
1727
2187
|
return { contributor: byEmail, github, via: "git" };
|
|
1728
2188
|
}
|
|
2189
|
+
|
|
1729
2190
|
const nameIsAnothers =
|
|
1730
2191
|
account !== undefined &&
|
|
1731
2192
|
byName?.github !== undefined &&
|
|
1732
2193
|
byName.github.toLowerCase() !== account;
|
|
2194
|
+
|
|
1733
2195
|
if (byName && !nameIsAnothers) {
|
|
1734
2196
|
return { contributor: byName, github, via: "git" };
|
|
1735
2197
|
}
|
|
1736
|
-
|
|
2198
|
+
|
|
2199
|
+
const newcomer = newcomerFrom(contributors, gitUser, github);
|
|
2200
|
+
|
|
1737
2201
|
return {
|
|
1738
2202
|
contributor: undefined,
|
|
1739
2203
|
github,
|
|
1740
2204
|
via: undefined,
|
|
1741
|
-
...(byName
|
|
1742
|
-
...(newcomer
|
|
2205
|
+
...(byName && { gitSays: byName }),
|
|
2206
|
+
...(newcomer && { newcomer }),
|
|
1743
2207
|
};
|
|
1744
2208
|
}
|
|
1745
2209
|
|
|
@@ -1754,7 +2218,7 @@ const UNNAMED_SLUG = "someone";
|
|
|
1754
2218
|
* app's `name[bot]` and its noreply email, GitHub's own Actions and
|
|
1755
2219
|
* Dependabot, and the address GitHub commits from on the web.
|
|
1756
2220
|
*/
|
|
1757
|
-
const BOT_RE = /\[bot\]|^(?:github-actions|dependabot|noreply@github\.com)$/
|
|
2221
|
+
const BOT_RE = /\[bot\]|^(?:github-actions|dependabot|noreply@github\.com)$/iu;
|
|
1758
2222
|
|
|
1759
2223
|
/**
|
|
1760
2224
|
* The contributor someone with this git user and GitHub account would be:
|
|
@@ -1766,34 +2230,46 @@ const BOT_RE = /\[bot\]|^(?:github-actions|dependabot|noreply@github\.com)$/i;
|
|
|
1766
2230
|
*/
|
|
1767
2231
|
function newcomerFrom(
|
|
1768
2232
|
contributors: Contributor[],
|
|
1769
|
-
|
|
2233
|
+
gitUser: GitUser,
|
|
1770
2234
|
github: string | undefined
|
|
1771
2235
|
): Contributor | undefined {
|
|
1772
2236
|
const login = github && GITHUB_LOGIN_RE.test(github) ? github : undefined;
|
|
1773
|
-
|
|
2237
|
+
|
|
2238
|
+
if (
|
|
2239
|
+
[gitUser.name, gitUser.email, login].some(
|
|
2240
|
+
(said) => said && BOT_RE.test(said)
|
|
2241
|
+
)
|
|
2242
|
+
) {
|
|
1774
2243
|
return;
|
|
1775
2244
|
}
|
|
1776
|
-
|
|
2245
|
+
|
|
2246
|
+
const name = gitUser.name || login;
|
|
2247
|
+
|
|
1777
2248
|
if (!name) {
|
|
1778
2249
|
return;
|
|
1779
2250
|
}
|
|
2251
|
+
|
|
1780
2252
|
const base = slugify(name) || slugify(login ?? "") || UNNAMED_SLUG;
|
|
1781
2253
|
const taken = new Set(contributors.map((contributor) => contributor.slug));
|
|
1782
2254
|
let slug = base;
|
|
2255
|
+
|
|
1783
2256
|
for (let count = 2; taken.has(slug); count += 1) {
|
|
1784
2257
|
slug = `${base}-${count}`;
|
|
1785
2258
|
}
|
|
2259
|
+
|
|
1786
2260
|
return {
|
|
1787
2261
|
slug,
|
|
1788
2262
|
name,
|
|
1789
2263
|
git: [name],
|
|
1790
2264
|
discipline: NEWCOMER_DISCIPLINE,
|
|
1791
|
-
...(login
|
|
2265
|
+
...(login && { github: login }),
|
|
1792
2266
|
};
|
|
1793
2267
|
}
|
|
1794
2268
|
|
|
1795
2269
|
export async function whoami(root: string): Promise<Contributor | undefined> {
|
|
1796
|
-
|
|
2270
|
+
const { contributor } = await identify(root);
|
|
2271
|
+
|
|
2272
|
+
return contributor;
|
|
1797
2273
|
}
|
|
1798
2274
|
|
|
1799
2275
|
/**
|
|
@@ -1803,24 +2279,27 @@ export async function whoami(root: string): Promise<Contributor | undefined> {
|
|
|
1803
2279
|
*/
|
|
1804
2280
|
export async function githubLogin(root: string): Promise<string | undefined> {
|
|
1805
2281
|
const account = await githubAccountLogin();
|
|
2282
|
+
|
|
1806
2283
|
if (account && GITHUB_LOGIN_RE.test(account)) {
|
|
1807
2284
|
return account;
|
|
1808
2285
|
}
|
|
2286
|
+
|
|
1809
2287
|
const email = git(["config", "user.email"], root);
|
|
1810
2288
|
const noreply = GITHUB_NOREPLY_RE.exec(email)?.[1];
|
|
2289
|
+
|
|
1811
2290
|
if (noreply && GITHUB_LOGIN_RE.test(noreply)) {
|
|
1812
2291
|
return noreply;
|
|
1813
2292
|
}
|
|
2293
|
+
|
|
1814
2294
|
// Signed in with a token alone (GH_TOKEN, as in a codespace), the CLI's
|
|
1815
2295
|
// config names no one: GitHub itself is asked whose the token is.
|
|
1816
|
-
const login = await
|
|
1817
|
-
|
|
1818
|
-
|
|
1819
|
-
|
|
1820
|
-
|
|
1821
|
-
|
|
1822
|
-
|
|
1823
|
-
);
|
|
2296
|
+
const login = await execFileAsync("gh", ["api", "user", "--jq", ".login"], {
|
|
2297
|
+
cwd: root,
|
|
2298
|
+
timeout: GH_TIMEOUT_MS,
|
|
2299
|
+
})
|
|
2300
|
+
.then(({ stdout }) => stdout.trim())
|
|
2301
|
+
.catch(() => "");
|
|
2302
|
+
|
|
1824
2303
|
return GITHUB_LOGIN_RE.test(login) ? login : undefined;
|
|
1825
2304
|
}
|
|
1826
2305
|
|
|
@@ -1830,15 +2309,20 @@ export async function githubLogin(root: string): Promise<string | undefined> {
|
|
|
1830
2309
|
*/
|
|
1831
2310
|
export async function linkGithub(root: string): Promise<string | undefined> {
|
|
1832
2311
|
const contributor = await whoami(root);
|
|
2312
|
+
|
|
1833
2313
|
if (!contributor || contributor.github) {
|
|
1834
2314
|
return;
|
|
1835
2315
|
}
|
|
2316
|
+
|
|
1836
2317
|
const login = await githubLogin(root);
|
|
2318
|
+
|
|
1837
2319
|
if (!login) {
|
|
1838
2320
|
return;
|
|
1839
2321
|
}
|
|
2322
|
+
|
|
1840
2323
|
return changeContributors(root, (contributors) => {
|
|
1841
2324
|
const entry = contributors.find(({ slug }) => slug === contributor.slug);
|
|
2325
|
+
|
|
1842
2326
|
return entry && !entry.github
|
|
1843
2327
|
? {
|
|
1844
2328
|
result: login,
|
|
@@ -1858,14 +2342,18 @@ export async function linkGithub(root: string): Promise<string | undefined> {
|
|
|
1858
2342
|
*/
|
|
1859
2343
|
export const changedFiles = (base: string, root: string): string[] => {
|
|
1860
2344
|
const mergeBase = git(["merge-base", "HEAD", base], root);
|
|
2345
|
+
|
|
1861
2346
|
const committed = mergeBase
|
|
1862
2347
|
? git(["diff", "--name-only", mergeBase, "HEAD"], root).split("\n")
|
|
1863
2348
|
: [];
|
|
2349
|
+
|
|
1864
2350
|
const working = git(["diff", "--name-only", "HEAD"], root).split("\n");
|
|
2351
|
+
|
|
1865
2352
|
const untracked = git(
|
|
1866
2353
|
["ls-files", "--others", "--exclude-standard", "--full-name"],
|
|
1867
2354
|
root
|
|
1868
2355
|
).split("\n");
|
|
2356
|
+
|
|
1869
2357
|
return [...new Set([...committed, ...working, ...untracked])].filter(Boolean);
|
|
1870
2358
|
};
|
|
1871
2359
|
|
|
@@ -1879,10 +2367,12 @@ export function allowedPrefixes(person: string, root: string): string[] {
|
|
|
1879
2367
|
if (!isSlug(person)) {
|
|
1880
2368
|
return [];
|
|
1881
2369
|
}
|
|
2370
|
+
|
|
1882
2371
|
// Git reports paths from the repository root; the studio may sit anywhere in it.
|
|
1883
2372
|
const repository = git(["rev-parse", "--show-toplevel"], root) || root;
|
|
1884
2373
|
const folder = relative(repository, root);
|
|
1885
2374
|
const studio = folder ? `${folder}/` : "";
|
|
2375
|
+
|
|
1886
2376
|
return [
|
|
1887
2377
|
`${studio}${PROTOTYPES_FOLDER}/*/`,
|
|
1888
2378
|
`${studio}${PROTOTYPES_FOLDER}/*/people/${person}/`,
|
|
@@ -1890,9 +2380,9 @@ export function allowedPrefixes(person: string, root: string): string[] {
|
|
|
1890
2380
|
];
|
|
1891
2381
|
}
|
|
1892
2382
|
|
|
1893
|
-
const PEOPLE_FOLDER_RE = /\/people\/[^/]
|
|
1894
|
-
const STAR_RE = /\*/
|
|
1895
|
-
const SPECIAL_RE = /[.+?^${}()|[\]\\]/
|
|
2383
|
+
const PEOPLE_FOLDER_RE = /\/people\/[^/]+\//u;
|
|
2384
|
+
const STAR_RE = /\*/gu;
|
|
2385
|
+
const SPECIAL_RE = /[.+?^${}()|[\]\\]/gu;
|
|
1896
2386
|
|
|
1897
2387
|
/**
|
|
1898
2388
|
* Whether a file is under a prefix. Someone's people/ folder is theirs even
|
|
@@ -1900,12 +2390,16 @@ const SPECIAL_RE = /[.+?^${}()|[\]\\]/g;
|
|
|
1900
2390
|
*/
|
|
1901
2391
|
const underPrefix = (file: string, prefix: string): boolean => {
|
|
1902
2392
|
const pattern = new RegExp(
|
|
1903
|
-
`^${prefix.
|
|
2393
|
+
`^${prefix.replaceAll(SPECIAL_RE, "\\$&").replaceAll(STAR_RE, "[^/]+")}`,
|
|
2394
|
+
"u"
|
|
1904
2395
|
);
|
|
2396
|
+
|
|
1905
2397
|
const match = pattern.exec(file);
|
|
2398
|
+
|
|
1906
2399
|
if (!match) {
|
|
1907
2400
|
return false;
|
|
1908
2401
|
}
|
|
2402
|
+
|
|
1909
2403
|
return (
|
|
1910
2404
|
PEOPLE_FOLDER_RE.test(prefix) ||
|
|
1911
2405
|
!PEOPLE_FOLDER_RE.test(file.slice(match[0].length - 1))
|
|
@@ -1938,6 +2432,7 @@ export function framePageOf(
|
|
|
1938
2432
|
): string | undefined {
|
|
1939
2433
|
const query = new URLSearchParams(frame.params ?? {});
|
|
1940
2434
|
const search = query.size > 0 ? `?${query}` : "";
|
|
2435
|
+
|
|
1941
2436
|
return framePage(slug, frame.view, search);
|
|
1942
2437
|
}
|
|
1943
2438
|
|
|
@@ -1965,9 +2460,11 @@ async function snapshotOf(
|
|
|
1965
2460
|
slug: string
|
|
1966
2461
|
): Promise<ViewShot | { problem: string }> {
|
|
1967
2462
|
const href = framePageOf(slug, frame);
|
|
2463
|
+
|
|
1968
2464
|
if (!href) {
|
|
1969
2465
|
return { problem: `no snapshot: "${frame.view}" is not a view's name` };
|
|
1970
2466
|
}
|
|
2467
|
+
|
|
1971
2468
|
try {
|
|
1972
2469
|
return await snapshotView(url, {
|
|
1973
2470
|
href,
|
|
@@ -1978,6 +2475,7 @@ async function snapshotOf(
|
|
|
1978
2475
|
if (error instanceof SnapshotError && error.status !== undefined) {
|
|
1979
2476
|
return { problem: `no snapshot (${error.status}): ${error.message}` };
|
|
1980
2477
|
}
|
|
2478
|
+
|
|
1981
2479
|
throw error;
|
|
1982
2480
|
}
|
|
1983
2481
|
}
|
|
@@ -2008,41 +2506,52 @@ export async function snapshot(
|
|
|
2008
2506
|
"Usage: npx dex snapshot --slug <file> [--view <view>] [--url <address>]"
|
|
2009
2507
|
);
|
|
2010
2508
|
}
|
|
2509
|
+
|
|
2011
2510
|
const canvas = await readCanvas(slug, root);
|
|
2511
|
+
|
|
2012
2512
|
if (canvas.sections.length === 0) {
|
|
2013
2513
|
throw new Error(`${slug} has nothing on its canvas to snapshot.`);
|
|
2014
2514
|
}
|
|
2515
|
+
|
|
2015
2516
|
const frames = canvasFrames(canvas).flatMap(({ address, frame }) => {
|
|
2016
2517
|
const view = viewOf(frame);
|
|
2518
|
+
|
|
2017
2519
|
return view && (!only || view.view === only)
|
|
2018
2520
|
? [{ address, frame: view }]
|
|
2019
2521
|
: [];
|
|
2020
2522
|
});
|
|
2523
|
+
|
|
2021
2524
|
if (only && frames.length === 0) {
|
|
2022
2525
|
throw new Error(
|
|
2023
2526
|
`${slug} has no frame on its canvas showing the view "${only}".`
|
|
2024
2527
|
);
|
|
2025
2528
|
}
|
|
2529
|
+
|
|
2026
2530
|
const out = studioState(root).snapshotsOf(slug);
|
|
2027
2531
|
await prepareState(root, out);
|
|
2028
2532
|
const shots: Shot[] = [];
|
|
2533
|
+
|
|
2029
2534
|
for (const { address, frame } of frames) {
|
|
2030
2535
|
for (const scheme of COLOR_SCHEMES) {
|
|
2031
2536
|
const shot = await snapshotOf(url, frame, scheme, slug);
|
|
2032
2537
|
const named = `${address.section}/${address.row}/${address.frame}, ${scheme}`;
|
|
2538
|
+
|
|
2033
2539
|
if ("problem" in shot) {
|
|
2034
2540
|
shots.push({ frame: named, problems: [shot.problem] });
|
|
2035
2541
|
continue;
|
|
2036
2542
|
}
|
|
2543
|
+
|
|
2037
2544
|
// The whole address: frame ids are unique only within their row.
|
|
2038
2545
|
const file = join(
|
|
2039
2546
|
out,
|
|
2040
2547
|
`${address.section}--${address.row}--${address.frame}--${scheme}.png`
|
|
2041
2548
|
);
|
|
2549
|
+
|
|
2042
2550
|
await writeFile(file, shot.image);
|
|
2043
2551
|
shots.push({ file, frame: named, problems: shot.problems });
|
|
2044
2552
|
}
|
|
2045
2553
|
}
|
|
2554
|
+
|
|
2046
2555
|
return shots;
|
|
2047
2556
|
}
|
|
2048
2557
|
|
|
@@ -2055,6 +2564,7 @@ const THREAD_USAGE =
|
|
|
2055
2564
|
|
|
2056
2565
|
/** An agent's action before it is signed with the agent's name. */
|
|
2057
2566
|
type UnsignedAction = WithoutAuthor<AgentAction>;
|
|
2567
|
+
|
|
2058
2568
|
/** Each kind of action without its author (Omit, taken one kind at a time). */
|
|
2059
2569
|
type WithoutAuthor<Action> = Action extends unknown
|
|
2060
2570
|
? Omit<Action, "author">
|
|
@@ -2070,21 +2580,27 @@ const threadChange = (values: CommandValues): ThreadChange | undefined => {
|
|
|
2070
2580
|
const flag = (["acknowledge", "resolve", "dismiss"] as const).find(
|
|
2071
2581
|
(name) => values[name]
|
|
2072
2582
|
);
|
|
2583
|
+
|
|
2073
2584
|
const actions: UnsignedAction[] = [];
|
|
2585
|
+
|
|
2074
2586
|
if (flag === "resolve" || flag === "dismiss") {
|
|
2075
2587
|
actions.push({ action: flag, note: values.note });
|
|
2076
2588
|
} else {
|
|
2077
2589
|
if (flag) {
|
|
2078
2590
|
actions.push({ action: flag });
|
|
2079
2591
|
}
|
|
2592
|
+
|
|
2080
2593
|
if (isText(values.note)) {
|
|
2081
2594
|
actions.push({ action: "reply", message: values.note, ask: values.ask });
|
|
2082
2595
|
}
|
|
2083
2596
|
}
|
|
2597
|
+
|
|
2084
2598
|
if (actions.length === 0) {
|
|
2085
2599
|
return;
|
|
2086
2600
|
}
|
|
2601
|
+
|
|
2087
2602
|
const author = values.agent ?? "Agent";
|
|
2603
|
+
|
|
2088
2604
|
return Object.assign(
|
|
2089
2605
|
{},
|
|
2090
2606
|
...actions.map((action) => agentChange({ ...action, author }))
|
|
@@ -2106,29 +2622,41 @@ export function createContentCommands({
|
|
|
2106
2622
|
root?: string;
|
|
2107
2623
|
}) {
|
|
2108
2624
|
const root = content;
|
|
2625
|
+
|
|
2109
2626
|
/** Which Dex serves this checkout, never only the configured port. */
|
|
2110
2627
|
const running = () =>
|
|
2111
2628
|
studioFor({ content, root: projectRoot, port: Number(port) });
|
|
2629
|
+
|
|
2112
2630
|
const presence = openPresence(root);
|
|
2631
|
+
|
|
2113
2632
|
return {
|
|
2114
2633
|
async whoami(): Promise<void> {
|
|
2115
2634
|
const contributor = await joinCurrentPerson(root);
|
|
2635
|
+
|
|
2116
2636
|
if (!contributor) {
|
|
2117
2637
|
print(NOT_RECOGNISED);
|
|
2118
2638
|
process.exitCode = 1;
|
|
2639
|
+
|
|
2119
2640
|
return;
|
|
2120
2641
|
}
|
|
2642
|
+
|
|
2121
2643
|
print(
|
|
2122
2644
|
`${contributor.slug} (${contributor.name}, ${contributor.discipline})`
|
|
2123
2645
|
);
|
|
2124
2646
|
},
|
|
2125
2647
|
async new(values: CommandValues): Promise<void> {
|
|
2126
2648
|
// Yours unless an agent names another contributor.
|
|
2127
|
-
|
|
2128
|
-
|
|
2649
|
+
let person = values.person ?? values.owner;
|
|
2650
|
+
|
|
2651
|
+
if (person === undefined) {
|
|
2652
|
+
const joined = await joinCurrentPerson(root);
|
|
2653
|
+
person = joined?.slug;
|
|
2654
|
+
}
|
|
2655
|
+
|
|
2129
2656
|
if (!person) {
|
|
2130
2657
|
throw new Error(NOT_RECOGNISED);
|
|
2131
2658
|
}
|
|
2659
|
+
|
|
2132
2660
|
const { folder, slug } = await createPrototype(
|
|
2133
2661
|
{
|
|
2134
2662
|
title: values.title,
|
|
@@ -2138,6 +2666,7 @@ export function createContentCommands({
|
|
|
2138
2666
|
},
|
|
2139
2667
|
root
|
|
2140
2668
|
);
|
|
2669
|
+
|
|
2141
2670
|
const canvas = prototypePage(slug, "canvas");
|
|
2142
2671
|
print(`Created ${display(folder)}`);
|
|
2143
2672
|
const found = await running();
|
|
@@ -2157,12 +2686,15 @@ export function createContentCommands({
|
|
|
2157
2686
|
async check(unresolved: string[] = []): Promise<void> {
|
|
2158
2687
|
const { problems, warnings } = await checkStudio(root, { designSystem });
|
|
2159
2688
|
problems.push(...unresolved);
|
|
2689
|
+
|
|
2160
2690
|
for (const warning of warnings) {
|
|
2161
2691
|
print(`! ${warning}`);
|
|
2162
2692
|
}
|
|
2693
|
+
|
|
2163
2694
|
if (problems.length > 0) {
|
|
2164
2695
|
throw new Error(`Dex check failed:\n - ${problems.join("\n - ")}`);
|
|
2165
2696
|
}
|
|
2697
|
+
|
|
2166
2698
|
print(
|
|
2167
2699
|
warnings.length > 0
|
|
2168
2700
|
? `Dex check passed, with ${warnings.length} warning${warnings.length === 1 ? "" : "s"} (the lines with !).`
|
|
@@ -2170,26 +2702,34 @@ export function createContentCommands({
|
|
|
2170
2702
|
);
|
|
2171
2703
|
},
|
|
2172
2704
|
async snapshot(values: CommandValues): Promise<void> {
|
|
2173
|
-
let url = values
|
|
2705
|
+
let { url } = values;
|
|
2706
|
+
|
|
2174
2707
|
if (!url) {
|
|
2175
2708
|
const found = await running();
|
|
2709
|
+
|
|
2176
2710
|
if (found.kind !== "running") {
|
|
2177
2711
|
throw new Error(notRunning(found));
|
|
2178
2712
|
}
|
|
2713
|
+
|
|
2179
2714
|
url = found.url;
|
|
2180
2715
|
}
|
|
2716
|
+
|
|
2181
2717
|
const shots = await snapshot({ ...values, url }, root);
|
|
2182
2718
|
let problems = 0;
|
|
2719
|
+
|
|
2183
2720
|
for (const shot of shots) {
|
|
2184
2721
|
print(shot.file ? display(shot.file) : shot.frame);
|
|
2722
|
+
|
|
2185
2723
|
for (const problem of shot.problems) {
|
|
2186
2724
|
problems += 1;
|
|
2187
2725
|
print(` ! ${problem}`);
|
|
2188
2726
|
}
|
|
2189
2727
|
}
|
|
2728
|
+
|
|
2190
2729
|
print(
|
|
2191
2730
|
`${shots.length} snapshots. Open each one and look before you call the work done.`
|
|
2192
2731
|
);
|
|
2732
|
+
|
|
2193
2733
|
if (problems > 0) {
|
|
2194
2734
|
process.exitCode = 1;
|
|
2195
2735
|
}
|
|
@@ -2199,6 +2739,7 @@ export function createContentCommands({
|
|
|
2199
2739
|
(values.view && `view:${values.view}`) ||
|
|
2200
2740
|
(values.doc && `doc:${values.doc}`) ||
|
|
2201
2741
|
(values.slug ? "prototype" : undefined);
|
|
2742
|
+
|
|
2202
2743
|
if (values.clear) {
|
|
2203
2744
|
await presence.clear({
|
|
2204
2745
|
slug: values.slug,
|
|
@@ -2206,13 +2747,16 @@ export function createContentCommands({
|
|
|
2206
2747
|
agent: values.agent,
|
|
2207
2748
|
});
|
|
2208
2749
|
print("Presence cleared.");
|
|
2750
|
+
|
|
2209
2751
|
return;
|
|
2210
2752
|
}
|
|
2753
|
+
|
|
2211
2754
|
if (!(isSlug(values.slug) && target)) {
|
|
2212
2755
|
throw new Error(
|
|
2213
2756
|
'Usage: npx dex presence --slug <file> [--view <name> | --doc <name>] [--agent "<name>"] [--note "<what>"] [--clear]'
|
|
2214
2757
|
);
|
|
2215
2758
|
}
|
|
2759
|
+
|
|
2216
2760
|
await presence.mark({
|
|
2217
2761
|
slug: values.slug,
|
|
2218
2762
|
target,
|
|
@@ -2224,57 +2768,77 @@ export function createContentCommands({
|
|
|
2224
2768
|
/** Prints the threads waiting for an agent, or all, and returns them. */
|
|
2225
2769
|
async threads(values: CommandValues) {
|
|
2226
2770
|
const threads = openThreads(root);
|
|
2771
|
+
|
|
2227
2772
|
const listed = await threads.list({
|
|
2228
|
-
...(values.slug
|
|
2773
|
+
...(values.slug && { prototype: values.slug }),
|
|
2229
2774
|
status: values.all ? "all" : "waiting",
|
|
2230
2775
|
});
|
|
2776
|
+
|
|
2231
2777
|
if (listed.length === 0) {
|
|
2232
2778
|
print(
|
|
2233
2779
|
values.all ? "No comments yet." : "No comments waiting for an agent."
|
|
2234
2780
|
);
|
|
2781
|
+
|
|
2235
2782
|
return [];
|
|
2236
2783
|
}
|
|
2784
|
+
|
|
2237
2785
|
// Each with its file's title beside its name: a folder may be an id.
|
|
2238
2786
|
const titleOf = await prototypeTitles(root, listed);
|
|
2787
|
+
|
|
2239
2788
|
const described = listed.map((thread) => {
|
|
2240
2789
|
const { id, prototype, ...rest } = describeThread(thread);
|
|
2241
2790
|
const fileTitle = titleOf(thread);
|
|
2242
|
-
|
|
2791
|
+
|
|
2792
|
+
return { id, prototype, ...(fileTitle && { fileTitle }), ...rest };
|
|
2243
2793
|
});
|
|
2794
|
+
|
|
2244
2795
|
print(JSON.stringify(described, null, 2));
|
|
2796
|
+
|
|
2245
2797
|
return described;
|
|
2246
2798
|
},
|
|
2247
2799
|
async thread(values: CommandValues): Promise<void> {
|
|
2248
2800
|
const change = threadChange(values);
|
|
2801
|
+
|
|
2249
2802
|
if (!(values.id && change)) {
|
|
2250
2803
|
throw new Error(THREAD_USAGE);
|
|
2251
2804
|
}
|
|
2805
|
+
|
|
2252
2806
|
const answered = await openThreads(root).change(values.id, change);
|
|
2807
|
+
|
|
2253
2808
|
if (!answered) {
|
|
2254
2809
|
throw new Error(THREAD_USAGE);
|
|
2255
2810
|
}
|
|
2811
|
+
|
|
2256
2812
|
if (answered.problems) {
|
|
2257
2813
|
throw new Error(answered.problems.join(" "));
|
|
2258
2814
|
}
|
|
2815
|
+
|
|
2259
2816
|
print(`Updated ${values.id}.`);
|
|
2260
2817
|
},
|
|
2261
2818
|
scope(values: CommandValues): void {
|
|
2262
2819
|
const person = values.person ?? values.owner;
|
|
2820
|
+
|
|
2263
2821
|
if (!isSlug(person)) {
|
|
2264
2822
|
throw new Error("Usage: npx dex scope --person <slug> [--base main]");
|
|
2265
2823
|
}
|
|
2824
|
+
|
|
2266
2825
|
const outside = outOfScope(
|
|
2267
2826
|
changedFiles(values.base ?? "main", root),
|
|
2268
2827
|
allowedPrefixes(person, root)
|
|
2269
2828
|
);
|
|
2829
|
+
|
|
2270
2830
|
if (outside.length === 0) {
|
|
2271
2831
|
print(`All changes are inside ${person}'s scope.`);
|
|
2832
|
+
|
|
2272
2833
|
return;
|
|
2273
2834
|
}
|
|
2835
|
+
|
|
2274
2836
|
print(`Changes outside ${person}'s scope (need studio review):`);
|
|
2837
|
+
|
|
2275
2838
|
for (const file of outside) {
|
|
2276
2839
|
print(` ${file}`);
|
|
2277
2840
|
}
|
|
2841
|
+
|
|
2278
2842
|
process.exitCode = 1;
|
|
2279
2843
|
},
|
|
2280
2844
|
};
|