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