@dexhq/canvas 0.14.0 → 0.16.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 +70 -0
- package/README.md +5 -3
- package/app/canvas/activity-parts.tsx +50 -6
- package/app/canvas/activity.tsx +10 -18
- package/app/canvas/agent-changes.ts +18 -8
- package/app/canvas/anchoring.ts +15 -7
- package/app/canvas/canvas-context.tsx +6 -2
- package/app/canvas/canvas-input.ts +186 -14
- package/app/canvas/canvas-keys.ts +9 -0
- package/app/canvas/canvas-model.ts +7 -44
- package/app/canvas/canvas-panels.ts +1 -17
- package/app/canvas/canvas-scene.ts +250 -27
- package/app/canvas/canvas-ui.ts +13 -3
- package/app/canvas/canvas.css +147 -29
- package/app/canvas/change-notice.tsx +10 -1
- package/app/canvas/comment-layer.tsx +2 -1
- package/app/canvas/comments.tsx +270 -111
- package/app/canvas/element-link.ts +135 -0
- package/app/canvas/element-picker.ts +223 -27
- package/app/canvas/engine/canvas-gestures.ts +72 -17
- package/app/canvas/engine/canvas-store.ts +17 -1
- package/app/canvas/engine/engine.css +6 -3
- package/app/canvas/export-dialog.tsx +265 -0
- package/app/canvas/find-bar.tsx +817 -0
- package/app/canvas/find-model.ts +135 -0
- package/app/canvas/flow-canvas.tsx +83 -16
- package/app/canvas/follow-pin.ts +26 -6
- package/app/canvas/frame-context-menu.tsx +61 -7
- package/app/canvas/frame-node.tsx +19 -20
- package/app/canvas/imported-reviews.tsx +12 -22
- package/app/canvas/layout.ts +68 -22
- package/app/canvas/linked-element.tsx +196 -0
- package/app/canvas/live-page.ts +156 -19
- package/app/canvas/mentions.tsx +209 -0
- package/app/canvas/page-find.ts +220 -0
- package/app/canvas/page-style.ts +23 -0
- package/app/canvas/picked-box.tsx +21 -0
- package/app/canvas/removed-views-panel.tsx +4 -4
- package/app/canvas/request-node.tsx +151 -0
- package/app/canvas/review-panel.tsx +8 -3
- package/app/canvas/section-node.tsx +6 -133
- package/app/canvas/spec-margin.tsx +4 -1
- package/app/canvas/spec-threads.ts +24 -23
- package/app/canvas/teammates-layer.tsx +205 -0
- package/app/canvas/text-layer.tsx +103 -17
- package/app/canvas/thread-focus.tsx +14 -12
- package/app/canvas/tool-cursors.ts +7 -6
- package/app/canvas/tool-icons.tsx +24 -56
- package/app/canvas/typing.ts +12 -0
- package/app/canvas/use-activity.ts +0 -8
- package/app/canvas/use-agent-changes.tsx +40 -42
- package/app/canvas/use-canvas-clipboard.tsx +11 -14
- package/app/canvas/use-canvas-editor.ts +4 -2
- package/app/canvas/xray.ts +3 -12
- package/app/export/player-model.ts +159 -0
- package/app/export/player.tsx +198 -0
- package/app/export.html +31 -0
- package/app/export.tsx +9 -0
- package/app/frame/announce-refreshes.ts +21 -0
- package/app/frame/start-frame.tsx +50 -0
- package/app/frame/view-loads.ts +161 -0
- package/app/frame/views.ts +13 -49
- package/app/frame.tsx +2 -33
- package/app/i18n/locales/en/messages.po +233 -14
- package/app/i18n/locales/en/messages.ts +1 -1
- package/app/i18n/locales/pseudo/messages.po +232 -13
- package/app/i18n/locales/pseudo/messages.ts +1 -1
- package/app/icons/dex-glyphs.tsx +219 -0
- package/app/icons/glyphs.tsx +80 -80
- package/app/kit/use-flow.ts +2 -1
- package/app/live/canvas-teammates.ts +90 -0
- package/app/live/studio-api.ts +30 -20
- package/app/main.tsx +3 -0
- package/app/pages/canvas.tsx +45 -14
- package/app/pages/commands-settings.tsx +17 -3
- package/app/pages/render.tsx +39 -11
- package/app/shell/bell.tsx +15 -5
- package/app/shell/feedback-form.tsx +10 -21
- package/app/shell/feedback-link.tsx +2 -1
- package/app/shell/presence.tsx +123 -26
- package/app/shell/scaled-frame.tsx +21 -9
- package/app/shell/thread-list.tsx +25 -8
- package/app/shell/working-on.tsx +35 -3
- package/app/types.ts +21 -205
- package/app/ui/file-drop.ts +128 -0
- package/app/ui/prompt-editor.tsx +39 -11
- package/app/ui/reference.tsx +21 -8
- package/app/ui/shadcn/input-group.tsx +2 -2
- package/bin/sudio.mjs +1 -1
- package/dist/cli/banner.d.mts +4 -2
- package/dist/cli/banner.mjs +34 -11
- package/dist/cli/commands/app.mjs +19 -11
- package/dist/cli/commands/create.d.mts +5 -5
- package/dist/cli/commands/create.mjs +4 -4
- package/dist/cli/commands/export.d.mts +40 -0
- package/dist/cli/commands/export.mjs +66 -0
- package/dist/cli/commands/hook.mjs +2 -1
- package/dist/cli/commands/init.d.mts +2 -2
- package/dist/cli/commands/upgrade.mjs +1 -1
- package/dist/cli/help.d.mts +1 -1
- package/dist/cli/help.mjs +13 -7
- package/dist/cli/main.d.mts +42 -5
- package/dist/cli/main.mjs +1 -0
- package/dist/config/load.mjs +14 -2
- package/dist/config/project-files.d.mts +11 -0
- package/dist/config/project-files.mjs +23 -2
- package/dist/config/renamed.d.mts +7 -2
- package/dist/config/renamed.mjs +13 -3
- package/dist/content/capture.d.mts +2 -2
- package/dist/content/capture.mjs +2 -2
- package/dist/content/commands.d.mts +11 -9
- package/dist/content/commands.mjs +22 -16
- package/dist/content/comments-log.mjs +2 -1
- package/dist/content/content.d.mts +13 -143
- package/dist/content/content.mjs +55 -76
- package/dist/content/element-words.d.mts +42 -0
- package/dist/content/element-words.mjs +112 -0
- package/dist/content/flow-specs.mjs +1 -1
- package/dist/content/hosted-person.d.mts +31 -0
- package/dist/content/hosted-person.mjs +68 -0
- package/dist/content/merge-rules.d.mts +5 -0
- package/dist/content/merge-rules.mjs +17 -1
- package/dist/content/prototype-summary.d.mts +3 -39
- package/dist/content/prototype-summary.mjs +2 -3
- package/dist/content/prototypes.mjs +1 -1
- package/dist/content/screenshot.mjs +9 -0
- package/dist/content/text-edit.d.mts +24 -14
- package/dist/content/text-edit.mjs +92 -81
- package/dist/content/text-replace.d.mts +30 -0
- package/dist/content/text-replace.mjs +285 -0
- package/dist/content/thread-module.d.mts +2 -4
- package/dist/content/thread-module.mjs +4 -5
- package/dist/content/threads.mjs +1 -1
- package/dist/paste/paste.mjs +1 -1
- package/dist/paths.d.mts +0 -2
- package/dist/paths.mjs +1 -3
- package/dist/server/agent-env.d.mts +5 -1
- package/dist/server/agent-env.mjs +7 -2
- package/dist/server/agent-session.d.mts +14 -1
- package/dist/server/agent-session.mjs +84 -19
- package/dist/server/agents.d.mts +10 -0
- package/dist/server/agents.mjs +21 -6
- package/dist/server/build-pictures.mjs +1 -1
- package/dist/server/canvas-presence.d.mts +22 -0
- package/dist/server/canvas-presence.mjs +160 -0
- package/dist/server/channel.d.mts +13 -24
- package/dist/server/channel.mjs +55 -37
- package/dist/server/claimed-presence.d.mts +3 -2
- package/dist/server/claimed-presence.mjs +15 -7
- package/dist/server/close-check.mjs +2 -2
- package/dist/server/command-settings.mjs +1 -1
- package/dist/server/comments/actions.d.mts +145 -0
- package/dist/server/comments/actions.mjs +146 -0
- package/dist/server/comments/routes.d.mts +25 -0
- package/dist/server/comments/routes.mjs +67 -0
- package/dist/server/comments/tools.d.mts +6 -0
- package/dist/server/comments/tools.mjs +154 -0
- package/dist/server/dev-server.mjs +59 -23
- package/dist/server/export/build.d.mts +15 -0
- package/dist/server/export/build.mjs +220 -0
- package/dist/server/export/page.d.mts +25 -0
- package/dist/server/export/page.mjs +40 -0
- package/dist/server/export/plugin.d.mts +31 -0
- package/dist/server/export/plugin.mjs +69 -0
- package/dist/server/export/run.d.mts +9 -0
- package/dist/server/export/run.mjs +61 -0
- package/dist/server/export/save.d.mts +7 -0
- package/dist/server/export/save.mjs +29 -0
- package/dist/server/file-lock.d.mts +2 -2
- package/dist/server/file-lock.mjs +130 -36
- package/dist/server/hosted.d.mts +8 -0
- package/dist/server/hosted.mjs +78 -0
- package/dist/server/live-mirror.mjs +66 -10
- package/dist/server/live.mjs +28 -1
- package/dist/server/mcp.d.mts +0 -2
- package/dist/server/mcp.mjs +9 -8
- package/dist/server/me.d.mts +3 -1
- package/dist/server/me.mjs +8 -2
- package/dist/server/notices.d.mts +1 -1
- package/dist/server/notices.mjs +1 -1
- package/dist/server/open-page.d.mts +22 -0
- package/dist/server/open-page.mjs +20 -2
- package/dist/server/outcome.d.mts +22 -0
- package/dist/server/outcome.mjs +8 -0
- package/dist/server/own-copies.mjs +1 -1
- package/dist/server/people.d.mts +8 -3
- package/dist/server/people.mjs +6 -2
- package/dist/server/pictures.d.mts +1 -1
- package/dist/server/pictures.mjs +2 -2
- package/dist/server/port.d.mts +12 -0
- package/dist/server/port.mjs +66 -14
- package/dist/server/prebundle.d.mts +32 -0
- package/dist/server/prebundle.mjs +115 -0
- package/dist/server/presence.d.mts +4 -1
- package/dist/server/presence.mjs +2 -2
- package/dist/server/problems.d.mts +8 -0
- package/dist/server/problems.mjs +13 -0
- package/dist/server/requests.d.mts +5 -1
- package/dist/server/requests.mjs +76 -78
- package/dist/server/source-stamp.d.mts +4 -3
- package/dist/server/source-stamp.mjs +60 -31
- package/dist/server/state.d.mts +19 -10
- package/dist/server/state.mjs +27 -18
- package/dist/server/studio-for.d.mts +5 -0
- package/dist/server/studio-for.mjs +17 -3
- package/dist/server/sync-install.d.mts +8 -12
- package/dist/server/sync-install.mjs +12 -30
- package/dist/server/thread-source.d.mts +8 -0
- package/dist/server/thread-source.mjs +25 -6
- package/dist/server/tools/describe.d.mts +1 -1
- package/dist/server/tools/describe.mjs +1 -1
- package/dist/server/tools/export.d.mts +5 -0
- package/dist/server/tools/export.mjs +35 -0
- package/dist/server/tools/feedback.d.mts +1 -1
- package/dist/server/tools/place-frame.mjs +16 -16
- package/dist/server/tools/reading.mjs +13 -4
- package/dist/server/tools/show.d.mts +1 -1
- package/dist/server/tools/snapshot.d.mts +1 -1
- package/dist/server/tools/thread-list.mjs +2 -2
- package/dist/server/tools/watch.mjs +5 -3
- package/dist/server/vite.d.mts +9 -4
- package/dist/server/vite.mjs +65 -63
- package/dist/server/web-app.mjs +4 -7
- package/dist/server/welcome.mjs +2 -1
- package/dist/server/work-groups.mjs +1 -1
- package/dist/setup/apply.d.mts +4 -0
- package/dist/setup/apply.mjs +5 -4
- package/dist/setup/create.d.mts +4 -2
- package/dist/setup/create.mjs +72 -22
- package/dist/setup/design-system-checks.mjs +3 -17
- package/dist/setup/desktop-app-script.mjs +4 -3
- package/dist/setup/desktop-app-start.d.mts +8 -2
- package/dist/setup/desktop-app-start.mjs +64 -29
- package/dist/setup/desktop-app.d.mts +8 -0
- package/dist/setup/desktop-app.mjs +19 -3
- package/dist/setup/detect/workspace.d.mts +10 -10
- package/dist/setup/detect/workspace.mjs +10 -12
- package/dist/setup/detect.d.mts +0 -2
- package/dist/setup/detect.mjs +1 -3
- package/dist/setup/doctor.d.mts +4 -1
- package/dist/setup/doctor.mjs +8 -6
- package/dist/setup/migrate/dex-folder.d.mts +61 -0
- package/dist/setup/migrate/dex-folder.mjs +544 -0
- package/dist/setup/migrate/files-folder.mjs +1 -1
- package/dist/setup/migrate/guides.mjs +1 -1
- package/dist/setup/migrate/migrations.mjs +4 -0
- package/dist/setup/migrate/row-titles.mjs +1 -1
- package/dist/setup/migrate/setup-files.d.mts +5 -0
- package/dist/setup/migrate/setup-files.mjs +115 -0
- package/dist/setup/migrate/studio-state.d.mts +2 -2
- package/dist/setup/migrate/studio-state.mjs +4 -4
- package/dist/setup/placement.d.mts +1 -1
- package/dist/setup/placement.mjs +5 -4
- package/dist/setup/plan.d.mts +5 -5
- package/dist/setup/plan.mjs +8 -12
- package/dist/setup/project.d.mts +6 -1
- package/dist/setup/project.mjs +10 -10
- package/dist/setup/prompts.d.mts +2 -1
- package/dist/setup/prompts.mjs +4 -3
- package/dist/setup/questions.mjs +3 -2
- package/dist/setup/starters.d.mts +3 -1
- package/dist/setup/starters.mjs +9 -3
- package/dist/setup/write.d.mts +15 -3
- package/dist/setup/write.mjs +23 -3
- package/dist/shared/annotations-core.mjs +1 -1
- package/dist/shared/canvas-core.d.mts +22 -7
- package/dist/shared/canvas-core.mjs +39 -11
- package/dist/shared/canvas-file.d.mts +201 -0
- package/dist/shared/canvas-file.mjs +1 -0
- package/dist/shared/comments/routes.d.mts +55 -0
- package/dist/shared/comments/routes.mjs +39 -0
- package/dist/shared/export-core.d.mts +62 -0
- package/dist/shared/export-core.mjs +101 -0
- package/dist/shared/feedback.d.mts +8 -0
- package/dist/shared/feedback.mjs +10 -2
- package/dist/shared/live-core.d.mts +2 -0
- package/dist/shared/live-core.mjs +6 -1
- package/dist/shared/live-presence.d.mts +57 -2
- package/dist/shared/live-presence.mjs +90 -4
- package/dist/shared/page-messages.d.mts +14 -1
- package/dist/shared/page-messages.mjs +30 -3
- package/dist/shared/page-review.d.mts +2 -11
- package/dist/shared/page-review.mjs +4 -13
- package/dist/shared/people-core.d.mts +28 -0
- package/dist/shared/people-core.mjs +27 -1
- package/dist/shared/presence-core.d.mts +13 -0
- package/dist/shared/presence-core.mjs +11 -2
- package/dist/shared/references-core.d.mts +4 -0
- package/dist/shared/references-core.mjs +12 -4
- package/dist/shared/review-file.d.mts +5 -0
- package/dist/shared/review-file.mjs +23 -13
- package/dist/shared/server-page.mjs +1 -1
- package/dist/shared/signup.d.mts +2 -5
- package/dist/shared/signup.mjs +2 -35
- package/dist/shared/studio-events.d.mts +0 -6
- package/dist/shared/studio-events.mjs +1 -5
- package/dist/shared/studio-files.d.mts +21 -0
- package/dist/shared/studio-files.mjs +16 -2
- package/dist/shared/studio-routes.d.mts +29 -63
- package/dist/shared/studio-routes.mjs +1 -69
- package/dist/shared/threads-core.d.mts +29 -6
- package/dist/shared/threads-core.mjs +68 -13
- package/extension/dist/feedback.js +104 -284
- package/extension/dist/manifest.json +1 -1
- package/extension/dist/picker.js +104 -284
- package/package.json +2 -2
- package/src/cli/banner.ts +45 -11
- package/src/cli/commands/app.ts +23 -8
- package/src/cli/commands/create.ts +4 -4
- package/src/cli/commands/export.ts +78 -0
- package/src/cli/commands/hook.ts +4 -1
- package/src/cli/commands/upgrade.ts +1 -1
- package/src/cli/help.ts +13 -7
- package/src/cli/main.ts +1 -0
- package/src/config/load.ts +26 -2
- package/src/config/project-files.ts +36 -6
- package/src/config/renamed.ts +19 -4
- package/src/content/capture.ts +6 -12
- package/src/content/commands.ts +30 -18
- package/src/content/comments-log.ts +4 -1
- package/src/content/content.ts +71 -257
- package/src/content/element-words.ts +175 -0
- package/src/content/flow-specs.ts +2 -1
- package/src/content/hosted-person.ts +107 -0
- package/src/content/merge-rules.ts +29 -0
- package/src/content/prototype-summary.ts +4 -44
- package/src/content/review-pages.ts +2 -1
- package/src/content/screenshot.ts +14 -0
- package/src/content/text-edit.ts +172 -105
- package/src/content/text-replace.ts +420 -0
- package/src/content/thread-module.ts +2 -4
- package/src/content/trash.ts +1 -1
- package/src/paths.ts +0 -8
- package/src/server/agent-env.ts +12 -2
- package/src/server/agent-session.ts +124 -34
- package/src/server/agents.ts +48 -17
- package/src/server/canvas-presence.ts +237 -0
- package/src/server/channel.ts +95 -53
- package/src/server/claimed-presence.ts +26 -10
- package/src/server/command-settings.ts +1 -1
- package/src/server/comments/actions.ts +333 -0
- package/src/server/comments/routes.ts +131 -0
- package/src/server/comments/tools.ts +317 -0
- package/src/server/dev-server.ts +94 -33
- package/src/server/export/build.ts +310 -0
- package/src/server/export/page.ts +85 -0
- package/src/server/export/plugin.ts +138 -0
- package/src/server/export/run.ts +79 -0
- package/src/server/export/save.ts +38 -0
- package/src/server/file-lock.ts +205 -54
- package/src/server/hosted.ts +113 -0
- package/src/server/live-mirror.ts +93 -8
- package/src/server/live.ts +46 -1
- package/src/server/machine-update.ts +3 -3
- package/src/server/mcp.ts +15 -14
- package/src/server/me.ts +12 -6
- package/src/server/notices.ts +2 -2
- package/src/server/open-page.ts +54 -4
- package/src/server/outcome.ts +26 -0
- package/src/server/people.ts +13 -3
- package/src/server/pictures.ts +2 -2
- package/src/server/port.ts +94 -20
- package/src/server/prebundle.ts +230 -0
- package/src/server/presence.ts +12 -4
- package/src/server/problems.ts +11 -0
- package/src/server/requests.ts +115 -110
- package/src/server/roster.ts +1 -1
- package/src/server/saved.ts +1 -1
- package/src/server/source-stamp.ts +118 -37
- package/src/server/state.ts +53 -31
- package/src/server/studio-for.ts +26 -2
- package/src/server/sync-install.ts +35 -26
- package/src/server/thread-place.ts +2 -4
- package/src/server/thread-source.ts +35 -3
- package/src/server/tools/export.ts +56 -0
- package/src/server/tools/place-frame.ts +23 -15
- package/src/server/tools/reading.ts +16 -3
- package/src/server/tools/thread-list.ts +1 -1
- package/src/server/tools/watch.ts +7 -7
- package/src/server/updates.ts +2 -2
- package/src/server/vite.ts +106 -110
- package/src/server/web-app.ts +11 -9
- package/src/server/welcome.ts +3 -1
- package/src/setup/apply.ts +8 -5
- package/src/setup/create.ts +101 -27
- package/src/setup/design-system-checks.ts +8 -21
- package/src/setup/desktop-app-script.ts +4 -3
- package/src/setup/desktop-app-start.ts +94 -26
- package/src/setup/desktop-app.ts +23 -2
- package/src/setup/detect/workspace.ts +20 -21
- package/src/setup/detect.ts +0 -4
- package/src/setup/doctor.ts +13 -6
- package/src/setup/migrate/dex-folder.ts +842 -0
- package/src/setup/migrate/files-folder.ts +1 -1
- package/src/setup/migrate/guides.ts +3 -1
- package/src/setup/migrate/migrations.ts +8 -2
- package/src/setup/migrate/setup-files.ts +198 -0
- package/src/setup/migrate/studio-state.ts +12 -10
- package/src/setup/own-app.ts +1 -1
- package/src/setup/placement.ts +7 -6
- package/src/setup/plan.ts +13 -18
- package/src/setup/project.ts +11 -10
- package/src/setup/prompts.ts +5 -4
- package/src/setup/questions.ts +6 -3
- package/src/setup/starters.ts +11 -4
- package/src/setup/write.ts +34 -3
- package/src/shared/canvas-core.ts +48 -9
- package/src/shared/canvas-file.ts +205 -0
- package/src/shared/comments/routes.ts +81 -0
- package/src/shared/export-core.ts +198 -0
- package/src/shared/feedback.ts +14 -4
- package/src/shared/live-core.ts +8 -0
- package/src/shared/live-presence.ts +171 -2
- package/src/shared/page-messages.ts +38 -2
- package/src/shared/page-review.ts +11 -16
- package/src/shared/people-core.ts +44 -0
- package/src/shared/presence-core.ts +18 -2
- package/src/shared/references-core.ts +22 -3
- package/src/shared/review-file.ts +28 -12
- package/src/shared/server-page.ts +2 -1
- package/src/shared/signup.ts +4 -28
- package/src/shared/studio-events.ts +0 -13
- package/src/shared/studio-files.ts +29 -1
- package/src/shared/studio-routes.ts +32 -65
- package/src/shared/threads-core.ts +134 -12
- package/templates/methods/explore.md +1 -1
- package/templates/methods/handoff.md +1 -1
- package/templates/methods/review.md +2 -1
- package/templates/rules/canvas-frames.md +6 -3
- package/templates/rules/commands.md +1 -0
- package/templates/rules/prototypes.md +1 -1
- package/templates/rules/studio.md +17 -11
- package/templates/skills/comprehend/SKILL.md +56 -0
- package/templates/skills/distill/SKILL.md +172 -0
- package/templates/skills/export-prototype/SKILL.md +35 -0
- package/templates/skills/riff/SKILL.md +21 -0
- package/templates/skills/riff-deep/SKILL.md +40 -0
- package/templates/skills/riff-max/SKILL.md +46 -0
- package/templates/skills/riff-state/SKILL.md +45 -0
- package/templates/skills/riff-up/SKILL.md +38 -0
- package/templates/skills/riff-wide/SKILL.md +40 -0
- package/templates/starters/standalone/README.md +1 -1
- package/templates/starters/turborepo/README.md +2 -2
- package/templates/starters/turborepo/apps/web/src/app.tsx +2 -2
- package/templates/starters/vite/README.md +1 -1
- package/dist/server/tools/close-reply.d.mts +0 -6
- package/dist/server/tools/close-reply.mjs +0 -138
- package/dist/server/tools/comment.d.mts +0 -6
- package/dist/server/tools/comment.mjs +0 -49
- package/src/server/tools/close-reply.ts +0 -271
- package/src/server/tools/comment.ts +0 -96
package/dist/server/vite.mjs
CHANGED
|
@@ -1,31 +1,34 @@
|
|
|
1
|
-
import { APP_DIR, PACKAGE_ROOT } from "../paths.mjs";
|
|
1
|
+
import { APP_DIR, PACKAGE_ROOT, posix as posix$1 } from "../paths.mjs";
|
|
2
2
|
import { ME_META } from "../shared/studio-routes.mjs";
|
|
3
|
+
import { publicThreads } from "../shared/threads-core.mjs";
|
|
3
4
|
import { legacyState, prepareOutput, prepareState, studioOutput, studioState } from "./state.mjs";
|
|
4
5
|
import { prototypesDir } from "../content/prototypes.mjs";
|
|
5
6
|
import { renamedNotice } from "../config/renamed.mjs";
|
|
6
7
|
import { canImport, dependenciesOf, projectAliases, projectBaseUrl, resolveAlias, tailwind3Config, tailwindSetup } from "../config/project-files.mjs";
|
|
7
8
|
import { forInterface } from "../config/design-system.mjs";
|
|
8
|
-
import { publicThreads } from "../shared/threads-core.mjs";
|
|
9
9
|
import { CloudError } from "./cloud.mjs";
|
|
10
10
|
import { features } from "./features.mjs";
|
|
11
11
|
import { openThreads } from "../content/thread-module.mjs";
|
|
12
|
+
import { readMe } from "./me.mjs";
|
|
12
13
|
import { WORKSPACE_META, workspaceName } from "../shared/workspace.mjs";
|
|
13
14
|
import { EXAMPLE_FILES, OLD_EXAMPLE_FILES, findConfigFile } from "../config/load.mjs";
|
|
14
15
|
import { componentFileProps, withConfiguredProps } from "../content/component-props.mjs";
|
|
15
16
|
import { prepareContent } from "../content/first-run.mjs";
|
|
16
17
|
import { lacksNext, next } from "./next.mjs";
|
|
17
18
|
import { readBuildSettings } from "./build-settings.mjs";
|
|
18
|
-
import {
|
|
19
|
+
import { canvasPresence } from "./canvas-presence.mjs";
|
|
19
20
|
import { findWorkspaceIcon, readWorkspace, workspaceIconBytes } from "./workspace-settings.mjs";
|
|
20
21
|
import { studioDev } from "./dev-server.mjs";
|
|
21
22
|
import { fileErrors } from "./file-errors.mjs";
|
|
23
|
+
import { hostedPeople } from "./hosted.mjs";
|
|
24
|
+
import { interfaceDependencies, prebundleViews } from "./prebundle.mjs";
|
|
22
25
|
import { projectPublic } from "./project-public.mjs";
|
|
23
26
|
import { sourceStamp } from "./source-stamp.mjs";
|
|
24
27
|
import { studioWebApp } from "./web-app.mjs";
|
|
25
28
|
import { createRequire } from "node:module";
|
|
26
29
|
import { existsSync, readFileSync } from "node:fs";
|
|
27
30
|
import { basename, dirname, isAbsolute, join, relative, resolve, sep } from "node:path";
|
|
28
|
-
import { readFile,
|
|
31
|
+
import { readFile, rm, writeFile } from "node:fs/promises";
|
|
29
32
|
import { normalizePath, searchForWorkspaceRoot } from "vite";
|
|
30
33
|
import { makeConfig } from "@lingui/conf";
|
|
31
34
|
import tailwindcss from "@tailwindcss/vite";
|
|
@@ -33,12 +36,6 @@ import react from "@vitejs/plugin-react";
|
|
|
33
36
|
//#region src/server/vite.ts
|
|
34
37
|
const ENTRY_CSS_RE = /^@studio-entry\.css$/;
|
|
35
38
|
const FRAME_CSS_RE = /^@studio-frame\.css$/;
|
|
36
|
-
const SOURCE_FILE_RE = /\.(?:ts|tsx)$/;
|
|
37
|
-
const TEST_FILE_RE = /\.(?:test|bench)\./;
|
|
38
|
-
const TEST_SUPPORT_DIR = "testing";
|
|
39
|
-
const BARE_IMPORT_RE = /^\s*import\s+(?!type\s)[^"';]*?from\s+["']([^"'./][^"']*)["']|import\(\s*["']([^"'./][^"']*)["']\s*\)/gm;
|
|
40
|
-
const SIDE_EFFECT_IMPORT_RE = /^\s*import\s+["']([^"'./][^"']*)["']/gm;
|
|
41
|
-
const OWN_ALIASES = ["@studio"];
|
|
42
39
|
const INTERFACE_COMPONENT_RE = /^@studio\/ui\/shadcn\/([a-z-]+)$/;
|
|
43
40
|
const INTERFACE_COMPONENT = "studio-interface-component:";
|
|
44
41
|
const PACKAGED_COMPONENTS = join(APP_DIR, "ui", "shadcn");
|
|
@@ -146,76 +143,79 @@ function componentsRoot(project) {
|
|
|
146
143
|
if (!path || path.startsWith("..") || isAbsolute(path) || folder.split(sep).includes("node_modules")) return folder;
|
|
147
144
|
return join(home, path.split(sep)[0] ?? "");
|
|
148
145
|
}
|
|
146
|
+
/** A stylesheet's imports, as `@import` lines relative to `dir`. */
|
|
147
|
+
const importLines = (dir, entries) => entries.map(({ entry, layer }) => {
|
|
148
|
+
return `@import "${isAbsolute(entry) ? posixFrom(dir, entry) : entry}"${layer ? ` layer(${layer})` : ""};`;
|
|
149
|
+
});
|
|
150
|
+
const posixFrom = (dir, path) => posix$1(relative(dir, path));
|
|
151
|
+
/**
|
|
152
|
+
* `@source` lines for folders given as paths, or aliases like
|
|
153
|
+
* "@/components/ui" the project's tsconfig maps, relative to `dir`.
|
|
154
|
+
*/
|
|
155
|
+
const sourceLines = (project, dir, values) => [...new Set(values.map((value) => value && folderOf(value, project.root)).filter((folder) => Boolean(folder)).map((folder) => `@source "${posixFrom(dir, folder)}";`))];
|
|
156
|
+
/**
|
|
157
|
+
* Tailwind 3's config, for Tailwind 4 wherever the design system's theme is
|
|
158
|
+
* used: the one beside the components views render (Dub's packages/ui, for
|
|
159
|
+
* its semantic classes), else the project's own.
|
|
160
|
+
*/
|
|
161
|
+
const tailwind3Lines = (project, dir) => {
|
|
162
|
+
const config = tailwind3Config([project.designSystem?.componentPackage, project.root])?.config;
|
|
163
|
+
return config ? [`@config "${posixFrom(dir, config)}";`] : [];
|
|
164
|
+
};
|
|
149
165
|
/**
|
|
150
|
-
*
|
|
151
|
-
*
|
|
152
|
-
*
|
|
153
|
-
* system's components are, and none of Dex's.
|
|
166
|
+
* The frame page's stylesheet, written in `dir`: what the real product would
|
|
167
|
+
* have, the design system's CSS (it brings Tailwind and the tokens) and
|
|
168
|
+
* Tailwind told where the views are (`views`, folders) and where the design
|
|
169
|
+
* system's components are, and none of Dex's.
|
|
170
|
+
*/
|
|
171
|
+
function frameStylesheet(project, dir, views) {
|
|
172
|
+
const tailwind = tailwindSetup(project.root);
|
|
173
|
+
return [
|
|
174
|
+
GENERATED,
|
|
175
|
+
LAYER_ORDER,
|
|
176
|
+
...importLines(dir, designSystemStyles(project, tailwind, resetsViews(project))),
|
|
177
|
+
`@import "${posixFrom(dir, join(APP_DIR, "frame.css"))}";`,
|
|
178
|
+
...tailwind3Lines(project, dir),
|
|
179
|
+
...views.map((folder) => `@source "${posixFrom(dir, folder)}";`),
|
|
180
|
+
...sourceLines(project, dir, [componentsRoot(project)]),
|
|
181
|
+
""
|
|
182
|
+
].join("\n");
|
|
183
|
+
}
|
|
184
|
+
/**
|
|
185
|
+
* Write a generated file only when it changes: the development server
|
|
186
|
+
* watches these, and a rewrite of the same text reloads every open page's
|
|
187
|
+
* styles.
|
|
188
|
+
*/
|
|
189
|
+
async function writeChanged(file, text) {
|
|
190
|
+
if (await readFile(file, "utf8").catch(() => void 0) !== text) await writeFile(file, text);
|
|
191
|
+
}
|
|
192
|
+
/**
|
|
193
|
+
* Two stylesheets per project, one for each page. The frame page's
|
|
194
|
+
* (frameStylesheet) reads every prototype's views. The interface's is Dex's
|
|
154
195
|
* own, with the design system's first only when the interface takes it.
|
|
155
196
|
*/
|
|
156
197
|
async function writeEntries(project) {
|
|
157
198
|
const { dir, entryCss, frameCss } = studioState(project.content);
|
|
158
199
|
await prepareState(project.content);
|
|
159
|
-
const from = (path) => relative(dir, path).split(sep).join("/");
|
|
160
|
-
const imports = (entries) => entries.map(({ entry, layer }) => {
|
|
161
|
-
return `@import "${isAbsolute(entry) ? from(entry) : entry}"${layer ? ` layer(${layer})` : ""};`;
|
|
162
|
-
});
|
|
163
|
-
const sources = (values) => [...new Set(values.map((value) => value && folderOf(value, project.root)).filter((folder) => Boolean(folder)).map((folder) => `@source "${from(folder)}";`))];
|
|
164
200
|
const tailwind = tailwindSetup(project.root);
|
|
165
|
-
const tailwind3 = tailwind3Config([project.designSystem?.componentPackage, project.root])?.config;
|
|
166
|
-
const config = tailwind3 ? [`@config "${from(tailwind3)}";`] : [];
|
|
167
201
|
const takesDesignSystem = interfaceTakesDesignSystem(project);
|
|
168
|
-
const frame = [
|
|
169
|
-
GENERATED,
|
|
170
|
-
LAYER_ORDER,
|
|
171
|
-
...imports(designSystemStyles(project, tailwind, resetsViews(project))),
|
|
172
|
-
`@import "${from(join(APP_DIR, "frame.css"))}";`,
|
|
173
|
-
...config,
|
|
174
|
-
`@source "${from(prototypesDir(project.content))}";`,
|
|
175
|
-
...sources([componentsRoot(project)]),
|
|
176
|
-
""
|
|
177
|
-
].join("\n");
|
|
178
202
|
const own = [
|
|
179
203
|
GENERATED,
|
|
180
204
|
LAYER_ORDER,
|
|
181
|
-
...
|
|
182
|
-
`@import "${
|
|
183
|
-
...takesDesignSystem ?
|
|
184
|
-
...
|
|
205
|
+
...importLines(dir, takesDesignSystem ? designSystemStyles(project, tailwind, true) : [{ entry: tailwindModule(tailwind) }]),
|
|
206
|
+
`@import "${posixFrom(dir, join(APP_DIR, "styles.css"))}";`,
|
|
207
|
+
...takesDesignSystem ? tailwind3Lines(project, dir) : [],
|
|
208
|
+
...sourceLines(project, dir, [project.ui?.components, primitivesFrom(project)]),
|
|
185
209
|
...project.ui?.accent ? [`:root, .dark { --studio-accent: ${project.ui.accent}; }`] : [],
|
|
186
210
|
""
|
|
187
211
|
].join("\n");
|
|
188
|
-
await
|
|
189
|
-
await
|
|
212
|
+
await writeChanged(frameCss, frameStylesheet(project, dir, [prototypesDir(project.content)]));
|
|
213
|
+
await writeChanged(entryCss, own);
|
|
190
214
|
return {
|
|
191
215
|
frame: frameCss,
|
|
192
216
|
interface: entryCss
|
|
193
217
|
};
|
|
194
218
|
}
|
|
195
|
-
const isOwn = (specifier) => OWN_ALIASES.some((alias) => specifier === alias || specifier.startsWith(`${alias}/`)) || specifier.startsWith("@studio-") || specifier.startsWith("virtual:");
|
|
196
|
-
/** The libraries one source file imports, not counting the studio's own. */
|
|
197
|
-
const importsIn = (source) => [BARE_IMPORT_RE, SIDE_EFFECT_IMPORT_RE].flatMap((re) => [...source.matchAll(re)]).map((match) => match[1] ?? match[2]).filter((specifier) => Boolean(specifier) && !specifier.endsWith(".css") && !isOwn(specifier));
|
|
198
|
-
/** Every source file under a folder, tests and what they share aside. */
|
|
199
|
-
async function sourceFiles(dir) {
|
|
200
|
-
const files = [];
|
|
201
|
-
for (const entry of await readdir(dir, { withFileTypes: true })) {
|
|
202
|
-
const path = join(dir, entry.name);
|
|
203
|
-
if (entry.isDirectory()) {
|
|
204
|
-
if (entry.name !== TEST_SUPPORT_DIR) files.push(...await sourceFiles(path));
|
|
205
|
-
} else if (SOURCE_FILE_RE.test(entry.name) && !TEST_FILE_RE.test(entry.name)) files.push(path);
|
|
206
|
-
}
|
|
207
|
-
return files;
|
|
208
|
-
}
|
|
209
|
-
/**
|
|
210
|
-
* Every library the studio's own interface imports. Installed from npm, the
|
|
211
|
-
* interface lives in node_modules, where Vite neither crawls imports nor
|
|
212
|
-
* converts CommonJS for the browser, so they are listed for it to prepare.
|
|
213
|
-
*/
|
|
214
|
-
async function interfaceDependencies() {
|
|
215
|
-
const found = /* @__PURE__ */ new Set();
|
|
216
|
-
for (const file of await sourceFiles(APP_DIR)) for (const specifier of importsIn(await readFile(file, "utf8"))) if (!MACRO_IMPORT_RE.test(specifier)) found.add(specifier);
|
|
217
|
-
return [...found].sort();
|
|
218
|
-
}
|
|
219
219
|
const LINGUI_MACRO = "@lingui/babel-plugin-lingui-macro";
|
|
220
220
|
/**
|
|
221
221
|
* What Lingui's macro needs to compile the interface's messages, made here
|
|
@@ -228,7 +228,6 @@ const lingui = () => makeConfig({
|
|
|
228
228
|
locales: ["en"],
|
|
229
229
|
sourceLocale: "en"
|
|
230
230
|
}, { skipValidation: true });
|
|
231
|
-
const MACRO_IMPORT_RE = /\/macro$/;
|
|
232
231
|
const SCRIPT_RE = /\.[cm]?[jt]sx?$/;
|
|
233
232
|
/**
|
|
234
233
|
* Compile Lingui's macros in the studio's own interface. React's plugin
|
|
@@ -676,6 +675,7 @@ async function viteConfig(project, mode) {
|
|
|
676
675
|
envDir: project.root,
|
|
677
676
|
define: { "process.env.NODE_ENV": JSON.stringify(mode) },
|
|
678
677
|
plugins: [
|
|
678
|
+
hostedPeople(),
|
|
679
679
|
studioMacros(),
|
|
680
680
|
oneInterfaceCopy(),
|
|
681
681
|
sourceStamp(project.content, project.designSystem?.imports ?? [], { places: stampsSources(features()) }),
|
|
@@ -692,6 +692,8 @@ async function viteConfig(project, mode) {
|
|
|
692
692
|
...project.plugins,
|
|
693
693
|
...await lacksNext(project) ? [next()] : [],
|
|
694
694
|
studioDev(project),
|
|
695
|
+
canvasPresence(),
|
|
696
|
+
prebundleViews(project),
|
|
695
697
|
fileErrors(project.content, componentsRoot(project)),
|
|
696
698
|
studioWebApp(project),
|
|
697
699
|
projectPublic(project.root)
|
|
@@ -748,4 +750,4 @@ async function viteConfig(project, mode) {
|
|
|
748
750
|
return project.vite ? await project.vite(config, { mode }) : config;
|
|
749
751
|
}
|
|
750
752
|
//#endregion
|
|
751
|
-
export { SAVE_TEMPORARY, hostTag, importsTailwind, meTag, oneInterfaceCopy, primitivesFrom, projectBaseUrlResolver, studioComponents, studioProvider, studioThreads, viteConfig, workspaceTag, writeEntries };
|
|
753
|
+
export { SAVE_TEMPORARY, frameStylesheet, hostTag, importsTailwind, meTag, oneInterfaceCopy, primitivesFrom, projectBaseUrlResolver, studioComponents, studioProvider, studioThreads, viteConfig, workspaceTag, writeEntries };
|
package/dist/server/web-app.mjs
CHANGED
|
@@ -2,7 +2,7 @@ import { runningVersion } from "../paths.mjs";
|
|
|
2
2
|
import { DESKTOP_APP_INSTALLED, DESKTOP_APP_KEY, MANIFEST_FILE, OLD_PROJECT_ID_HEADER, PROJECT_ID_HEADER, START_LINK_META } from "../shared/studio-routes.mjs";
|
|
3
3
|
import { projectId } from "./project-id.mjs";
|
|
4
4
|
import { serverPage, shownPath } from "../shared/server-page.mjs";
|
|
5
|
-
import { APP_NAME,
|
|
5
|
+
import { APP_NAME, desktopAppState, desktopAppUnavailable, servedApp, urlScheme } from "../setup/desktop-app.mjs";
|
|
6
6
|
import { basename, sep } from "node:path";
|
|
7
7
|
import { homedir } from "node:os";
|
|
8
8
|
//#region src/server/web-app.ts
|
|
@@ -109,7 +109,7 @@ const rememberAppScript = (startsHere) => {
|
|
|
109
109
|
function studioWebApp(project) {
|
|
110
110
|
let base = "/";
|
|
111
111
|
let serving = false;
|
|
112
|
-
let
|
|
112
|
+
let devServer;
|
|
113
113
|
const name = APP_NAME;
|
|
114
114
|
const manifest = JSON.stringify(webAppManifest(name), null, 2);
|
|
115
115
|
return {
|
|
@@ -117,13 +117,9 @@ function studioWebApp(project) {
|
|
|
117
117
|
configResolved(config) {
|
|
118
118
|
base = config.base;
|
|
119
119
|
serving = config.command === "serve";
|
|
120
|
-
app = serving && desktopAppUnavailable() === void 0 ? desktopApp({
|
|
121
|
-
root: project.root,
|
|
122
|
-
port: config.server.port,
|
|
123
|
-
base
|
|
124
|
-
}) : void 0;
|
|
125
120
|
},
|
|
126
121
|
configureServer(server) {
|
|
122
|
+
devServer = server;
|
|
127
123
|
const worker = serviceWorker(project.root);
|
|
128
124
|
const id = projectId(project.root);
|
|
129
125
|
server.middlewares.use((request, response, next) => {
|
|
@@ -166,6 +162,7 @@ function studioWebApp(project) {
|
|
|
166
162
|
})];
|
|
167
163
|
if (!serving) return tags;
|
|
168
164
|
tags.push(head("script", { type: "module" }, registration(base)));
|
|
165
|
+
const app = devServer && desktopAppUnavailable() === void 0 ? servedApp(project.root, devServer) : void 0;
|
|
169
166
|
if (app) {
|
|
170
167
|
const { startsHere } = await desktopAppState(app);
|
|
171
168
|
tags.push(head("meta", {
|
package/dist/server/welcome.mjs
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { nameOfMe } from "../shared/studio-routes.mjs";
|
|
2
2
|
import { personalFolder } from "./personal-folder.mjs";
|
|
3
|
+
import { isHosted } from "../content/hosted-person.mjs";
|
|
3
4
|
import { readMe } from "./me.mjs";
|
|
4
5
|
import { join } from "node:path";
|
|
5
6
|
import { execFile } from "node:child_process";
|
|
@@ -19,7 +20,7 @@ const welcomed = async () => {
|
|
|
19
20
|
const gitEmail = (content) => new Promise((done) => execFile("git", ["config", "user.email"], { cwd: content }, (_, out) => done(String(out ?? "").trim())));
|
|
20
21
|
/** Whether to welcome the person, and who Dex takes them to be. */
|
|
21
22
|
const readWelcome = async (content) => {
|
|
22
|
-
if (await welcomed()) return {
|
|
23
|
+
if (isHosted() || await welcomed()) return {
|
|
23
24
|
due: false,
|
|
24
25
|
name: "",
|
|
25
26
|
email: ""
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { prototypeFiles } from "../shared/prototypes-core.mjs";
|
|
2
|
-
import { ownTitle, prototypeTitle, viewFiles } from "../content/prototypes.mjs";
|
|
3
2
|
import { specName } from "../shared/canvas-core.mjs";
|
|
3
|
+
import { ownTitle, prototypeTitle, viewFiles } from "../content/prototypes.mjs";
|
|
4
4
|
import { existsSync } from "node:fs";
|
|
5
5
|
import { dirname, extname, join, relative, resolve } from "node:path";
|
|
6
6
|
import { readFile } from "node:fs/promises";
|
package/dist/setup/apply.d.mts
CHANGED
|
@@ -59,6 +59,10 @@ export declare function studioDesignSystem(findings: ProjectFindings, decisions:
|
|
|
59
59
|
* yet, but its folder was chosen.
|
|
60
60
|
*/
|
|
61
61
|
export declare function nextFolders(packageDir: string, decisions: SetupDecisions, componentPackage: string | undefined): (string | undefined)[];
|
|
62
|
+
/** A package.json, changed by `change`, written back. */
|
|
63
|
+
export declare function editManifest(file: string, change: (manifest: Record<string, unknown>) => void): Promise<void>;
|
|
64
|
+
/** It extends the tsconfig the dev server resolves views' imports through. */
|
|
65
|
+
export declare function studioTsconfig(folders: Folders): string;
|
|
62
66
|
/** The project's tsconfig as the studio's extends it: "../tsconfig.json". */
|
|
63
67
|
export declare function projectTsconfig({ content, packageDir }: Folders): string | undefined;
|
|
64
68
|
/** How the studio's DESIGN.md started: drafted, imported, or left as it was. */
|
package/dist/setup/apply.mjs
CHANGED
|
@@ -12,7 +12,7 @@ import { agentName, componentsChoice, connectInStudio } from "./project.mjs";
|
|
|
12
12
|
import { nextPackage } from "../server/next.mjs";
|
|
13
13
|
import { choicesOnly } from "./config-choices.mjs";
|
|
14
14
|
import { formatAsProject, keepLockfilesFormatted, readLockfiles } from "./host-format.mjs";
|
|
15
|
-
import { STUDIO_TYPES, configSource, designSystemConfig, fromStudio, ignoreFile, missingIgnoreLines, missingScripts, pnpmDecidesEsbuild, tsconfigJson, withEsbuildBuilds, withIgnoreLines, withPointer } from "./write.mjs";
|
|
15
|
+
import { STUDIO_TYPES, configSource, designSystemConfig, fromStudio, ignoreFile, missingIgnoreLines, missingScripts, pnpmDecidesEsbuild, renamedScripts, tsconfigJson, withEsbuildBuilds, withIgnoreLines, withPointer } from "./write.mjs";
|
|
16
16
|
import { appPackageJson, appTsconfigJson, turboJson } from "./own-app.mjs";
|
|
17
17
|
import { PROVIDER_FILE } from "./questions.mjs";
|
|
18
18
|
import { commandLine, planCounts } from "./plan.mjs";
|
|
@@ -198,9 +198,10 @@ async function writeStep(step, context) {
|
|
|
198
198
|
const own = plan.target.kind === "own-app";
|
|
199
199
|
await editManifest(file, (manifest) => {
|
|
200
200
|
const scripts = recordAt(manifest, "scripts");
|
|
201
|
-
|
|
201
|
+
manifest.scripts = {
|
|
202
202
|
...scripts,
|
|
203
|
-
...
|
|
203
|
+
...renamedScripts(scripts),
|
|
204
|
+
...own ? {} : missingScripts(scripts)
|
|
204
205
|
};
|
|
205
206
|
if (spec) manifest.devDependencies = {
|
|
206
207
|
...recordAt(manifest, "devDependencies"),
|
|
@@ -455,4 +456,4 @@ async function applyPlan(plan, context) {
|
|
|
455
456
|
};
|
|
456
457
|
}
|
|
457
458
|
//#endregion
|
|
458
|
-
export { applyPlan, foldersOf, nextFolders, projectTsconfig, runCommand, studioDesignSystem };
|
|
459
|
+
export { applyPlan, editManifest, foldersOf, nextFolders, projectTsconfig, runCommand, studioDesignSystem, studioTsconfig };
|
package/dist/setup/create.d.mts
CHANGED
|
@@ -43,8 +43,10 @@ export declare function setUp(root: string, flags: CreateFlags, deps?: CreateDep
|
|
|
43
43
|
workspaces?: boolean;
|
|
44
44
|
}): Promise<SetupOutcome>;
|
|
45
45
|
/**
|
|
46
|
-
* `dex create [dir]`:
|
|
47
|
-
*
|
|
46
|
+
* `dex create [dir]`: the studio added to the project in a folder with a
|
|
47
|
+
* package.json, or else a new project. A folder with files but no project
|
|
48
|
+
* (an agent's `work/` and `outputs/`, notes) gets the new project beside
|
|
49
|
+
* them.
|
|
48
50
|
*/
|
|
49
51
|
export declare function create(dir: string | undefined, flags?: CreateFlags, deps?: CreateDeps): Promise<SetupOutcome>;
|
|
50
52
|
//#endregion
|
package/dist/setup/create.mjs
CHANGED
|
@@ -8,6 +8,7 @@ import { summaryLines } from "./design-md-setup.mjs";
|
|
|
8
8
|
import { dexRunner, pmCommand } from "../config/package-manager.mjs";
|
|
9
9
|
import { createPrototype, loadStudio, scratchView } from "../content/content.mjs";
|
|
10
10
|
import { agentSetups } from "../server/agents.mjs";
|
|
11
|
+
import { runningAgent } from "./detect.mjs";
|
|
11
12
|
import { AGENT_IDS, CREATE_COMMAND, agentName, connectInStudio, createCommandFor, findProject, resolvedStudio } from "./project.mjs";
|
|
12
13
|
import { prepareContent } from "../content/first-run.mjs";
|
|
13
14
|
import { nextPackage } from "../server/next.mjs";
|
|
@@ -20,7 +21,7 @@ import { doctor, realProbes, startProblems } from "./doctor.mjs";
|
|
|
20
21
|
import { configChange, decideAgain, existingStudio, newStudioSpec, placementOf, refuseOwnFolder, studioUpgrade } from "./existing-setup.mjs";
|
|
21
22
|
import { setupHints } from "./hints.mjs";
|
|
22
23
|
import { PLACEMENT, decidePlacement, describePlacement, workspaceLines } from "./placement.mjs";
|
|
23
|
-
import { DEFAULT_STARTER, STARTERS, STARTER_NAMES, TEMPLATE_FLAG, copyStarter, packageManagerVersion, starterNamed, starterPackageManager } from "./starters.mjs";
|
|
24
|
+
import { DEFAULT_STARTER, STARTERS, STARTER_NAMES, TEMPLATE_FLAG, copyStarter, packageManagerVersion, starterNamed, starterPackageManager, starterRootNames } from "./starters.mjs";
|
|
24
25
|
import { findingsFor, targetFor, workspaceFor, workspaceSetup, workspaceWarnings } from "./workspace-setup.mjs";
|
|
25
26
|
import { existsSync, readFileSync } from "node:fs";
|
|
26
27
|
import { basename, join, relative, resolve } from "node:path";
|
|
@@ -241,7 +242,7 @@ function nextLines(decisions, result, { blockers = [], cwd, root, placement }) {
|
|
|
241
242
|
})}`, `Check the setup any time: ${inPackage}${dex} doctor`);
|
|
242
243
|
return lines;
|
|
243
244
|
}
|
|
244
|
-
/** Where the studio's commands find its config: "cd apps/
|
|
245
|
+
/** Where the studio's commands find its config: "cd apps/dex && ", or "". */
|
|
245
246
|
function cdInto(placement) {
|
|
246
247
|
if (!placement) return "";
|
|
247
248
|
const folder = placement.kind === "own-app" ? placement.folder : placement.packageFolder;
|
|
@@ -329,9 +330,9 @@ function ending(installed, flags, blocked) {
|
|
|
329
330
|
}
|
|
330
331
|
/** --app and --in choose a place in a workspace: a single project has none. */
|
|
331
332
|
function refuseWorkspaceFlags(flags) {
|
|
332
|
-
if (flags.app !== void 0 || flags.in !== void 0) throw new Error(`${flags.app === void 0 ? "--in" : "--app"} is for a workspace, and this is a single project: the studio goes in its
|
|
333
|
+
if (flags.app !== void 0 || flags.in !== void 0) throw new Error(`${flags.app === void 0 ? "--in" : "--app"} is for a workspace, and this is a single project: the studio goes in its Dex folder, dex/ (--dir).`);
|
|
333
334
|
}
|
|
334
|
-
/** A single project (or a package set up by itself): the studio in
|
|
335
|
+
/** A single project (or a package set up by itself): the studio in dex/. */
|
|
335
336
|
async function prepareProject(root, flags, ui, { ask, deps }) {
|
|
336
337
|
const findings = await findProject(root, { userAgent: deps.userAgent });
|
|
337
338
|
reportFindings(ui, findings);
|
|
@@ -720,6 +721,33 @@ function shownPath(root) {
|
|
|
720
721
|
}
|
|
721
722
|
/** Whether a folder can take a new project: missing, empty or near enough. */
|
|
722
723
|
const isEmpty = async (root) => !existsSync(root) || (await readdir(root)).every((name) => ALLOWED_EXISTING.has(name));
|
|
724
|
+
/**
|
|
725
|
+
* A new project beside what a folder holds already (an agent's `work/`, a
|
|
726
|
+
* few notes): asked in a terminal, said without one. It stops, writing
|
|
727
|
+
* nothing, when the project would write over any of it.
|
|
728
|
+
*/
|
|
729
|
+
async function besideKept(root, project, kept, { ui, ask }) {
|
|
730
|
+
const written = [
|
|
731
|
+
...await starterRootNames(project.starter),
|
|
732
|
+
project.starter.workspace ? "apps" : project.dir,
|
|
733
|
+
"dex.config.ts"
|
|
734
|
+
];
|
|
735
|
+
const clashes = kept.filter((name) => written.includes(name));
|
|
736
|
+
const shown = shownPath(root);
|
|
737
|
+
if (clashes.length > 0) throw new Error(`${shown} has no package.json, but it has ${clashes.join(", ")}, which a new project would write over. Move ${clashes.length === 1 ? "it" : "them"}, or start in another folder: dex create <folder>.`);
|
|
738
|
+
const list = kept.join(", ");
|
|
739
|
+
ui.event({
|
|
740
|
+
step: "decide",
|
|
741
|
+
key: "kept",
|
|
742
|
+
value: kept,
|
|
743
|
+
source: "the folder"
|
|
744
|
+
});
|
|
745
|
+
if (!ask) {
|
|
746
|
+
ui.step(`${shown} has no package.json: a new project goes here, beside ${list}, which stay as they are.`);
|
|
747
|
+
return;
|
|
748
|
+
}
|
|
749
|
+
if (!await ui.confirm(`${shown} has ${list} but no package.json. Start a new project here, beside ${kept.length === 1 ? "it" : "them"}?`, { initial: true })) throw new Cancelled();
|
|
750
|
+
}
|
|
723
751
|
const WELCOME_IMPORT = "\"@/components/ui/";
|
|
724
752
|
/**
|
|
725
753
|
* A first prototype, by whoever is creating the project, importing the
|
|
@@ -754,8 +782,8 @@ async function chooseStarter(ui, ask) {
|
|
|
754
782
|
}
|
|
755
783
|
/**
|
|
756
784
|
* `--agent`, parsed: the agents it names ("none" for none). Without it, a
|
|
757
|
-
* new folder has no agent files to go by: asked in a terminal, else
|
|
758
|
-
* Code.
|
|
785
|
+
* new folder has no agent files to go by: asked in a terminal, else the
|
|
786
|
+
* agent running setup, else Claude Code.
|
|
759
787
|
*/
|
|
760
788
|
function newProjectAgents(flag, ask) {
|
|
761
789
|
if (flag !== void 0) return {
|
|
@@ -764,7 +792,7 @@ function newProjectAgents(flag, ask) {
|
|
|
764
792
|
};
|
|
765
793
|
return ask ? { kind: "ask" } : {
|
|
766
794
|
kind: "given",
|
|
767
|
-
ids: ["claude"]
|
|
795
|
+
ids: [runningAgent()?.id ?? "claude"]
|
|
768
796
|
};
|
|
769
797
|
}
|
|
770
798
|
/** The agents as the plan names them. */
|
|
@@ -773,7 +801,7 @@ function agentsInPlan(agents) {
|
|
|
773
801
|
return agents.ids.length > 0 ? agents.ids.join(",") : "no agents";
|
|
774
802
|
}
|
|
775
803
|
/** Where the studio goes in a new project, as the plan says it. */
|
|
776
|
-
const studioPlace = ({ starter, dir }) => starter.workspace ? "its own app, apps/
|
|
804
|
+
const studioPlace = ({ starter, dir }) => starter.workspace ? "its own app, apps/dex" : `${dir}/`;
|
|
777
805
|
/** `create --dry-run` in an empty folder: what it would do, writing nothing. */
|
|
778
806
|
function newProjectPlan(ui, project, flags) {
|
|
779
807
|
const agents = agentsInPlan(project.agents);
|
|
@@ -857,7 +885,7 @@ function checkNewProjectFlags(flags) {
|
|
|
857
885
|
studioDir(flags.dir);
|
|
858
886
|
if (flags.pm !== void 0) packageManagerName(flags.pm);
|
|
859
887
|
const named = flags.template === void 0 ? void 0 : starterNamed(flags.template);
|
|
860
|
-
if (named?.workspace && flags.dir !== void 0) throw new Error(`--dir is for a studio inside an app; in a ${named.label} the studio is an app of its own, apps/
|
|
888
|
+
if (named?.workspace && flags.dir !== void 0) throw new Error(`--dir is for a studio inside an app; in a ${named.label} the studio is an app of its own, apps/dex.`);
|
|
861
889
|
return named;
|
|
862
890
|
}
|
|
863
891
|
/** How a new project's output ends: where it is, and how to start. */
|
|
@@ -886,7 +914,8 @@ function readyLines(root, project, result) {
|
|
|
886
914
|
* Turborepo's studio gets its own app. The agents are asked in a terminal,
|
|
887
915
|
* as in any project; without one, Claude Code, unless --agent says otherwise.
|
|
888
916
|
*/
|
|
889
|
-
async function newProject(root, flags, deps) {
|
|
917
|
+
async function newProject(root, flags, deps, names) {
|
|
918
|
+
const kept = names.filter((name) => !ALLOWED_EXISTING.has(name));
|
|
890
919
|
const name = basename(root).toLowerCase().replace(NAME_RE, "-").replace(EDGE_RE, "") || "my-studio";
|
|
891
920
|
const named = checkNewProjectFlags(flags);
|
|
892
921
|
const ui = deps.ui ?? await createReporter({ json: flags.json });
|
|
@@ -912,6 +941,14 @@ async function newProject(root, flags, deps) {
|
|
|
912
941
|
pm,
|
|
913
942
|
starter
|
|
914
943
|
};
|
|
944
|
+
if (kept.length > 0) try {
|
|
945
|
+
await besideKept(root, project, kept, {
|
|
946
|
+
ui,
|
|
947
|
+
ask
|
|
948
|
+
});
|
|
949
|
+
} catch (error) {
|
|
950
|
+
return stopped(ui, error);
|
|
951
|
+
}
|
|
915
952
|
if (!(ask || named)) ui.step("A new project. Change it with its flag:", [`Template ${starter.name.padEnd(12)}${TEMPLATE_FLAG}`, `Package manager ${pm.padEnd(12)}--pm bun | pnpm | yarn | npm`]);
|
|
916
953
|
ui.event({
|
|
917
954
|
step: "decide",
|
|
@@ -943,7 +980,8 @@ async function newProject(root, flags, deps) {
|
|
|
943
980
|
await trackWithGit(root, flags, {
|
|
944
981
|
ui,
|
|
945
982
|
exec,
|
|
946
|
-
ask
|
|
983
|
+
ask,
|
|
984
|
+
kept
|
|
947
985
|
});
|
|
948
986
|
if (!flags.skipInstall) await check(ui, join(root, plan.target.package));
|
|
949
987
|
ui.end("Ready.", readyLines(root, project, result));
|
|
@@ -957,12 +995,12 @@ const inRepository = async (dir, exec) => (await exec("git", ["rev-parse", "--is
|
|
|
957
995
|
* in a terminal, done without one; skipped inside a repository, with
|
|
958
996
|
* --no-git, or without git. It adds no remote: that is the person's.
|
|
959
997
|
*/
|
|
960
|
-
async function trackWithGit(root, flags, { ask, exec, ui }) {
|
|
998
|
+
async function trackWithGit(root, flags, { ask, exec, ui, kept }) {
|
|
961
999
|
if (flags.git === false || await inRepository(root, exec)) return;
|
|
962
1000
|
if (ask) {
|
|
963
1001
|
if (!await ui.confirm("Track this project with git?", { initial: true })) return;
|
|
964
1002
|
}
|
|
965
|
-
|
|
1003
|
+
const steps = [
|
|
966
1004
|
{
|
|
967
1005
|
args: ["init", "--quiet"],
|
|
968
1006
|
failed: "Git didn’t start: run git init in the project to track it."
|
|
@@ -971,6 +1009,18 @@ async function trackWithGit(root, flags, { ask, exec, ui }) {
|
|
|
971
1009
|
args: ["add", "--all"],
|
|
972
1010
|
failed: "Git started, but the files weren’t added: run git add --all."
|
|
973
1011
|
},
|
|
1012
|
+
...kept.length > 0 ? [{
|
|
1013
|
+
args: [
|
|
1014
|
+
"rm",
|
|
1015
|
+
"-r",
|
|
1016
|
+
"--cached",
|
|
1017
|
+
"--quiet",
|
|
1018
|
+
"--ignore-unmatch",
|
|
1019
|
+
"--",
|
|
1020
|
+
...kept
|
|
1021
|
+
],
|
|
1022
|
+
failed: `Git started, but it holds what was here too: run git rm -r --cached ${kept.join(" ")} to leave it out.`
|
|
1023
|
+
}] : [],
|
|
974
1024
|
{
|
|
975
1025
|
args: [
|
|
976
1026
|
"commit",
|
|
@@ -980,7 +1030,8 @@ async function trackWithGit(root, flags, { ask, exec, ui }) {
|
|
|
980
1030
|
],
|
|
981
1031
|
failed: "Git started, but the first commit failed. If git doesn’t know who you are yet, set git config user.name and user.email, then commit."
|
|
982
1032
|
}
|
|
983
|
-
]
|
|
1033
|
+
];
|
|
1034
|
+
for (const { args, failed } of steps) {
|
|
984
1035
|
const { ok } = await exec("git", args, { cwd: root });
|
|
985
1036
|
if (!ok) {
|
|
986
1037
|
ui.step(failed);
|
|
@@ -995,17 +1046,16 @@ async function trackWithGit(root, flags, { ask, exec, ui }) {
|
|
|
995
1046
|
ui.step("Tracked with git, with a first commit.");
|
|
996
1047
|
}
|
|
997
1048
|
/**
|
|
998
|
-
* `dex create [dir]`:
|
|
999
|
-
*
|
|
1049
|
+
* `dex create [dir]`: the studio added to the project in a folder with a
|
|
1050
|
+
* package.json, or else a new project. A folder with files but no project
|
|
1051
|
+
* (an agent's `work/` and `outputs/`, notes) gets the new project beside
|
|
1052
|
+
* them.
|
|
1000
1053
|
*/
|
|
1001
1054
|
async function create(dir, flags = {}, deps = {}) {
|
|
1002
1055
|
const root = resolve(dir ?? ".");
|
|
1003
|
-
if (await isEmpty(root)) return newProject(root, flags, deps);
|
|
1004
|
-
if (
|
|
1005
|
-
if (
|
|
1006
|
-
const shown = relative(process.cwd(), root) || ".";
|
|
1007
|
-
throw new Error(`${shown} has files but no package.json. Run \`dex create\` in a project's folder (where its package.json is), or in an empty folder for a new project.`);
|
|
1008
|
-
}
|
|
1056
|
+
if (await isEmpty(root)) return newProject(root, flags, deps, []);
|
|
1057
|
+
if (!existsSync(join(root, "package.json"))) return newProject(root, flags, deps, await readdir(root));
|
|
1058
|
+
if (flags.template !== void 0) throw new Error(`--template starts a new project, and ${shownPath(root)} has one already. Leave it out to add a studio to the project here, or give another folder: dex create <folder> --template ${flags.template}.`);
|
|
1009
1059
|
return setUp(root, flags, {
|
|
1010
1060
|
...deps,
|
|
1011
1061
|
workspaces: true
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { posix as posix$1 } from "../paths.mjs";
|
|
2
|
-
import { componentsJsonError, projectPaths } from "../config/project-files.mjs";
|
|
2
|
+
import { componentsJsonError, installedPackageDir, packageOf, projectPaths } from "../config/project-files.mjs";
|
|
3
3
|
import { createRequire } from "node:module";
|
|
4
4
|
import { existsSync, readFileSync, readdirSync } from "node:fs";
|
|
5
5
|
import { dirname, isAbsolute, join, relative } from "node:path";
|
|
@@ -15,11 +15,6 @@ const canResolve = (from, specifier) => {
|
|
|
15
15
|
};
|
|
16
16
|
/** A path as doctor prints it: from the config's folder. */
|
|
17
17
|
const shown = (file, root) => posix$1(relative(root, file)) || ".";
|
|
18
|
-
/** A package name from an import pattern: "@acme/ui/*" → "@acme/ui". */
|
|
19
|
-
const packageOf = (pattern) => {
|
|
20
|
-
const parts = pattern.replace(WILDCARD_RE, "").split("/");
|
|
21
|
-
return pattern.startsWith("@") ? parts.slice(0, 2).join("/") : parts[0];
|
|
22
|
-
};
|
|
23
18
|
const SCOPE_WILDCARD_RE = /^(@[^/]+)\/\*$/;
|
|
24
19
|
/** The scope a whole-scope pattern allows: "@mantine/*" → "@mantine". */
|
|
25
20
|
const scopeOf = (pattern) => SCOPE_WILDCARD_RE.exec(pattern)?.[1];
|
|
@@ -43,15 +38,6 @@ const localTo = (root) => {
|
|
|
43
38
|
const aliases = projectPaths(root).map(([pattern]) => pattern.replace(WILDCARD_RE, ""));
|
|
44
39
|
return (name) => name.startsWith(".") || name.startsWith("@/") || aliases.some((alias) => name === alias || name.startsWith(`${alias}/`));
|
|
45
40
|
};
|
|
46
|
-
/** Where an installed package lives, looking up from `from`. */
|
|
47
|
-
const packageDir = (from, name) => {
|
|
48
|
-
let dir = from;
|
|
49
|
-
while (dir !== dirname(dir)) {
|
|
50
|
-
const candidate = join(dir, "node_modules", name);
|
|
51
|
-
if (existsSync(join(candidate, "package.json"))) return candidate;
|
|
52
|
-
dir = dirname(dir);
|
|
53
|
-
}
|
|
54
|
-
};
|
|
55
41
|
const VITE_CONDITIONS = /* @__PURE__ */ new Set([
|
|
56
42
|
"browser",
|
|
57
43
|
"import",
|
|
@@ -109,7 +95,7 @@ function unbuiltPackages(project) {
|
|
|
109
95
|
if (!project.designSystem) return [];
|
|
110
96
|
const isLocal = localTo(project.root);
|
|
111
97
|
return importedPackages(project.designSystem).filter((name) => !isLocal(name)).flatMap((name) => {
|
|
112
|
-
const dir =
|
|
98
|
+
const dir = installedPackageDir(project.content, name);
|
|
113
99
|
const missing = dir ? missingExports(dir) : [];
|
|
114
100
|
return missing.length > 0 ? [{
|
|
115
101
|
name,
|
|
@@ -121,7 +107,7 @@ function checkImports({ content, root, designSystem }, { ok, warn }) {
|
|
|
121
107
|
const isLocal = localTo(root);
|
|
122
108
|
if (designSystem.imports.length === 0) warn("The design system lists no imports", "Fill in `designSystem.imports` in dex.config.ts so the audit can tell your components apart.");
|
|
123
109
|
for (const name of importedPackages(designSystem)) {
|
|
124
|
-
const dir = isLocal(name) ? void 0 :
|
|
110
|
+
const dir = isLocal(name) ? void 0 : installedPackageDir(content, name);
|
|
125
111
|
const resolves = isLocal(name) || canResolve(content, `${name}/package.json`) || canResolve(content, name) || dir !== void 0;
|
|
126
112
|
const missing = dir ? missingExports(dir) : [];
|
|
127
113
|
if (resolves && missing.length > 0) warn(`${name} is not built: ${missing.slice(0, 3).join(", ")} ${missing.length === 1 ? "is" : "are"} missing`, `Build it before starting the studio (in a monorepo, \`npx turbo run build --filter=${name}\`), or views cannot import it.`);
|
|
@@ -162,9 +162,10 @@ function startOutput() {
|
|
|
162
162
|
ObjC.bindFunction("kill", ["int", ["int", "int"]]);
|
|
163
163
|
|
|
164
164
|
/**
|
|
165
|
-
* Whether the server the launcher started last still runs. The
|
|
166
|
-
*
|
|
167
|
-
*
|
|
165
|
+
* Whether the server the launcher started last still runs. The pid file
|
|
166
|
+
* names the start the window waits on; the launcher clears it when it
|
|
167
|
+
* gives up, and dex app start when the port is taken, so without one,
|
|
168
|
+
* nothing is starting.
|
|
168
169
|
*/
|
|
169
170
|
function startAlive() {
|
|
170
171
|
const pid = Number(readText(DEX.pidFile).trim());
|
|
@@ -18,10 +18,14 @@ export type AppStart =
|
|
|
18
18
|
state: "gone";
|
|
19
19
|
message: string;
|
|
20
20
|
} |
|
|
21
|
-
/**
|
|
21
|
+
/**
|
|
22
|
+
* Something other than this project's Dex holds the port. `ownUrl` is
|
|
23
|
+
* where this project's Dex answers instead, when it runs on another port.
|
|
24
|
+
*/
|
|
22
25
|
{
|
|
23
26
|
state: "taken";
|
|
24
27
|
taken: PortTaken;
|
|
28
|
+
ownUrl?: string;
|
|
25
29
|
};
|
|
26
30
|
export interface AppStartOptions {
|
|
27
31
|
/** The `dex` to run `dev` with. */
|
|
@@ -53,7 +57,9 @@ export declare function loginShellPath(env: NodeJS.ProcessEnv): Promise<string |
|
|
|
53
57
|
export declare const launchPath: (runtime: string, login: string | undefined) => string;
|
|
54
58
|
/**
|
|
55
59
|
* Show this project's Dex, or start it: never a server another project,
|
|
56
|
-
* or anything else, put on the port.
|
|
60
|
+
* or anything else, put on the port. The app's start link asks again as
|
|
61
|
+
* the app opens: then the `dex dev` it started is still coming up, and
|
|
62
|
+
* it waits on that one rather than start another.
|
|
57
63
|
*/
|
|
58
64
|
export declare function startForApp(options: AppStartOptions): Promise<AppStart>;
|
|
59
65
|
//#endregion
|