@rien7/seji 0.0.0 → 0.6.1
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/bin/design-surface.mjs +6 -0
- package/bin/postinstall.mjs +19 -0
- package/bin/seji.mjs +585 -0
- package/dist/agent/host.d.mts +34 -0
- package/dist/agent/host.mjs +387 -0
- package/dist/agent/messages.d.mts +9 -0
- package/dist/agent/messages.mjs +70 -0
- package/dist/agent/runtimes.mjs +157 -0
- package/dist/cli/app.mjs +321 -0
- package/dist/cli/appScan.mjs +284 -0
- package/dist/cli/catalog.mjs +78 -0
- package/dist/cli/component.mjs +165 -0
- package/dist/cli/consolidate.mjs +159 -0
- package/dist/cli/cssImport.mjs +68 -0
- package/dist/cli/dev.mjs +339 -0
- package/dist/cli/doctor.mjs +311 -0
- package/dist/cli/init.mjs +338 -0
- package/dist/cli/legacyNames.mjs +266 -0
- package/dist/cli/migrate.mjs +163 -0
- package/dist/cli/prompt.mjs +34 -0
- package/dist/cli/propose.mjs +208 -0
- package/dist/cli/providers.mjs +344 -0
- package/dist/cli/reviewOps.mjs +110 -0
- package/dist/cli/semver.mjs +45 -0
- package/dist/cli/setup.mjs +360 -0
- package/dist/cli/sketches.mjs +47 -0
- package/dist/cli/skills.mjs +150 -0
- package/dist/cli/snapshot.mjs +107 -0
- package/dist/cli/tokenOps.mjs +120 -0
- package/dist/cli/types.mjs +191 -0
- package/dist/cli/updater.mjs +274 -0
- package/dist/components/astIndex.mjs +992 -0
- package/dist/components/ops.mjs +1069 -0
- package/dist/editor/AgentProposalCard.d.ts +10 -0
- package/dist/editor/AgentProposalCard.d.ts.map +1 -0
- package/dist/editor/AgentProposalCard.js +31 -0
- package/dist/editor/AgentProposalCard.js.map +1 -0
- package/dist/editor/App.d.ts +2 -0
- package/dist/editor/App.d.ts.map +1 -0
- package/dist/editor/App.js +2834 -0
- package/dist/editor/App.js.map +1 -0
- package/dist/editor/CanvasHud.d.ts +12 -0
- package/dist/editor/CanvasHud.d.ts.map +1 -0
- package/dist/editor/CanvasHud.js +13 -0
- package/dist/editor/CanvasHud.js.map +1 -0
- package/dist/editor/CanvasSurface.d.ts +31 -0
- package/dist/editor/CanvasSurface.d.ts.map +1 -0
- package/dist/editor/CanvasSurface.js +270 -0
- package/dist/editor/CanvasSurface.js.map +1 -0
- package/dist/editor/CommentPopover.d.ts +17 -0
- package/dist/editor/CommentPopover.d.ts.map +1 -0
- package/dist/editor/CommentPopover.js +62 -0
- package/dist/editor/CommentPopover.js.map +1 -0
- package/dist/editor/Comments.d.ts +13 -0
- package/dist/editor/Comments.d.ts.map +1 -0
- package/dist/editor/Comments.js +41 -0
- package/dist/editor/Comments.js.map +1 -0
- package/dist/editor/ComponentPage.d.ts +28 -0
- package/dist/editor/ComponentPage.d.ts.map +1 -0
- package/dist/editor/ComponentPage.js +55 -0
- package/dist/editor/ComponentPage.js.map +1 -0
- package/dist/editor/ComponentPanel.d.ts +38 -0
- package/dist/editor/ComponentPanel.d.ts.map +1 -0
- package/dist/editor/ComponentPanel.js +275 -0
- package/dist/editor/ComponentPanel.js.map +1 -0
- package/dist/editor/Glyph.d.ts +51 -0
- package/dist/editor/Glyph.d.ts.map +1 -0
- package/dist/editor/Glyph.js +50 -0
- package/dist/editor/Glyph.js.map +1 -0
- package/dist/editor/History.d.ts +7 -0
- package/dist/editor/History.d.ts.map +1 -0
- package/dist/editor/History.js +51 -0
- package/dist/editor/History.js.map +1 -0
- package/dist/editor/Inspector.d.ts +56 -0
- package/dist/editor/Inspector.d.ts.map +1 -0
- package/dist/editor/Inspector.js +510 -0
- package/dist/editor/Inspector.js.map +1 -0
- package/dist/editor/LazyMount.d.ts +10 -0
- package/dist/editor/LazyMount.d.ts.map +1 -0
- package/dist/editor/LazyMount.js +29 -0
- package/dist/editor/LazyMount.js.map +1 -0
- package/dist/editor/LocaleSwitch.d.ts +3 -0
- package/dist/editor/LocaleSwitch.d.ts.map +1 -0
- package/dist/editor/LocaleSwitch.js +9 -0
- package/dist/editor/LocaleSwitch.js.map +1 -0
- package/dist/editor/PreviewFrame.d.ts +10 -0
- package/dist/editor/PreviewFrame.d.ts.map +1 -0
- package/dist/editor/PreviewFrame.js +22 -0
- package/dist/editor/PreviewFrame.js.map +1 -0
- package/dist/editor/ProjectIndex.d.ts +12 -0
- package/dist/editor/ProjectIndex.d.ts.map +1 -0
- package/dist/editor/ProjectIndex.js +43 -0
- package/dist/editor/ProjectIndex.js.map +1 -0
- package/dist/editor/PromoteComponent.d.ts +28 -0
- package/dist/editor/PromoteComponent.d.ts.map +1 -0
- package/dist/editor/PromoteComponent.js +33 -0
- package/dist/editor/PromoteComponent.js.map +1 -0
- package/dist/editor/PromoteForm.d.ts +18 -0
- package/dist/editor/PromoteForm.d.ts.map +1 -0
- package/dist/editor/PromoteForm.js +35 -0
- package/dist/editor/PromoteForm.js.map +1 -0
- package/dist/editor/PromoteToken.d.ts +31 -0
- package/dist/editor/PromoteToken.d.ts.map +1 -0
- package/dist/editor/PromoteToken.js +94 -0
- package/dist/editor/PromoteToken.js.map +1 -0
- package/dist/editor/StatePreviews.d.ts +28 -0
- package/dist/editor/StatePreviews.d.ts.map +1 -0
- package/dist/editor/StatePreviews.js +113 -0
- package/dist/editor/StatePreviews.js.map +1 -0
- package/dist/editor/ValueCombo.d.ts +51 -0
- package/dist/editor/ValueCombo.d.ts.map +1 -0
- package/dist/editor/ValueCombo.js +260 -0
- package/dist/editor/ValueCombo.js.map +1 -0
- package/dist/editor/agent/AgentPanel.d.ts +19 -0
- package/dist/editor/agent/AgentPanel.d.ts.map +1 -0
- package/dist/editor/agent/AgentPanel.js +271 -0
- package/dist/editor/agent/AgentPanel.js.map +1 -0
- package/dist/editor/agent/Markdown.d.ts +5 -0
- package/dist/editor/agent/Markdown.d.ts.map +1 -0
- package/dist/editor/agent/Markdown.js +28 -0
- package/dist/editor/agent/Markdown.js.map +1 -0
- package/dist/editor/agent/agentApi.d.ts +106 -0
- package/dist/editor/agent/agentApi.d.ts.map +1 -0
- package/dist/editor/agent/agentApi.js +66 -0
- package/dist/editor/agent/agentApi.js.map +1 -0
- package/dist/editor/agent/toolLines.d.ts +38 -0
- package/dist/editor/agent/toolLines.d.ts.map +1 -0
- package/dist/editor/agent/toolLines.js +159 -0
- package/dist/editor/agent/toolLines.js.map +1 -0
- package/dist/editor/agent/useAgent.d.ts +15 -0
- package/dist/editor/agent/useAgent.d.ts.map +1 -0
- package/dist/editor/agent/useAgent.js +65 -0
- package/dist/editor/agent/useAgent.js.map +1 -0
- package/dist/editor/api.d.ts +378 -0
- package/dist/editor/api.d.ts.map +1 -0
- package/dist/editor/api.js +247 -0
- package/dist/editor/api.js.map +1 -0
- package/dist/editor/camera.d.ts +18 -0
- package/dist/editor/camera.d.ts.map +1 -0
- package/dist/editor/camera.js +40 -0
- package/dist/editor/camera.js.map +1 -0
- package/dist/editor/canvas.d.ts +25 -0
- package/dist/editor/canvas.d.ts.map +1 -0
- package/dist/editor/canvas.js +35 -0
- package/dist/editor/canvas.js.map +1 -0
- package/dist/editor/changes/ChangesPage.d.ts +25 -0
- package/dist/editor/changes/ChangesPage.d.ts.map +1 -0
- package/dist/editor/changes/ChangesPage.js +132 -0
- package/dist/editor/changes/ChangesPage.js.map +1 -0
- package/dist/editor/changes/changeModel.d.ts +25 -0
- package/dist/editor/changes/changeModel.d.ts.map +1 -0
- package/dist/editor/changes/changeModel.js +81 -0
- package/dist/editor/changes/changeModel.js.map +1 -0
- package/dist/editor/changes/changeState.d.mts +29 -0
- package/dist/editor/changes/changeState.mjs +187 -0
- package/dist/editor/chrome/EditorChrome.d.ts +49 -0
- package/dist/editor/chrome/EditorChrome.d.ts.map +1 -0
- package/dist/editor/chrome/EditorChrome.js +21 -0
- package/dist/editor/chrome/EditorChrome.js.map +1 -0
- package/dist/editor/drafts.d.ts +46 -0
- package/dist/editor/drafts.d.ts.map +1 -0
- package/dist/editor/drafts.js +38 -0
- package/dist/editor/drafts.js.map +1 -0
- package/dist/editor/i18n.d.ts +29 -0
- package/dist/editor/i18n.d.ts.map +1 -0
- package/dist/editor/i18n.js +2320 -0
- package/dist/editor/i18n.js.map +1 -0
- package/dist/editor/iconStroke.d.ts +6 -0
- package/dist/editor/iconStroke.d.ts.map +1 -0
- package/dist/editor/iconStroke.js +6 -0
- package/dist/editor/iconStroke.js.map +1 -0
- package/dist/editor/main.d.ts +2 -0
- package/dist/editor/main.d.ts.map +1 -0
- package/dist/editor/main.js +14 -0
- package/dist/editor/main.js.map +1 -0
- package/dist/editor/model.d.ts +16 -0
- package/dist/editor/model.d.ts.map +1 -0
- package/dist/editor/model.js +11 -0
- package/dist/editor/model.js.map +1 -0
- package/dist/editor/reasons.d.ts +44 -0
- package/dist/editor/reasons.d.ts.map +1 -0
- package/dist/editor/reasons.js +131 -0
- package/dist/editor/reasons.js.map +1 -0
- package/dist/editor/reviewLifecycle.d.ts +8 -0
- package/dist/editor/reviewLifecycle.d.ts.map +1 -0
- package/dist/editor/reviewLifecycle.js +21 -0
- package/dist/editor/reviewLifecycle.js.map +1 -0
- package/dist/editor/styles.css +8737 -0
- package/dist/editor/tokenMatch.d.ts +59 -0
- package/dist/editor/tokenMatch.d.ts.map +1 -0
- package/dist/editor/tokenMatch.js +198 -0
- package/dist/editor/tokenMatch.js.map +1 -0
- package/dist/editor/tokens/ConsolidatePage.d.ts +16 -0
- package/dist/editor/tokens/ConsolidatePage.d.ts.map +1 -0
- package/dist/editor/tokens/ConsolidatePage.js +244 -0
- package/dist/editor/tokens/ConsolidatePage.js.map +1 -0
- package/dist/editor/tokens/TokenActivity.d.ts +18 -0
- package/dist/editor/tokens/TokenActivity.d.ts.map +1 -0
- package/dist/editor/tokens/TokenActivity.js +18 -0
- package/dist/editor/tokens/TokenActivity.js.map +1 -0
- package/dist/editor/tokens/TokenDialogs.d.ts +26 -0
- package/dist/editor/tokens/TokenDialogs.d.ts.map +1 -0
- package/dist/editor/tokens/TokenDialogs.js +119 -0
- package/dist/editor/tokens/TokenDialogs.js.map +1 -0
- package/dist/editor/tokens/TokenList.d.ts +21 -0
- package/dist/editor/tokens/TokenList.d.ts.map +1 -0
- package/dist/editor/tokens/TokenList.js +98 -0
- package/dist/editor/tokens/TokenList.js.map +1 -0
- package/dist/editor/tokens/TokenPage.d.ts +25 -0
- package/dist/editor/tokens/TokenPage.d.ts.map +1 -0
- package/dist/editor/tokens/TokenPage.js +108 -0
- package/dist/editor/tokens/TokenPage.js.map +1 -0
- package/dist/editor/tokens/tokenModel.d.ts +35 -0
- package/dist/editor/tokens/tokenModel.d.ts.map +1 -0
- package/dist/editor/tokens/tokenModel.js +72 -0
- package/dist/editor/tokens/tokenModel.js.map +1 -0
- package/dist/editor/ui/Button.d.ts +3 -0
- package/dist/editor/ui/Button.d.ts.map +1 -0
- package/dist/editor/ui/Button.js +6 -0
- package/dist/editor/ui/Button.js.map +1 -0
- package/dist/editor/ui/CommentBox.d.ts +23 -0
- package/dist/editor/ui/CommentBox.d.ts.map +1 -0
- package/dist/editor/ui/CommentBox.js +41 -0
- package/dist/editor/ui/CommentBox.js.map +1 -0
- package/dist/editor/ui/Icon.d.ts +8 -0
- package/dist/editor/ui/Icon.d.ts.map +1 -0
- package/dist/editor/ui/Icon.js +6 -0
- package/dist/editor/ui/Icon.js.map +1 -0
- package/dist/editor/ui/IconButton.d.ts +11 -0
- package/dist/editor/ui/IconButton.d.ts.map +1 -0
- package/dist/editor/ui/IconButton.js +6 -0
- package/dist/editor/ui/IconButton.js.map +1 -0
- package/dist/editor/ui/NumberInput.d.ts +14 -0
- package/dist/editor/ui/NumberInput.d.ts.map +1 -0
- package/dist/editor/ui/NumberInput.js +6 -0
- package/dist/editor/ui/NumberInput.js.map +1 -0
- package/dist/editor/ui/PageLine.d.ts +14 -0
- package/dist/editor/ui/PageLine.d.ts.map +1 -0
- package/dist/editor/ui/PageLine.js +7 -0
- package/dist/editor/ui/PageLine.js.map +1 -0
- package/dist/editor/ui/SearchPicker.d.ts +41 -0
- package/dist/editor/ui/SearchPicker.d.ts.map +1 -0
- package/dist/editor/ui/SearchPicker.js +82 -0
- package/dist/editor/ui/SearchPicker.js.map +1 -0
- package/dist/editor/ui/Select.d.ts +19 -0
- package/dist/editor/ui/Select.d.ts.map +1 -0
- package/dist/editor/ui/Select.js +12 -0
- package/dist/editor/ui/Select.js.map +1 -0
- package/dist/editor/ui/TokenField.d.ts +14 -0
- package/dist/editor/ui/TokenField.d.ts.map +1 -0
- package/dist/editor/ui/TokenField.js +41 -0
- package/dist/editor/ui/TokenField.js.map +1 -0
- package/dist/editor/ui/TokenPicker.d.ts +31 -0
- package/dist/editor/ui/TokenPicker.d.ts.map +1 -0
- package/dist/editor/ui/TokenPicker.js +26 -0
- package/dist/editor/ui/TokenPicker.js.map +1 -0
- package/dist/editor/useBuildError.d.ts +7 -0
- package/dist/editor/useBuildError.d.ts.map +1 -0
- package/dist/editor/useBuildError.js +30 -0
- package/dist/editor/useBuildError.js.map +1 -0
- package/dist/editor/useLatestRequest.d.ts +22 -0
- package/dist/editor/useLatestRequest.d.ts.map +1 -0
- package/dist/editor/useLatestRequest.js +49 -0
- package/dist/editor/useLatestRequest.js.map +1 -0
- package/dist/editor-bundle/editor.css +2 -0
- package/dist/editor-bundle/editor.js +83 -0
- package/dist/editor-ui.d.ts +15 -0
- package/dist/editor-ui.d.ts.map +1 -0
- package/dist/editor-ui.js +14 -0
- package/dist/editor-ui.js.map +1 -0
- package/dist/inspector/runtime.d.ts +18 -0
- package/dist/inspector/runtime.d.ts.map +1 -0
- package/dist/inspector/runtime.js +1280 -0
- package/dist/inspector/runtime.js.map +1 -0
- package/dist/preview/main.d.ts +3 -0
- package/dist/preview/main.d.ts.map +1 -0
- package/dist/preview/main.js +320 -0
- package/dist/preview/main.js.map +1 -0
- package/dist/preview/preview.css +40 -0
- package/dist/runtime/index.d.ts +3 -0
- package/dist/runtime/index.d.ts.map +1 -0
- package/dist/runtime/index.js +2 -0
- package/dist/runtime/index.js.map +1 -0
- package/dist/shared/buildError.d.mts +27 -0
- package/dist/shared/buildError.mjs +141 -0
- package/dist/shared/cameraFit.d.mts +16 -0
- package/dist/shared/cameraFit.mjs +47 -0
- package/dist/shared/canvasLayout.d.mts +13 -0
- package/dist/shared/canvasLayout.mjs +171 -0
- package/dist/shared/commentShots.d.mts +12 -0
- package/dist/shared/commentShots.mjs +53 -0
- package/dist/shared/componentExtract.d.mts +43 -0
- package/dist/shared/componentExtract.mjs +136 -0
- package/dist/shared/componentMeta.d.mts +26 -0
- package/dist/shared/componentMeta.mjs +87 -0
- package/dist/shared/componentOps.d.mts +70 -0
- package/dist/shared/componentOps.mjs +407 -0
- package/dist/shared/componentTarget.d.mts +15 -0
- package/dist/shared/componentTarget.mjs +58 -0
- package/dist/shared/components.d.mts +30 -0
- package/dist/shared/components.mjs +106 -0
- package/dist/shared/consolidateCategories.d.mts +2 -0
- package/dist/shared/consolidateCategories.mjs +6 -0
- package/dist/shared/env.d.mts +4 -0
- package/dist/shared/env.mjs +18 -0
- package/dist/shared/gitChanges.d.mts +2 -0
- package/dist/shared/gitChanges.mjs +30 -0
- package/dist/shared/legacyPaths.d.mts +1 -0
- package/dist/shared/legacyPaths.mjs +9 -0
- package/dist/shared/oklab.d.mts +6 -0
- package/dist/shared/oklab.mjs +56 -0
- package/dist/shared/optimizeEntries.d.mts +5 -0
- package/dist/shared/optimizeEntries.mjs +24 -0
- package/dist/shared/packages.d.mts +11 -0
- package/dist/shared/packages.mjs +96 -0
- package/dist/shared/projectFiles.d.mts +23 -0
- package/dist/shared/projectFiles.mjs +72 -0
- package/dist/shared/prompt.d.mts +25 -0
- package/dist/shared/prompt.mjs +217 -0
- package/dist/shared/proposals.d.mts +11 -0
- package/dist/shared/proposals.mjs +42 -0
- package/dist/shared/protocol.d.ts +122 -0
- package/dist/shared/protocol.d.ts.map +1 -0
- package/dist/shared/protocol.js +7 -0
- package/dist/shared/protocol.js.map +1 -0
- package/dist/shared/reviewArchive.d.mts +4 -0
- package/dist/shared/reviewArchive.mjs +19 -0
- package/dist/shared/reviewStore.d.mts +30 -0
- package/dist/shared/reviewStore.mjs +218 -0
- package/dist/shared/reviewVerify.d.mts +21 -0
- package/dist/shared/reviewVerify.mjs +158 -0
- package/dist/shared/sizeModes.d.mts +15 -0
- package/dist/shared/sizeModes.mjs +53 -0
- package/dist/shared/sketches.d.mts +10 -0
- package/dist/shared/sketches.mjs +64 -0
- package/dist/shared/snapshotCheck.d.mts +13 -0
- package/dist/shared/snapshotCheck.mjs +81 -0
- package/dist/shared/timeout.d.mts +1 -0
- package/dist/shared/timeout.mjs +15 -0
- package/dist/shared/tokens.d.ts +2 -0
- package/dist/shared/tokens.d.ts.map +1 -0
- package/dist/shared/tokens.js +2 -0
- package/dist/shared/tokens.js.map +1 -0
- package/dist/shared/types.d.ts +689 -0
- package/dist/shared/types.d.ts.map +1 -0
- package/dist/shared/types.js +13 -0
- package/dist/shared/types.js.map +1 -0
- package/dist/shared/wheelRouting.d.mts +9 -0
- package/dist/shared/wheelRouting.mjs +31 -0
- package/dist/shared/writeScope.mjs +96 -0
- package/dist/snapshots/diff.d.mts +28 -0
- package/dist/snapshots/diff.mjs +263 -0
- package/dist/snapshots/index.d.mts +110 -0
- package/dist/snapshots/index.mjs +638 -0
- package/dist/snapshots/render.d.mts +24 -0
- package/dist/snapshots/render.mjs +250 -0
- package/dist/snapshots/toolOps.d.mts +25 -0
- package/dist/snapshots/toolOps.mjs +69 -0
- package/dist/tokens/adapters/css.mjs +51 -0
- package/dist/tokens/adapters/cssInCode.mjs +314 -0
- package/dist/tokens/adapters/oxcShared.mjs +80 -0
- package/dist/tokens/adapters/preprocessor.mjs +63 -0
- package/dist/tokens/adapters/registry.mjs +53 -0
- package/dist/tokens/adapters/tailwindcss.mjs +424 -0
- package/dist/tokens/adapters/types.mjs +117 -0
- package/dist/tokens/consolidate/index.d.mts +42 -0
- package/dist/tokens/consolidate/index.mjs +111 -0
- package/dist/tokens/consolidate/normalize.mjs +479 -0
- package/dist/tokens/consolidate/plan.mjs +726 -0
- package/dist/tokens/consolidate/scan.mjs +928 -0
- package/dist/tokens/extract.mjs +441 -0
- package/dist/tokens/moduleData.d.mts +14 -0
- package/dist/tokens/moduleData.mjs +32 -0
- package/dist/tokens/opLock.d.mts +4 -0
- package/dist/tokens/opLock.mjs +108 -0
- package/dist/tokens/ops.d.mts +71 -0
- package/dist/tokens/ops.mjs +1511 -0
- package/dist/tokens/pipeline.mjs +813 -0
- package/dist/tokens/report.d.mts +47 -0
- package/dist/tokens/report.mjs +257 -0
- package/dist/tokens/rewrite/code.mjs +172 -0
- package/dist/tokens/rewrite/css.mjs +154 -0
- package/dist/tokens/rewrite/index.mjs +244 -0
- package/dist/tokens/rewrite/tailwind.mjs +288 -0
- package/dist/tokens/rewrite/text.mjs +116 -0
- package/dist/tokens/rewrite/value.mjs +115 -0
- package/dist/tokens/usage.d.mts +97 -0
- package/dist/tokens/usage.mjs +680 -0
- package/dist/vite/agent.d.ts +21 -0
- package/dist/vite/agent.d.ts.map +1 -0
- package/dist/vite/agent.js +165 -0
- package/dist/vite/agent.js.map +1 -0
- package/dist/vite/events.d.ts +27 -0
- package/dist/vite/events.d.ts.map +1 -0
- package/dist/vite/events.js +156 -0
- package/dist/vite/events.js.map +1 -0
- package/dist/vite/layout.d.ts +2 -0
- package/dist/vite/layout.d.ts.map +1 -0
- package/dist/vite/layout.js +4 -0
- package/dist/vite/layout.js.map +1 -0
- package/dist/vite/plugin.d.ts +40 -0
- package/dist/vite/plugin.d.ts.map +1 -0
- package/dist/vite/plugin.js +1264 -0
- package/dist/vite/plugin.js.map +1 -0
- package/dist/vite/requestGuard.d.mts +3 -0
- package/dist/vite/requestGuard.mjs +43 -0
- package/dist/vite/review.d.ts +11 -0
- package/dist/vite/review.d.ts.map +1 -0
- package/dist/vite/review.js +283 -0
- package/dist/vite/review.js.map +1 -0
- package/package.json +106 -1
- package/skills/seji/SKILL.md +400 -0
- package/skills/seji-authoring/SKILL.md +397 -0
- package/skills/seji-tokens/SKILL.md +432 -0
|
@@ -0,0 +1,360 @@
|
|
|
1
|
+
// `seji setup [--app <dir>] [--dry-run] [--json]` (`init` is an alias): set up one Vite +
|
|
2
|
+
// React app so the editor really works, without touching package.json or a lockfile. Repeatable:
|
|
3
|
+
// a second run changes nothing, or only realigns tool-owned files.
|
|
4
|
+
//
|
|
5
|
+
// 1. find the app (cli/app.mjs); never write at a workspace root that is not the app
|
|
6
|
+
// 2. read it: the Vite config through the app's Vite (aliases, Tailwind), index.html → entry →
|
|
7
|
+
// its stylesheets, the entry's provider tree
|
|
8
|
+
// 3. design/ (yours, created once): tokens, tokens.config.json (cssOut next to the CSS entry),
|
|
9
|
+
// surface.config.json (real stylesheets, component globs over directories that exist),
|
|
10
|
+
// providers.tsx (copied from the entry), components.ts, tokens.ts, starter/design.tsx (also
|
|
11
|
+
// a page rendering the app's own component), tsconfig.json
|
|
12
|
+
// 4. tool cache design/.seji/ (gitignored): runtime types, generated token files
|
|
13
|
+
// 5. 0.4.2 layout migrated (cli/migrate.mjs); old project skill copies removed
|
|
14
|
+
// 6. tokens extract on the app's stylesheets, then the build (always writes)
|
|
15
|
+
// 7. one `@import` of tokens.generated.css in the CSS entry (the only write outside design/)
|
|
16
|
+
// 8. doctor --deep
|
|
17
|
+
import { existsSync, readFileSync } from 'node:fs'
|
|
18
|
+
import { homedir } from 'node:os'
|
|
19
|
+
import { dirname, join, relative, resolve, sep } from 'node:path'
|
|
20
|
+
|
|
21
|
+
import { componentExportsOf } from '../shared/components.mjs'
|
|
22
|
+
import { ensureCacheGitignore } from '../shared/projectFiles.mjs'
|
|
23
|
+
import { cssCustomPropertyCount, extractTokensFromCss } from '../tokens/extract.mjs'
|
|
24
|
+
import { DEFAULT_TOKEN_CONFIG, runTokenPipeline } from '../tokens/pipeline.mjs'
|
|
25
|
+
import { appPackages, appProblemText, designLocation, resolveApp } from './app.mjs'
|
|
26
|
+
import { appStyles, loadAppViteConfig, parseModule, resolveModuleFile, resolveSpecifier, rootRelative } from './appScan.mjs'
|
|
27
|
+
import { ensureTokenImport } from './cssImport.mjs'
|
|
28
|
+
import { runDoctor } from './doctor.mjs'
|
|
29
|
+
import {
|
|
30
|
+
DESIGN_PACKAGE,
|
|
31
|
+
PACKAGE_VERSION,
|
|
32
|
+
RUNTIME_PACKAGE,
|
|
33
|
+
STARTER_COMPONENTS_TS,
|
|
34
|
+
STARTER_PRIMITIVE,
|
|
35
|
+
STARTER_PROVIDERS_TSX,
|
|
36
|
+
STARTER_SEMANTIC,
|
|
37
|
+
STARTER_TOKENS_TS,
|
|
38
|
+
declaredRange,
|
|
39
|
+
readPackageJson,
|
|
40
|
+
starterDesign,
|
|
41
|
+
writeScaffold,
|
|
42
|
+
} from './init.mjs'
|
|
43
|
+
import { OLD_PACKAGE, migrateCacheDir, rewriteOldImports, swapOldDependency } from './legacyNames.mjs'
|
|
44
|
+
import { migrateLayout } from './migrate.mjs'
|
|
45
|
+
import { providersFromEntry } from './providers.mjs'
|
|
46
|
+
import { removeProjectSkills } from './skills.mjs'
|
|
47
|
+
import { ensureDesignTypes } from './types.mjs'
|
|
48
|
+
|
|
49
|
+
const toPosix = (file) => file.split(sep).join('/')
|
|
50
|
+
const rel = (root, file) => toPosix(relative(root, file))
|
|
51
|
+
const json = (value) => `${JSON.stringify(value, null, 2)}\n`
|
|
52
|
+
|
|
53
|
+
const COMPONENT_DIRS = ['src/components', 'src/ui', 'src/features', 'components']
|
|
54
|
+
|
|
55
|
+
/** An import specifier for `file` from design/<d>/: through an alias the app has for it, else relative. */
|
|
56
|
+
function importPath(appRoot, file, aliases, fromDir) {
|
|
57
|
+
const noExt = file.replace(/\.(?:tsx|ts|jsx|js)$/, '')
|
|
58
|
+
for (const { find, replacement } of aliases) {
|
|
59
|
+
if (typeof find !== 'string') continue
|
|
60
|
+
const target = resolveSpecifier(find, { importerDir: appRoot, appRoot, aliases: [{ find, replacement }] })
|
|
61
|
+
if (!target) continue
|
|
62
|
+
const inside = toPosix(relative(target, noExt))
|
|
63
|
+
if (inside && !inside.startsWith('..') && !inside.startsWith('/')) return `${find.replace(/\/$/, '')}/${inside}`
|
|
64
|
+
}
|
|
65
|
+
const relPath = toPosix(relative(fromDir, noExt))
|
|
66
|
+
return relPath.startsWith('.') ? relPath : `./${relPath}`
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
/** The app's own component for the starter: the element the entry renders (App), else a component file. */
|
|
70
|
+
async function realComponent(appRoot, { entry, leaf, aliases }) {
|
|
71
|
+
const designDir = join(appRoot, 'design/starter')
|
|
72
|
+
const candidates = []
|
|
73
|
+
if (entry && leaf) {
|
|
74
|
+
try {
|
|
75
|
+
const ast = parseModule(entry.file)
|
|
76
|
+
for (const node of ast.program.body) {
|
|
77
|
+
if (node.type !== 'ImportDeclaration' || (!node.source.value.startsWith('.') && !aliases.length)) continue
|
|
78
|
+
const spec = node.specifiers.find((specifier) => specifier.local.name === leaf)
|
|
79
|
+
if (!spec) continue
|
|
80
|
+
const target = resolveSpecifier(node.source.value, { importerDir: dirname(entry.file), appRoot, aliases })
|
|
81
|
+
const file = target && resolveModuleFile(target)
|
|
82
|
+
if (file) candidates.push({ file, exportName: spec.type === 'ImportDefaultSpecifier' ? 'default' : spec.imported?.name ?? leaf })
|
|
83
|
+
}
|
|
84
|
+
} catch {
|
|
85
|
+
// no entry component
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
if (!candidates.length) {
|
|
89
|
+
const { glob } = await import('tinyglobby')
|
|
90
|
+
const files = await glob(COMPONENT_DIRS.map((dir) => `${dir}/**/*.tsx`), { cwd: appRoot, absolute: true, ignore: ['**/*.test.*', '**/*.stories.*', '**/*.d.ts'] })
|
|
91
|
+
for (const file of files.sort()) {
|
|
92
|
+
const exported = componentExportsOf(readFileSync(file, 'utf8'), rel(appRoot, file))
|
|
93
|
+
if (exported.length) {
|
|
94
|
+
candidates.push({ file, exportName: exported[0].exportName, name: exported[0].name })
|
|
95
|
+
break
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
const pick = candidates[0]
|
|
100
|
+
if (!pick) return null
|
|
101
|
+
const exported = componentExportsOf(readFileSync(pick.file, 'utf8'), rel(appRoot, pick.file))
|
|
102
|
+
const match = exported.find((item) => item.exportName === pick.exportName) ?? exported[0]
|
|
103
|
+
if (!match) return null
|
|
104
|
+
const name = /^(?:StarterBoard|StarterFrame|AppFrame)$/.test(match.name) ? `${match.name}Component` : match.name
|
|
105
|
+
const spec = importPath(appRoot, pick.file, aliases, designDir)
|
|
106
|
+
const importLine =
|
|
107
|
+
match.exportName === 'default'
|
|
108
|
+
? `import ${name} from '${spec}'`
|
|
109
|
+
: `import { ${match.exportName}${match.exportName !== name ? ` as ${name}` : ''} } from '${spec}'`
|
|
110
|
+
return { name, importLine, label: match.name, file: rel(appRoot, pick.file) }
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
export function parseSetupArgs(argv = []) {
|
|
114
|
+
const options = { app: undefined, dryRun: false, json: false, cssFormat: undefined, deep: true }
|
|
115
|
+
for (let i = 0; i < argv.length; i += 1) {
|
|
116
|
+
const token = argv[i]
|
|
117
|
+
if (token === '--dry-run') options.dryRun = true
|
|
118
|
+
else if (token === '--json') options.json = true
|
|
119
|
+
else if (token === '--no-doctor') options.deep = false
|
|
120
|
+
else if (token === '--no-install' || token === '--no-skills') {
|
|
121
|
+
// 0.4.1 / 0.4.2 options: setup installs nothing and writes no skills.
|
|
122
|
+
} else if (token === '--app') {
|
|
123
|
+
if (!argv[i + 1]) throw new Error('--app requires the app directory')
|
|
124
|
+
options.app = argv[i + 1]
|
|
125
|
+
i += 1
|
|
126
|
+
} else if (token.startsWith('--app=')) options.app = token.slice('--app='.length)
|
|
127
|
+
else if (token === '--css-format') {
|
|
128
|
+
options.cssFormat = argv[i + 1]
|
|
129
|
+
i += 1
|
|
130
|
+
} else if (token.startsWith('--css-format=')) options.cssFormat = token.slice('--css-format='.length)
|
|
131
|
+
else throw new Error(`unknown setup option: ${token}`)
|
|
132
|
+
}
|
|
133
|
+
if (options.cssFormat !== undefined && options.cssFormat !== 'theme' && options.cssFormat !== 'root') {
|
|
134
|
+
throw new Error(`invalid --css-format "${options.cssFormat}". Expected "theme" or "root".`)
|
|
135
|
+
}
|
|
136
|
+
return options
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
/**
|
|
140
|
+
* Run setup. Returns `{ ok, exitCode, app, results, notes, todos, doctor, … }`; exitCode 2 when no
|
|
141
|
+
* single app was found (the message says what to run), 1 when doctor fails.
|
|
142
|
+
*/
|
|
143
|
+
// Without the starter tokens the starter card keeps its look through the var() fallbacks; use
|
|
144
|
+
// those literals so the app's token report lists no unknown starter variables.
|
|
145
|
+
const withoutStarterTokens = (source) => source.replace(/var\(--[a-z-]+, ([^()]+)\)/g, '$1')
|
|
146
|
+
|
|
147
|
+
export async function runSetup({ cwd = process.cwd(), app, dryRun = false, cssFormat: forcedFormat, deep = true, home = homedir(), env = process.env, doctorOptions = {} } = {}) {
|
|
148
|
+
const found = await resolveApp({ cwd, app })
|
|
149
|
+
if (found.status !== 'ok') return { ok: false, exitCode: 2, version: PACKAGE_VERSION, problem: found.status, message: appProblemText(found, 'setup'), candidates: found.candidates }
|
|
150
|
+
const root = found.root
|
|
151
|
+
const results = []
|
|
152
|
+
const notes = []
|
|
153
|
+
const todos = []
|
|
154
|
+
const push = (items) => results.push(...[items].flat())
|
|
155
|
+
|
|
156
|
+
const missing = Object.entries(appPackages(root, found.traits)).filter(([, dir]) => !dir).map(([name]) => name)
|
|
157
|
+
if (missing.length) {
|
|
158
|
+
return { ok: false, exitCode: 2, version: PACKAGE_VERSION, app: found.rel, root, message: `${found.rel}: not installed: ${missing.join(', ')}. Run the app's package install first (seji installs nothing).` }
|
|
159
|
+
}
|
|
160
|
+
const design = designLocation(found, cwd)
|
|
161
|
+
if (design.external) return setupExistingDesign({ cwd, found, design, dryRun, deep, home, env, doctorOptions })
|
|
162
|
+
// 0.5.x: design/.design-surface/ → design/.seji/ before anything writes the cache.
|
|
163
|
+
const cacheMove = migrateCacheDir(root, { dryRun })
|
|
164
|
+
push(cacheMove)
|
|
165
|
+
for (const item of cacheMove) if (item.warning) notes.push(`${item.file}: ${item.detail}`)
|
|
166
|
+
const vite = await loadAppViteConfig(root)
|
|
167
|
+
if (!vite.ok) {
|
|
168
|
+
// The config may import the old package that is no longer installed: migrate the names anyway,
|
|
169
|
+
// so the next install + setup works without the old package.
|
|
170
|
+
const renamed = [...rewriteOldImports([root], { dryRun }), ...swapOldDependency(root, { version: PACKAGE_VERSION, dryRun })]
|
|
171
|
+
const message = renamed.length
|
|
172
|
+
? `${found.rel}: ${vite.error}\nSwitched ${renamed.map((item) => item.file).join(', ')} from ${OLD_PACKAGE} to ${DESIGN_PACKAGE}. Run the app's package install, then run seji setup again.`
|
|
173
|
+
: `${found.rel}: ${vite.error}`
|
|
174
|
+
return { ok: false, exitCode: 2, version: PACKAGE_VERSION, app: found.rel, root, results: [...results, ...renamed], message }
|
|
175
|
+
}
|
|
176
|
+
const aliases = vite.aliases
|
|
177
|
+
const styles = appStyles(root, { aliases, tailwindPlugin: vite.tailwind })
|
|
178
|
+
const cssFormat = forcedFormat ?? styles.cssFormat
|
|
179
|
+
const cssEntry = styles.cssEntry
|
|
180
|
+
const outDir = cssEntry ? dirname(cssEntry) : styles.entry ? dirname(styles.entry.file) : join(root, 'src')
|
|
181
|
+
const cssOutAbs = join(outDir, 'tokens.generated.css')
|
|
182
|
+
const cssOut = rel(root, cssOutAbs)
|
|
183
|
+
if (!cssEntry) todos.push(`${styles.entry ? rel(root, styles.entry.file) : 'the entry'} imports no stylesheet: import "./${rel(dirname(styles.entry?.file ?? cssOutAbs), cssOutAbs)}" there so the app sees the tokens (frames load it through surface.config.json)`)
|
|
184
|
+
|
|
185
|
+
// design/ (yours): created once, never overwritten.
|
|
186
|
+
const scanDirs = ['src', 'design'].filter((dir) => dir === 'design' || existsSync(join(root, dir)))
|
|
187
|
+
const tokenConfig = { ...DEFAULT_TOKEN_CONFIG, cssOut, cssFormat, scanDirs }
|
|
188
|
+
delete tokenConfig.localAliases
|
|
189
|
+
const componentDirs = COMPONENT_DIRS.filter((dir) => existsSync(join(root, dir)))
|
|
190
|
+
if (!componentDirs.length) notes.push(`no component directory (${COMPONENT_DIRS.slice(0, 2).join(', ')}, …): surface.config.json lists no component groups yet`)
|
|
191
|
+
const surfaceConfig = {
|
|
192
|
+
dir: 'design',
|
|
193
|
+
css: [...styles.stylesheets.map((file) => rootRelative(root, file)), ...(cssEntry ? [] : [`/${cssOut}`])],
|
|
194
|
+
componentGroups: componentDirs.length ? [{ id: 'components', label: 'Components', globs: componentDirs.map((dir) => `${dir}/**/*.tsx`) }] : [],
|
|
195
|
+
title: readPackageJson(root)?.name ?? 'seji',
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
const designDir = join(root, 'design')
|
|
199
|
+
const providers = styles.entry ? providersFromEntry(styles.entry.file, { designDir }) : { ok: false, reason: 'no entry module found' }
|
|
200
|
+
if (!providers.ok) notes.push(`providers: ${providers.reason}; design/providers.tsx passes children through`)
|
|
201
|
+
const component = await realComponent(root, { entry: styles.entry, leaf: providers.ok ? providers.leaf : null, aliases })
|
|
202
|
+
|
|
203
|
+
const firstSetup = !existsSync(join(root, 'design/providers.tsx'))
|
|
204
|
+
// An app with its own CSS variables gets those as tokens (extract below), not the starter set.
|
|
205
|
+
const appCss = styles.stylesheets.filter((file) => file !== cssOutAbs)
|
|
206
|
+
const appTokens = cssCustomPropertyCount(root, appCss) > 0
|
|
207
|
+
push(
|
|
208
|
+
writeScaffold(
|
|
209
|
+
root,
|
|
210
|
+
[
|
|
211
|
+
{ rel: 'design/tokens/primitive.tokens.json', content: appTokens ? '{}\n' : json(STARTER_PRIMITIVE), ...(appTokens ? { detail: 'empty: tokens come from the app CSS' } : {}) },
|
|
212
|
+
{ rel: 'design/tokens/semantic.tokens.json', content: appTokens ? '{}\n' : json(STARTER_SEMANTIC) },
|
|
213
|
+
{ rel: 'design/tokens/component.tokens.json', content: '{}\n' },
|
|
214
|
+
{ rel: 'design/tokens.config.json', content: json(tokenConfig), detail: `cssOut ${cssOut}, cssFormat ${cssFormat}` },
|
|
215
|
+
{ rel: 'design/surface.config.json', content: json(surfaceConfig) },
|
|
216
|
+
{ rel: 'design/tokens.ts', content: STARTER_TOKENS_TS },
|
|
217
|
+
{
|
|
218
|
+
rel: 'design/providers.tsx',
|
|
219
|
+
content: providers.ok ? providers.text : STARTER_PROVIDERS_TSX,
|
|
220
|
+
detail: providers.ok ? `from ${rel(root, styles.entry.file)}: ${providers.wrappers.length ? providers.wrappers.join(' > ') : 'no wrappers'}` : undefined,
|
|
221
|
+
},
|
|
222
|
+
{ rel: 'design/components.ts', content: STARTER_COMPONENTS_TS },
|
|
223
|
+
{ rel: 'design/starter/design.tsx', content: appTokens ? withoutStarterTokens(starterDesign(component)) : starterDesign(component), detail: component ? `renders ${component.label} from ${component.file}` : undefined },
|
|
224
|
+
],
|
|
225
|
+
{ dryRun },
|
|
226
|
+
),
|
|
227
|
+
)
|
|
228
|
+
if (providers.ok && firstSetup) {
|
|
229
|
+
notes.push(...providers.notes.map((note) => `providers: ${note}`))
|
|
230
|
+
todos.push(...providers.todos.map((todo) => `design/providers.tsx: ${todo}`))
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
// Tool cache + old layout.
|
|
234
|
+
push(ensureCacheGitignore(root, { dryRun }))
|
|
235
|
+
push(migrateLayout(root, { dryRun }))
|
|
236
|
+
push(await ensureDesignTypes(root, { dryRun }))
|
|
237
|
+
if (!dryRun) push(removeProjectSkills(root, { home }).map((item) => ({ ...item, detail: 'old project copy; skills are global now' })))
|
|
238
|
+
|
|
239
|
+
// Tokens: the app's variables become tokens, then the build writes the outputs.
|
|
240
|
+
let extract = null
|
|
241
|
+
let build = null
|
|
242
|
+
if (!dryRun) {
|
|
243
|
+
const cssFiles = styles.stylesheets.filter((file) => file !== cssOutAbs).map((file) => rel(root, file))
|
|
244
|
+
if (cssFiles.length) {
|
|
245
|
+
try {
|
|
246
|
+
extract = await extractTokensFromCss({ root, files: cssFiles })
|
|
247
|
+
const added = extract.addedPrimitives.length + extract.addedSemantics.length
|
|
248
|
+
if (added) results.push({ file: 'design/tokens/', status: 'updated', detail: `tokens extract: ${extract.addedPrimitives.length} primitive, ${extract.addedSemantics.length} semantic from ${cssFiles.join(', ')}` })
|
|
249
|
+
for (const item of extract.renamed) notes.push(`token ${item.cssName} stored as ${item.to} (${item.from} collides with another token)`)
|
|
250
|
+
if (extract.dark.length) notes.push(`${extract.dark.length} dark-mode value(s) recorded on their tokens ($extensions["design-surface"].modes.dark)`)
|
|
251
|
+
} catch (error) {
|
|
252
|
+
todos.push(`tokens extract failed: ${error instanceof Error ? error.message : String(error)}`)
|
|
253
|
+
}
|
|
254
|
+
}
|
|
255
|
+
const cssFile = resolve(root, cssOut)
|
|
256
|
+
const cssBefore = existsSync(cssFile) ? readFileSync(cssFile, 'utf8') : null
|
|
257
|
+
try {
|
|
258
|
+
build = await runTokenPipeline({ root, check: false })
|
|
259
|
+
// The build always writes; a repeat run with the same tokens reports no change.
|
|
260
|
+
const same = cssBefore !== null && readFileSync(cssFile, 'utf8') === cssBefore
|
|
261
|
+
results.push({ file: cssOut, status: same ? 'unchanged' : 'built', detail: `${build.counts.total} tokens` })
|
|
262
|
+
} catch (error) {
|
|
263
|
+
build = { error: error instanceof Error ? error.message : String(error) }
|
|
264
|
+
results.push({ file: cssOut, status: 'built', detail: 'with validation errors (see doctor)' })
|
|
265
|
+
todos.push(`token validation: ${(error.validationErrors ?? [build.error]).join('; ')}`)
|
|
266
|
+
}
|
|
267
|
+
if (build?.unknown?.length) todos.push(`${build.unknown.length} CSS variable(s) used but not tokens: ${build.unknown.join(', ')}`)
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
// The one write outside design/.
|
|
271
|
+
if (cssEntry) {
|
|
272
|
+
const added = ensureTokenImport(cssEntry, cssOutAbs, { dryRun, displayRoot: root })
|
|
273
|
+
if (added.status === 'added') results.push({ file: added.file, status: 'updated', detail: `+ @import "${added.spec}"; (line ${added.line}): the only change outside design/` })
|
|
274
|
+
else if (added.status === 'skipped') todos.push(added.reason)
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
// 0.5.x: '@rien7/design-surface' imports and dependency → @rien7/seji (after the Vite config was read
|
|
278
|
+
// through the package it imports).
|
|
279
|
+
push(rewriteOldImports([root], { dryRun }))
|
|
280
|
+
const swapped = swapOldDependency(root, { version: PACKAGE_VERSION, dryRun })
|
|
281
|
+
push(swapped)
|
|
282
|
+
if (swapped.length) todos.push(`package.json now depends on ${DESIGN_PACKAGE} instead of @rien7/design-surface: run the app's package install`)
|
|
283
|
+
for (const name of [RUNTIME_PACKAGE, DESIGN_PACKAGE]) {
|
|
284
|
+
const declared = declaredRange(root, name)
|
|
285
|
+
if (declared && !(name === DESIGN_PACKAGE && swapped.length)) notes.push(`${name} ${declared} is a project dependency; no longer needed (dev uses the CLI's runtime). Removable; setup leaves package.json alone.`)
|
|
286
|
+
}
|
|
287
|
+
|
|
288
|
+
// From the cwd, so the doctor shows the app as `apps/web`, like setup does.
|
|
289
|
+
const doctor = deep && !dryRun ? await runDoctor({ root: cwd, app: relative(resolve(cwd), root) || '.', home, env, deep: true, ...doctorOptions }) : null
|
|
290
|
+
const ok = doctor ? doctor.ok : true
|
|
291
|
+
return {
|
|
292
|
+
ok,
|
|
293
|
+
exitCode: ok ? 0 : 1,
|
|
294
|
+
version: PACKAGE_VERSION,
|
|
295
|
+
dryRun,
|
|
296
|
+
app: found.rel,
|
|
297
|
+
root,
|
|
298
|
+
cssFormat,
|
|
299
|
+
cssEntry: cssEntry ? rel(root, cssEntry) : null,
|
|
300
|
+
cssOut,
|
|
301
|
+
component,
|
|
302
|
+
results,
|
|
303
|
+
notes,
|
|
304
|
+
todos,
|
|
305
|
+
doctor,
|
|
306
|
+
next: found.how === 'flag' ? `seji dev --app ${found.rel}` : 'seji dev',
|
|
307
|
+
}
|
|
308
|
+
}
|
|
309
|
+
|
|
310
|
+
/**
|
|
311
|
+
* An existing design dir outside the app (a 0.4.2-era repo with `design/` at its root): used as
|
|
312
|
+
* it is. No scaffold, no token extraction, no app edits; only its own cache is refreshed.
|
|
313
|
+
*/
|
|
314
|
+
async function setupExistingDesign({ cwd, found, design, dryRun, deep, home, env, doctorOptions }) {
|
|
315
|
+
const root = found.root
|
|
316
|
+
const results = []
|
|
317
|
+
const notes = [`using existing design/ at ${design.rel} (nothing created in ${found.rel}/design)`]
|
|
318
|
+
const todos = []
|
|
319
|
+
const cacheMove = migrateCacheDir(design.home, { dryRun })
|
|
320
|
+
results.push(...cacheMove)
|
|
321
|
+
for (const item of cacheMove) if (item.warning) notes.push(`${item.file}: ${item.detail}`)
|
|
322
|
+
results.push(...rewriteOldImports([root, design.home], { dryRun }))
|
|
323
|
+
for (const dir of new Set([root, design.home])) {
|
|
324
|
+
const swapped = swapOldDependency(dir, { version: PACKAGE_VERSION, dryRun }).map((item) => ({ ...item, file: rel(cwd, join(dir, item.file)) }))
|
|
325
|
+
results.push(...swapped)
|
|
326
|
+
if (swapped.length) todos.push(`${swapped[0].file} now depends on ${DESIGN_PACKAGE} instead of @rien7/design-surface: run the package install`)
|
|
327
|
+
}
|
|
328
|
+
results.push(ensureCacheGitignore(design.home, { dryRun }))
|
|
329
|
+
// The 0.4.2 layout (generated files in design/, .consolidate/, sessions) is migrated here too:
|
|
330
|
+
// doctor's `layout` check points to setup for exactly this kind of design dir.
|
|
331
|
+
results.push(...migrateLayout(design.home, { dryRun }))
|
|
332
|
+
results.push(...[await ensureDesignTypes(design.home, { dryRun })].flat())
|
|
333
|
+
if (!dryRun && existsSync(join(design.designDir, 'tokens'))) {
|
|
334
|
+
try {
|
|
335
|
+
const build = await runTokenPipeline({ root: design.home, check: false })
|
|
336
|
+
results.push({ file: 'design/tokens/', status: 'built', detail: `${build.counts.total} tokens` })
|
|
337
|
+
} catch (error) {
|
|
338
|
+
todos.push(`token validation: ${(error.validationErrors ?? [error instanceof Error ? error.message : String(error)]).join('; ')}`)
|
|
339
|
+
}
|
|
340
|
+
}
|
|
341
|
+
const doctor = deep && !dryRun ? await runDoctor({ root: cwd, app: relative(resolve(cwd), root) || '.', designDir: design.designDir, home, env, deep: true, ...doctorOptions }) : null
|
|
342
|
+
const ok = doctor ? doctor.ok : true
|
|
343
|
+
return { ok, exitCode: ok ? 0 : 1, version: PACKAGE_VERSION, dryRun, app: found.rel, root, designDir: design.designDir, results, notes, todos, doctor, next: found.how === 'flag' ? `seji dev --app ${found.rel}` : 'seji dev' }
|
|
344
|
+
}
|
|
345
|
+
|
|
346
|
+
const LABELS = { created: 'CREATE ', skipped: 'KEEP ', updated: 'UPDATE ', unchanged: 'UNCHANGED', removed: 'REMOVE ', moved: 'MOVE ', built: 'BUILD ', failed: 'FAILED ' }
|
|
347
|
+
|
|
348
|
+
export function formatSetup(report, { formatDoctor } = {}) {
|
|
349
|
+
if (report.message && !report.results) return report.message
|
|
350
|
+
const lines = [`APP ${report.app}${report.dryRun ? ' (dry run: nothing written)' : ''}`]
|
|
351
|
+
for (const item of report.results) {
|
|
352
|
+
if (item.status === 'unchanged') continue
|
|
353
|
+
lines.push(`${LABELS[item.status] ?? item.status.toUpperCase().padEnd(9)} ${item.file}${item.detail ? ` (${item.detail})` : ''}`)
|
|
354
|
+
}
|
|
355
|
+
for (const note of report.notes) lines.push(`NOTE ${note}`)
|
|
356
|
+
for (const todo of report.todos) lines.push(`TODO ${todo}`)
|
|
357
|
+
if (report.doctor && formatDoctor) lines.push('', formatDoctor(report.doctor))
|
|
358
|
+
lines.push('', report.ok ? `Next: ${report.next} # the editor at /__seji` : 'Fix the doctor failures above, then run seji setup again.')
|
|
359
|
+
return lines.join('\n')
|
|
360
|
+
}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
// Node side of shared/sketches.mjs: misplaced sketch files (and the git helpers, re-exported).
|
|
2
|
+
import { readdirSync, readFileSync } from 'node:fs'
|
|
3
|
+
import { join } from 'node:path'
|
|
4
|
+
|
|
5
|
+
import { exportsReactComponent } from '../shared/sketches.mjs'
|
|
6
|
+
|
|
7
|
+
export { gitHead, workingTreeChanges } from '../shared/gitChanges.mjs'
|
|
8
|
+
|
|
9
|
+
const CODE_RE = /\.(?:tsx|jsx|ts|js|mts|mjs)$/
|
|
10
|
+
const SKIP_DIRS = new Set(['node_modules', '.seji', 'sketches', 'tokens'])
|
|
11
|
+
const EXEMPT_ROOT_FILES = /^(?:components|tokens|providers)\.(?:tsx?|jsx?|mts|mjs)$/
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* design/ files outside any sketches/ folder that export React components (root-relative paths).
|
|
15
|
+
* Exempt: design.tsx, providers.tsx, components / tokens index files, anything under tokens/.
|
|
16
|
+
*/
|
|
17
|
+
export function misplacedSketches(root, designDir = 'design') {
|
|
18
|
+
const found = []
|
|
19
|
+
const walk = (dir, rel, depth) => {
|
|
20
|
+
let entries
|
|
21
|
+
try {
|
|
22
|
+
entries = readdirSync(dir, { withFileTypes: true })
|
|
23
|
+
} catch {
|
|
24
|
+
return
|
|
25
|
+
}
|
|
26
|
+
for (const entry of entries) {
|
|
27
|
+
const relPath = `${rel}/${entry.name}`
|
|
28
|
+
if (entry.isDirectory()) {
|
|
29
|
+
if (!SKIP_DIRS.has(entry.name) && !entry.name.startsWith('.') && depth < 8) walk(join(dir, entry.name), relPath, depth + 1)
|
|
30
|
+
continue
|
|
31
|
+
}
|
|
32
|
+
if (!entry.isFile() || !CODE_RE.test(entry.name) || /\.d\.[mc]?ts$/.test(entry.name)) continue
|
|
33
|
+
if (/^(?:design|providers)\.(?:tsx|jsx)$/.test(entry.name)) continue
|
|
34
|
+
if (depth === 0 && EXEMPT_ROOT_FILES.test(entry.name)) continue
|
|
35
|
+
if (/^index\./.test(entry.name) && /(?:^|\/)(?:components|tokens)$/.test(rel)) continue
|
|
36
|
+
let code = ''
|
|
37
|
+
try {
|
|
38
|
+
code = readFileSync(join(dir, entry.name), 'utf8')
|
|
39
|
+
} catch {
|
|
40
|
+
continue
|
|
41
|
+
}
|
|
42
|
+
if (exportsReactComponent(code)) found.push(relPath)
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
walk(join(root, designDir), designDir, 0)
|
|
46
|
+
return found.sort()
|
|
47
|
+
}
|
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
// The agent skills are tool-owned and user-level: `seji skills install` writes the
|
|
2
|
+
// package's three skills into the agents' global skill directories, never into a project.
|
|
3
|
+
//
|
|
4
|
+
// ~/.agents/skills/ always: the shared user-level location (Codex reads $HOME/.agents/skills,
|
|
5
|
+
// other agents follow the same convention)
|
|
6
|
+
// ~/.claude/skills/ when Claude Code is set up (~/.claude, or $CLAUDE_CONFIG_DIR, exists)
|
|
7
|
+
//
|
|
8
|
+
// (Codex's older $CODEX_HOME/skills is not written: current Codex reads $HOME/.agents/skills and
|
|
9
|
+
// lists same-named skills twice when both exist.)
|
|
10
|
+
//
|
|
11
|
+
// Syncing a skill makes `<dir>/<skill>/` match the package: files written when they differ, files
|
|
12
|
+
// the package no longer ships removed. Other skills in the same directory are never touched.
|
|
13
|
+
import { existsSync, mkdirSync, readdirSync, readFileSync, rmSync, statSync, writeFileSync } from 'node:fs'
|
|
14
|
+
import { homedir } from 'node:os'
|
|
15
|
+
import { dirname, isAbsolute, join, relative, resolve, sep } from 'node:path'
|
|
16
|
+
import { fileURLToPath } from 'node:url'
|
|
17
|
+
|
|
18
|
+
export const SKILL_NAMES = ['seji', 'seji-tokens', 'seji-authoring']
|
|
19
|
+
/** The 0.5.x names of the same skills (design-surface → seji): removed wherever skills are installed. */
|
|
20
|
+
export const LEGACY_SKILL_NAMES = ['design-surface', 'design-surface-tokens', 'design-surface-authoring']
|
|
21
|
+
export const SKILLS_ROOT = fileURLToPath(new URL('../../skills', import.meta.url))
|
|
22
|
+
export const SKILLS_FIX = 'seji skills install'
|
|
23
|
+
|
|
24
|
+
export function listFiles(dir, base = dir, out = []) {
|
|
25
|
+
if (!existsSync(dir)) return out
|
|
26
|
+
for (const entry of readdirSync(dir).sort()) {
|
|
27
|
+
const abs = join(dir, entry)
|
|
28
|
+
if (statSync(abs).isDirectory()) listFiles(abs, base, out)
|
|
29
|
+
else out.push(relative(base, abs))
|
|
30
|
+
}
|
|
31
|
+
return out
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
function removeEmptyDirs(dir, keep) {
|
|
35
|
+
if (!existsSync(dir) || !statSync(dir).isDirectory()) return
|
|
36
|
+
for (const entry of readdirSync(dir)) removeEmptyDirs(join(dir, entry), false)
|
|
37
|
+
if (!keep && !readdirSync(dir).length) rmSync(dir, { recursive: true })
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
/** Make `dstDir` match `srcDir`. `label(abs)` names files in `results` (default: relative to `root`). */
|
|
41
|
+
export function syncToolOwnedDir(srcDir, dstDir, root, results) {
|
|
42
|
+
if (!existsSync(srcDir)) return
|
|
43
|
+
const relOf = typeof root === 'function' ? root : (abs) => relative(root, abs).split(sep).join('/')
|
|
44
|
+
const shipped = listFiles(srcDir)
|
|
45
|
+
const shippedSet = new Set(shipped)
|
|
46
|
+
for (const file of shipped) {
|
|
47
|
+
const srcPath = join(srcDir, file)
|
|
48
|
+
const dstPath = join(dstDir, file)
|
|
49
|
+
const content = readFileSync(srcPath)
|
|
50
|
+
if (existsSync(dstPath) && statSync(dstPath).isFile()) {
|
|
51
|
+
if (readFileSync(dstPath).equals(content)) {
|
|
52
|
+
results.push({ file: relOf(dstPath), status: 'unchanged' })
|
|
53
|
+
continue
|
|
54
|
+
}
|
|
55
|
+
writeFileSync(dstPath, content)
|
|
56
|
+
results.push({ file: relOf(dstPath), status: 'updated' })
|
|
57
|
+
continue
|
|
58
|
+
}
|
|
59
|
+
if (existsSync(dstPath)) rmSync(dstPath, { recursive: true })
|
|
60
|
+
mkdirSync(dirname(dstPath), { recursive: true })
|
|
61
|
+
writeFileSync(dstPath, content)
|
|
62
|
+
results.push({ file: relOf(dstPath), status: 'created' })
|
|
63
|
+
}
|
|
64
|
+
for (const file of listFiles(dstDir)) {
|
|
65
|
+
if (shippedSet.has(file)) continue
|
|
66
|
+
rmSync(join(dstDir, file))
|
|
67
|
+
results.push({ file: relOf(join(dstDir, file)), status: 'removed' })
|
|
68
|
+
}
|
|
69
|
+
removeEmptyDirs(dstDir, true)
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
/** `~/…` for paths under `home`. */
|
|
73
|
+
export const tildify = (abs, home = homedir()) => {
|
|
74
|
+
const rel = relative(home, abs)
|
|
75
|
+
return rel && !rel.startsWith('..') && !isAbsolute(rel) ? `~/${rel.split(sep).join('/')}` : abs.split(sep).join('/')
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
/** The global skill directories to write, `[{ agent, dir }]`. `dirs` (from `--dir`) replaces the defaults. */
|
|
79
|
+
export function globalSkillDirs({ home = homedir(), env = process.env, dirs } = {}) {
|
|
80
|
+
if (dirs?.length) return dirs.map((dir) => ({ agent: 'custom', dir: resolve(dir) }))
|
|
81
|
+
const targets = [{ agent: 'agents', dir: join(home, '.agents', 'skills') }]
|
|
82
|
+
const claudeHome = env.CLAUDE_CONFIG_DIR ? resolve(env.CLAUDE_CONFIG_DIR) : join(home, '.claude')
|
|
83
|
+
if (existsSync(claudeHome)) targets.push({ agent: 'claude', dir: join(claudeHome, 'skills') })
|
|
84
|
+
return targets
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
/** Write the three skills into every global skill directory. */
|
|
88
|
+
export function installSkills({ home = homedir(), env = process.env, dirs, skillsRoot = SKILLS_ROOT } = {}) {
|
|
89
|
+
return globalSkillDirs({ home, env, dirs }).map(({ agent, dir }) => {
|
|
90
|
+
const results = []
|
|
91
|
+
for (const skill of SKILL_NAMES) syncToolOwnedDir(join(skillsRoot, skill), join(dir, skill), (abs) => tildify(abs, home), results)
|
|
92
|
+
for (const skill of LEGACY_SKILL_NAMES) {
|
|
93
|
+
if (!existsSync(join(dir, skill))) continue
|
|
94
|
+
rmSync(join(dir, skill), { recursive: true, force: true })
|
|
95
|
+
results.push({ file: `${tildify(join(dir, skill), home)}/`, status: 'removed' })
|
|
96
|
+
}
|
|
97
|
+
const changed = results.filter((entry) => entry.status !== 'unchanged').length
|
|
98
|
+
return { agent, dir: tildify(dir, home), changed, results }
|
|
99
|
+
})
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
/** 'current' | 'outdated' | 'missing' for one installed skill directory. */
|
|
103
|
+
export function skillState(dir, skill, skillsRoot = SKILLS_ROOT) {
|
|
104
|
+
if (!existsSync(dir)) return 'missing'
|
|
105
|
+
const shipped = listFiles(join(skillsRoot, skill))
|
|
106
|
+
const local = listFiles(dir)
|
|
107
|
+
if (local.length !== shipped.length) return 'outdated'
|
|
108
|
+
const localSet = new Set(local)
|
|
109
|
+
const same = shipped.every((file) => localSet.has(file) && readFileSync(join(dir, file)).equals(readFileSync(join(skillsRoot, skill, file))))
|
|
110
|
+
return same ? 'current' : 'outdated'
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
/** `[{ agent, dir, skills: { name: state }, legacy: [old skill names still there] }]` for every global skill directory. */
|
|
114
|
+
export function globalSkillStatus({ home = homedir(), env = process.env, dirs, skillsRoot = SKILLS_ROOT } = {}) {
|
|
115
|
+
return globalSkillDirs({ home, env, dirs }).map(({ agent, dir }) => ({
|
|
116
|
+
agent,
|
|
117
|
+
dir: tildify(dir, home),
|
|
118
|
+
skills: Object.fromEntries(SKILL_NAMES.map((skill) => [skill, skillState(join(dir, skill), skill, skillsRoot)])),
|
|
119
|
+
legacy: LEGACY_SKILL_NAMES.filter((skill) => existsSync(join(dir, skill))),
|
|
120
|
+
}))
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
// Before 0.4.2 init copied the skills into the project. Those copies would shadow (or duplicate)
|
|
124
|
+
// the global ones, so init removes them. Only the tool's own names (and their 0.5.x names) are touched.
|
|
125
|
+
const PROJECT_SKILL_PARENTS = [['.agents', 'skills'], ['.claude', 'skills']]
|
|
126
|
+
|
|
127
|
+
/** Project-level copies of the tool skills, as project-relative paths. */
|
|
128
|
+
export function projectSkillDirs(root, { home = homedir() } = {}) {
|
|
129
|
+
if (resolve(root) === resolve(home)) return []
|
|
130
|
+
const found = []
|
|
131
|
+
for (const parent of PROJECT_SKILL_PARENTS) {
|
|
132
|
+
for (const skill of [...SKILL_NAMES, ...LEGACY_SKILL_NAMES]) {
|
|
133
|
+
if (existsSync(join(root, ...parent, skill))) found.push([...parent, skill].join('/'))
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
return found
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
/** Remove the project-level tool skills (and the skills / agent dirs they leave empty). */
|
|
140
|
+
export function removeProjectSkills(root, { home = homedir() } = {}) {
|
|
141
|
+
const removed = projectSkillDirs(root, { home })
|
|
142
|
+
for (const rel of removed) rmSync(join(root, rel), { recursive: true, force: true })
|
|
143
|
+
for (const [agentDir, skillsDir] of PROJECT_SKILL_PARENTS) {
|
|
144
|
+
if (!removed.some((rel) => rel.startsWith(`${agentDir}/`))) continue
|
|
145
|
+
for (const dir of [join(root, agentDir, skillsDir), join(root, agentDir)]) {
|
|
146
|
+
if (existsSync(dir) && statSync(dir).isDirectory() && !readdirSync(dir).length) rmSync(dir, { recursive: true })
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
return removed.map((rel) => ({ file: `${rel}/`, status: 'removed' }))
|
|
150
|
+
}
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
// `seji snapshot …` and the snapshot flags of `verify`.
|
|
2
|
+
import { resolve } from 'node:path'
|
|
3
|
+
|
|
4
|
+
import {
|
|
5
|
+
captureBaselines,
|
|
6
|
+
compareSnapshots,
|
|
7
|
+
decideSnapshots,
|
|
8
|
+
emptyCaptureError,
|
|
9
|
+
snapshotView,
|
|
10
|
+
waitForBaselines,
|
|
11
|
+
} from '../snapshots/index.mjs'
|
|
12
|
+
|
|
13
|
+
const VALUE_FLAGS = new Set(['url', 'config', 'reason', 'item', 'timeout'])
|
|
14
|
+
const BOOL_FLAGS = new Set(['force', 'snapshots', 'dry-run'])
|
|
15
|
+
|
|
16
|
+
export function parseFlags(argv, allowed) {
|
|
17
|
+
const flags = { item: [] }
|
|
18
|
+
const positionals = []
|
|
19
|
+
for (let i = 0; i < argv.length; i += 1) {
|
|
20
|
+
const token = argv[i]
|
|
21
|
+
if (!token.startsWith('--')) {
|
|
22
|
+
positionals.push(token)
|
|
23
|
+
continue
|
|
24
|
+
}
|
|
25
|
+
const eq = token.indexOf('=')
|
|
26
|
+
const key = eq > 2 ? token.slice(2, eq) : token.slice(2)
|
|
27
|
+
if (!allowed.includes(key)) throw new Error(`unknown option: --${key}`)
|
|
28
|
+
if (BOOL_FLAGS.has(key)) {
|
|
29
|
+
flags[key] = true
|
|
30
|
+
continue
|
|
31
|
+
}
|
|
32
|
+
if (!VALUE_FLAGS.has(key)) throw new Error(`unknown option: --${key}`)
|
|
33
|
+
let value = eq > 2 ? token.slice(eq + 1) : argv[i + 1]
|
|
34
|
+
if (eq <= 2) i += 1
|
|
35
|
+
if (value === undefined || value === '') throw new Error(`--${key} requires a value`)
|
|
36
|
+
if (key === 'item') flags.item.push(value)
|
|
37
|
+
else flags[key] = value
|
|
38
|
+
}
|
|
39
|
+
return { flags, positionals }
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
const USAGE = {
|
|
43
|
+
capture: 'snapshot capture <design> [<itemId>...] [--force] [--url <dev-url>] [--config <vite-config>]',
|
|
44
|
+
wait: 'snapshot wait <design> [<itemId>...] [--timeout <seconds>]',
|
|
45
|
+
compare: 'snapshot compare <design> [<itemId>...] [--url <dev-url>] [--config <vite-config>]',
|
|
46
|
+
show: 'snapshot show <design> <itemId>',
|
|
47
|
+
accept: 'snapshot accept <design> <itemId> [<frame>...]',
|
|
48
|
+
reject: 'snapshot reject <design> <itemId> [<frame>...] --reason "<why>"',
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
export async function runSnapshotCommand({ root = process.cwd(), argv = [] } = {}) {
|
|
52
|
+
const [sub, ...rest] = argv
|
|
53
|
+
if (!sub || !USAGE[sub]) {
|
|
54
|
+
throw new Error(`unknown snapshot subcommand: ${sub ?? '(missing)'} (expected ${Object.keys(USAGE).join(', ')})`)
|
|
55
|
+
}
|
|
56
|
+
const allowed = {
|
|
57
|
+
capture: ['force', 'url', 'config'],
|
|
58
|
+
wait: ['timeout'],
|
|
59
|
+
compare: ['url', 'config'],
|
|
60
|
+
show: [],
|
|
61
|
+
accept: [],
|
|
62
|
+
reject: ['reason'],
|
|
63
|
+
}[sub]
|
|
64
|
+
const { flags, positionals } = parseFlags(rest, allowed)
|
|
65
|
+
const [design, ...ids] = positionals
|
|
66
|
+
if (!design) throw new Error(`usage: seji ${USAGE[sub]}`)
|
|
67
|
+
const render = {
|
|
68
|
+
root,
|
|
69
|
+
design,
|
|
70
|
+
...(flags.url ? { url: flags.url } : {}),
|
|
71
|
+
...(flags.config ? { configFile: resolve(root, flags.config) } : {}),
|
|
72
|
+
}
|
|
73
|
+
const itemIds = ids.length ? ids : undefined
|
|
74
|
+
if (sub === 'wait') {
|
|
75
|
+
const seconds = flags.timeout === undefined ? undefined : Number(flags.timeout)
|
|
76
|
+
if (seconds !== undefined && !(seconds >= 0)) throw new Error('--timeout must be a number of seconds')
|
|
77
|
+
const result = await waitForBaselines({ root, design, itemIds, ...(seconds !== undefined ? { timeoutMs: seconds * 1000 } : {}) })
|
|
78
|
+
if (result.capturing.length) throw new Error(`baseline capture still running for ${result.capturing.join(', ')}`)
|
|
79
|
+
return result
|
|
80
|
+
}
|
|
81
|
+
if (sub === 'capture') {
|
|
82
|
+
const result = await captureBaselines({ ...render, itemIds, force: Boolean(flags.force) })
|
|
83
|
+
// Items the dev server (or another run) is capturing: wait so the baseline exists on return.
|
|
84
|
+
if (result.inProgress?.length) {
|
|
85
|
+
const waited = await waitForBaselines({ root, design, itemIds: result.inProgress })
|
|
86
|
+
if (waited.capturing.length) throw new Error(`baseline capture still running for ${waited.capturing.join(', ')}`)
|
|
87
|
+
}
|
|
88
|
+
const error = emptyCaptureError(result)
|
|
89
|
+
if (error) throw new Error(error)
|
|
90
|
+
return result
|
|
91
|
+
}
|
|
92
|
+
if (sub === 'compare') {
|
|
93
|
+
return compareSnapshots({ ...render, itemIds })
|
|
94
|
+
}
|
|
95
|
+
const [itemId, ...frames] = ids
|
|
96
|
+
if (!itemId) throw new Error(`usage: seji ${USAGE[sub]}`)
|
|
97
|
+
if (sub === 'show') return snapshotView(root, design, itemId)
|
|
98
|
+
const result = decideSnapshots({
|
|
99
|
+
root,
|
|
100
|
+
design,
|
|
101
|
+
itemId,
|
|
102
|
+
frames,
|
|
103
|
+
decision: sub === 'accept' ? 'accepted' : 'rejected',
|
|
104
|
+
reason: flags.reason,
|
|
105
|
+
})
|
|
106
|
+
return { design, item: itemId, status: result.item.status, frames: result.frames, check: result.check }
|
|
107
|
+
}
|