@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,344 @@
|
|
|
1
|
+
// design/providers.tsx from the app's entry: the JSX tree passed to `createRoot(…).render(…)`
|
|
2
|
+
// (or `ReactDOM.render`), read from the entry's syntax tree (@babel/parser). Every wrapper
|
|
3
|
+
// around the app element is copied with the imports and top-level values it uses; the app
|
|
4
|
+
// element becomes `{children}`. BrowserRouter / HashRouter become MemoryRouter (frames have no
|
|
5
|
+
// URL bar), a RouterProvider leaf becomes a MemoryRouter around the frame, StrictMode and
|
|
6
|
+
// Suspense are kept. A wrapper whose props need values the entry computes at runtime cannot be
|
|
7
|
+
// copied: it is left out and listed as a TODO. All ranges come from AST node offsets.
|
|
8
|
+
import { readFileSync } from 'node:fs'
|
|
9
|
+
import { dirname, relative, resolve, sep } from 'node:path'
|
|
10
|
+
|
|
11
|
+
import { parseModule } from './appScan.mjs'
|
|
12
|
+
|
|
13
|
+
const toPosix = (file) => file.split(sep).join('/')
|
|
14
|
+
const ROUTER_MODULES = new Set(['react-router-dom', 'react-router'])
|
|
15
|
+
const URL_ROUTERS = new Set(['BrowserRouter', 'HashRouter'])
|
|
16
|
+
const SKIP_KEYS = new Set(['loc', 'start', 'end', 'range', 'extra', 'leadingComments', 'trailingComments', 'innerComments', 'typeAnnotation', 'returnType', 'typeParameters', 'typeArguments'])
|
|
17
|
+
|
|
18
|
+
function* children(node) {
|
|
19
|
+
for (const key of Object.keys(node)) {
|
|
20
|
+
if (SKIP_KEYS.has(key)) continue
|
|
21
|
+
const value = node[key]
|
|
22
|
+
if (Array.isArray(value)) {
|
|
23
|
+
for (const item of value) if (item && typeof item.type === 'string') yield [item, key]
|
|
24
|
+
} else if (value && typeof value.type === 'string') yield [value, key]
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
function walk(node, visit, parent = null, key = null) {
|
|
29
|
+
if (!node || typeof node.type !== 'string') return
|
|
30
|
+
if (visit(node, parent, key) === false) return
|
|
31
|
+
// Type-only syntax never references runtime values.
|
|
32
|
+
if (node.type.startsWith('TS') && !['TSAsExpression', 'TSSatisfiesExpression', 'TSNonNullExpression'].includes(node.type)) return
|
|
33
|
+
for (const [child, childKey] of children(node)) walk(child, visit, node, childKey)
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
function patternNames(node, out) {
|
|
37
|
+
if (!node) return out
|
|
38
|
+
if (node.type === 'Identifier') out.add(node.name)
|
|
39
|
+
else if (node.type === 'ObjectPattern') for (const prop of node.properties) patternNames(prop.type === 'RestElement' ? prop.argument : prop.value, out)
|
|
40
|
+
else if (node.type === 'ArrayPattern') for (const element of node.elements) patternNames(element, out)
|
|
41
|
+
else if (node.type === 'AssignmentPattern') patternNames(node.left, out)
|
|
42
|
+
else if (node.type === 'RestElement') patternNames(node.argument, out)
|
|
43
|
+
return out
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
/** Names bound anywhere inside `node` (params, variables, functions, classes, catch params). */
|
|
47
|
+
function boundNames(node) {
|
|
48
|
+
const out = new Set()
|
|
49
|
+
walk(node, (current) => {
|
|
50
|
+
if (/Function|ObjectMethod|ClassMethod/.test(current.type) && Array.isArray(current.params)) {
|
|
51
|
+
for (const param of current.params) patternNames(param, out)
|
|
52
|
+
if (current.id && current.type !== 'FunctionExpression') out.add(current.id.name)
|
|
53
|
+
}
|
|
54
|
+
if (current.type === 'VariableDeclarator') patternNames(current.id, out)
|
|
55
|
+
if (current.type === 'CatchClause') patternNames(current.param, out)
|
|
56
|
+
if (current.type === 'ClassDeclaration' && current.id) out.add(current.id.name)
|
|
57
|
+
})
|
|
58
|
+
return out
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
/** Identifiers `node` reads that it does not bind itself. */
|
|
62
|
+
function freeNames(node) {
|
|
63
|
+
const used = new Set()
|
|
64
|
+
walk(node, (current, parent, key) => {
|
|
65
|
+
if (current.type === 'Identifier') {
|
|
66
|
+
if (!parent) return
|
|
67
|
+
if ((parent.type === 'MemberExpression' || parent.type === 'OptionalMemberExpression') && key === 'property' && !parent.computed) return
|
|
68
|
+
if ((parent.type === 'ObjectProperty' || parent.type === 'ObjectMethod' || parent.type === 'ClassProperty' || parent.type === 'ClassMethod') && key === 'key' && !parent.computed) return
|
|
69
|
+
if (parent.type === 'MetaProperty' || parent.type === 'LabeledStatement' || parent.type === 'BreakStatement' || parent.type === 'ContinueStatement') return
|
|
70
|
+
used.add(current.name)
|
|
71
|
+
}
|
|
72
|
+
if (current.type === 'JSXAttribute') {
|
|
73
|
+
if (current.value) walk(current.value, (inner, innerParent, innerKey) => {
|
|
74
|
+
if (inner.type === 'Identifier' && !(innerParent && (innerParent.type === 'MemberExpression' || innerParent.type === 'OptionalMemberExpression') && innerKey === 'property' && !innerParent.computed) && !(innerParent?.type === 'ObjectProperty' && innerKey === 'key' && !innerParent.computed)) used.add(inner.name)
|
|
75
|
+
if (inner.type === 'JSXOpeningElement') used.add(elementRoot(inner.name))
|
|
76
|
+
})
|
|
77
|
+
return false
|
|
78
|
+
}
|
|
79
|
+
if (current.type === 'JSXOpeningElement') {
|
|
80
|
+
const name = elementRoot(current.name)
|
|
81
|
+
if (name && (/^[A-Z]/.test(name) || current.name.type === 'JSXMemberExpression')) used.add(name)
|
|
82
|
+
}
|
|
83
|
+
})
|
|
84
|
+
const bound = boundNames(node)
|
|
85
|
+
return [...used].filter((name) => !bound.has(name))
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
function elementRoot(name) {
|
|
89
|
+
if (!name) return null
|
|
90
|
+
if (name.type === 'JSXIdentifier') return name.name
|
|
91
|
+
if (name.type === 'JSXMemberExpression') return elementRoot(name.object)
|
|
92
|
+
return null
|
|
93
|
+
}
|
|
94
|
+
const elementName = (element) => (element.type === 'JSXElement' ? elementRoot(element.openingElement.name) : null)
|
|
95
|
+
const fullName = (name) => (name.type === 'JSXMemberExpression' ? `${fullName(name.object)}.${name.property.name}` : name.name)
|
|
96
|
+
|
|
97
|
+
const elementChildren = (element) =>
|
|
98
|
+
element.children.filter((child) => child.type === 'JSXElement' || child.type === 'JSXFragment')
|
|
99
|
+
|
|
100
|
+
function findRenderCall(program) {
|
|
101
|
+
let found = null
|
|
102
|
+
walk(program, (node) => {
|
|
103
|
+
if (found) return false
|
|
104
|
+
if (
|
|
105
|
+
node.type === 'CallExpression' &&
|
|
106
|
+
(node.callee.type === 'MemberExpression' || node.callee.type === 'OptionalMemberExpression') &&
|
|
107
|
+
!node.callee.computed &&
|
|
108
|
+
node.callee.property.name === 'render' &&
|
|
109
|
+
(node.arguments[0]?.type === 'JSXElement' || node.arguments[0]?.type === 'JSXFragment')
|
|
110
|
+
) {
|
|
111
|
+
found = node
|
|
112
|
+
return false
|
|
113
|
+
}
|
|
114
|
+
})
|
|
115
|
+
return found
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
/**
|
|
119
|
+
* Analyse the entry: `{ ok, wrappers, leaf, source, todos, notes, text }` where `text` is the
|
|
120
|
+
* providers.tsx content (null when the entry has no render call).
|
|
121
|
+
*/
|
|
122
|
+
export function providersFromEntry(entryFile, { designDir, code = readFileSync(entryFile, 'utf8') } = {}) {
|
|
123
|
+
let ast
|
|
124
|
+
try {
|
|
125
|
+
ast = parseModule(entryFile, code)
|
|
126
|
+
} catch (error) {
|
|
127
|
+
return { ok: false, reason: `${entryFile} does not parse: ${error instanceof Error ? error.message : String(error)}` }
|
|
128
|
+
}
|
|
129
|
+
const program = ast.program
|
|
130
|
+
const call = findRenderCall(program)
|
|
131
|
+
if (!call) return { ok: false, reason: 'no createRoot(…).render(<…/>) call in the entry' }
|
|
132
|
+
|
|
133
|
+
// Top-level bindings: imports and declarations.
|
|
134
|
+
const imports = new Map()
|
|
135
|
+
const decls = new Map()
|
|
136
|
+
for (const statement of program.body) {
|
|
137
|
+
if (statement.type === 'ImportDeclaration') {
|
|
138
|
+
for (const specifier of statement.specifiers) {
|
|
139
|
+
imports.set(specifier.local.name, {
|
|
140
|
+
source: statement.source.value,
|
|
141
|
+
kind: specifier.type === 'ImportDefaultSpecifier' ? 'default' : specifier.type === 'ImportNamespaceSpecifier' ? 'namespace' : 'named',
|
|
142
|
+
imported: specifier.type === 'ImportSpecifier' ? (specifier.imported.name ?? specifier.imported.value) : null,
|
|
143
|
+
type: statement.importKind === 'type' || specifier.importKind === 'type',
|
|
144
|
+
})
|
|
145
|
+
}
|
|
146
|
+
continue
|
|
147
|
+
}
|
|
148
|
+
const declaration = statement.type === 'ExportNamedDeclaration' && statement.declaration ? statement.declaration : statement
|
|
149
|
+
if (declaration.type === 'VariableDeclaration') {
|
|
150
|
+
for (const declarator of declaration.declarations) for (const name of patternNames(declarator.id, new Set())) decls.set(name, statement)
|
|
151
|
+
} else if ((declaration.type === 'FunctionDeclaration' || declaration.type === 'ClassDeclaration') && declaration.id) {
|
|
152
|
+
decls.set(declaration.id.name, statement)
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
const nested = boundNames(program)
|
|
156
|
+
const renderStatement = program.body.find((statement) => statement.start <= call.start && statement.end >= call.end)
|
|
157
|
+
|
|
158
|
+
// What a set of names needs: imports, top-level statements; unsafe when it reaches a value the
|
|
159
|
+
// entry only has at runtime (a nested binding, the render statement, the DOM root).
|
|
160
|
+
const closure = (names) => {
|
|
161
|
+
const need = { imports: new Set(), statements: new Set(), unsafe: null }
|
|
162
|
+
const queue = [...names]
|
|
163
|
+
const seen = new Set()
|
|
164
|
+
while (queue.length) {
|
|
165
|
+
const name = queue.shift()
|
|
166
|
+
if (seen.has(name)) continue
|
|
167
|
+
seen.add(name)
|
|
168
|
+
if (imports.has(name)) {
|
|
169
|
+
need.imports.add(name)
|
|
170
|
+
continue
|
|
171
|
+
}
|
|
172
|
+
const statement = decls.get(name)
|
|
173
|
+
if (statement) {
|
|
174
|
+
if (statement === renderStatement) {
|
|
175
|
+
need.unsafe = `\`${name}\` is defined where the app is mounted`
|
|
176
|
+
continue
|
|
177
|
+
}
|
|
178
|
+
const text = code.slice(statement.start, statement.end)
|
|
179
|
+
if (/\b(?:createRoot|hydrateRoot|getElementById)\b/.test(text) && freeNames(statement).some((free) => ['createRoot', 'hydrateRoot', 'document'].includes(free))) {
|
|
180
|
+
need.unsafe = `\`${name}\` uses the page's DOM root`
|
|
181
|
+
continue
|
|
182
|
+
}
|
|
183
|
+
need.statements.add(statement)
|
|
184
|
+
queue.push(...freeNames(statement))
|
|
185
|
+
continue
|
|
186
|
+
}
|
|
187
|
+
if (nested.has(name)) need.unsafe = `\`${name}\` is a value the entry computes at runtime`
|
|
188
|
+
}
|
|
189
|
+
return need
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
// The wrapper chain: root element → … → the app element (the leaf).
|
|
193
|
+
const root = call.arguments[0]
|
|
194
|
+
const wrappers = []
|
|
195
|
+
let current = root
|
|
196
|
+
for (;;) {
|
|
197
|
+
const kids = elementChildren(current)
|
|
198
|
+
if (!kids.length) break
|
|
199
|
+
let next = kids.length === 1 ? kids[0] : null
|
|
200
|
+
if (!next) {
|
|
201
|
+
const isApp = (kid) => {
|
|
202
|
+
const name = elementName(kid)
|
|
203
|
+
return name && imports.get(name)?.source?.startsWith('.') && (name === 'App' || imports.get(name).kind === 'default')
|
|
204
|
+
}
|
|
205
|
+
next = kids.find(isApp) ?? kids.find((kid) => elementChildren(kid).length) ?? kids[kids.length - 1]
|
|
206
|
+
}
|
|
207
|
+
wrappers.push({ node: current, siblings: kids.filter((kid) => kid !== next) })
|
|
208
|
+
current = next
|
|
209
|
+
}
|
|
210
|
+
const leaf = current
|
|
211
|
+
const leafName = elementName(leaf)
|
|
212
|
+
|
|
213
|
+
const edits = []
|
|
214
|
+
const needed = { imports: new Set(), statements: new Set() }
|
|
215
|
+
const todos = []
|
|
216
|
+
const notes = []
|
|
217
|
+
const addNeed = (need) => {
|
|
218
|
+
for (const name of need.imports) needed.imports.add(name)
|
|
219
|
+
for (const statement of need.statements) needed.statements.add(statement)
|
|
220
|
+
}
|
|
221
|
+
const extraImports = []
|
|
222
|
+
const kept = []
|
|
223
|
+
|
|
224
|
+
for (const { node, siblings } of wrappers) {
|
|
225
|
+
if (node.type === 'JSXFragment') {
|
|
226
|
+
kept.push('<>')
|
|
227
|
+
} else {
|
|
228
|
+
const opening = node.openingElement
|
|
229
|
+
const name = elementName(node)
|
|
230
|
+
const shown = fullName(opening.name)
|
|
231
|
+
const ownNames = [name, ...opening.attributes.flatMap((attribute) => freeNames(attribute))]
|
|
232
|
+
const need = closure(ownNames)
|
|
233
|
+
const declaredHere = !imports.has(name) && !decls.has(name)
|
|
234
|
+
if (need.unsafe || declaredHere) {
|
|
235
|
+
// Left out: keep its children only.
|
|
236
|
+
edits.push({ start: opening.start, end: opening.end, text: '' })
|
|
237
|
+
if (node.closingElement) edits.push({ start: node.closingElement.start, end: node.closingElement.end, text: '' })
|
|
238
|
+
todos.push(`<${shown}> was left out: ${need.unsafe ?? `${name} is not imported by the entry`}. Add it to design/providers.tsx by hand if frames need it.`)
|
|
239
|
+
continue
|
|
240
|
+
}
|
|
241
|
+
const imported = imports.get(name)
|
|
242
|
+
if (imported && ROUTER_MODULES.has(imported.source) && URL_ROUTERS.has(imported.imported ?? '')) {
|
|
243
|
+
edits.push({ start: opening.name.start, end: opening.name.end, text: 'MemoryRouter' })
|
|
244
|
+
if (node.closingElement) edits.push({ start: node.closingElement.name.start, end: node.closingElement.name.end, text: 'MemoryRouter' })
|
|
245
|
+
for (const attribute of opening.attributes) {
|
|
246
|
+
if (attribute.type === 'JSXAttribute' && attribute.name.name === 'window') edits.push({ start: attribute.start, end: attribute.end, text: '' })
|
|
247
|
+
}
|
|
248
|
+
extraImports.push({ source: imported.source, name: 'MemoryRouter' })
|
|
249
|
+
addNeed(closure(opening.attributes.flatMap((attribute) => freeNames(attribute))))
|
|
250
|
+
notes.push(`${shown} → MemoryRouter (frames have no address bar)`)
|
|
251
|
+
kept.push('MemoryRouter')
|
|
252
|
+
} else {
|
|
253
|
+
addNeed(need)
|
|
254
|
+
kept.push(shown)
|
|
255
|
+
}
|
|
256
|
+
}
|
|
257
|
+
for (const sibling of siblings) {
|
|
258
|
+
const need = closure(freeNames(sibling))
|
|
259
|
+
if (need.unsafe) {
|
|
260
|
+
edits.push({ start: sibling.start, end: sibling.end, text: '' })
|
|
261
|
+
todos.push(`<${elementName(sibling) ?? 'element'}> next to the app was left out: ${need.unsafe}.`)
|
|
262
|
+
} else addNeed(need)
|
|
263
|
+
}
|
|
264
|
+
}
|
|
265
|
+
|
|
266
|
+
const leafImport = leafName ? imports.get(leafName) : null
|
|
267
|
+
if (leafName === 'RouterProvider' && leafImport && ROUTER_MODULES.has(leafImport.source)) {
|
|
268
|
+
edits.push({ start: leaf.start, end: leaf.end, text: '<MemoryRouter>{children}</MemoryRouter>' })
|
|
269
|
+
extraImports.push({ source: leafImport.source, name: 'MemoryRouter' })
|
|
270
|
+
notes.push('RouterProvider → a MemoryRouter around each frame (router hooks work; the app\'s routes are not mounted)')
|
|
271
|
+
} else {
|
|
272
|
+
edits.push({ start: leaf.start, end: leaf.end, text: '{children}' })
|
|
273
|
+
}
|
|
274
|
+
|
|
275
|
+
// The tree's text with the edits applied (latest first, so offsets stay valid).
|
|
276
|
+
let jsx = code.slice(root.start, root.end)
|
|
277
|
+
for (const edit of [...edits].sort((a, b) => b.start - a.start)) {
|
|
278
|
+
jsx = jsx.slice(0, edit.start - root.start) + edit.text + jsx.slice(edit.end - root.start)
|
|
279
|
+
}
|
|
280
|
+
const lineStart = code.lastIndexOf('\n', root.start - 1) + 1
|
|
281
|
+
const baseIndent = /^[ \t]*/.exec(code.slice(lineStart, root.start))[0].length
|
|
282
|
+
const body = jsx
|
|
283
|
+
.split('\n')
|
|
284
|
+
.map((line, index) => (index === 0 ? line : line.replace(new RegExp(`^[ \\t]{0,${baseIndent}}`), '')))
|
|
285
|
+
.filter((line) => line.trim() !== '')
|
|
286
|
+
.map((line) => ` ${line}`)
|
|
287
|
+
.join('\n')
|
|
288
|
+
|
|
289
|
+
// Imports: per source, in the entry's order, relative paths rebased to design/.
|
|
290
|
+
const rebase = (source) => {
|
|
291
|
+
if (!source.startsWith('.')) return source
|
|
292
|
+
const target = resolve(dirname(entryFile), source)
|
|
293
|
+
const rel = toPosix(relative(designDir, target))
|
|
294
|
+
return rel.startsWith('.') ? rel : `./${rel}`
|
|
295
|
+
}
|
|
296
|
+
const bySource = new Map()
|
|
297
|
+
const entry = (source) => {
|
|
298
|
+
if (!bySource.has(source)) bySource.set(source, { default: null, namespace: null, named: [] })
|
|
299
|
+
return bySource.get(source)
|
|
300
|
+
}
|
|
301
|
+
for (const [local, info] of imports) {
|
|
302
|
+
if (!needed.imports.has(local)) continue
|
|
303
|
+
const group = entry(info.source)
|
|
304
|
+
if (info.kind === 'default') group.default = local
|
|
305
|
+
else if (info.kind === 'namespace') group.namespace = local
|
|
306
|
+
else group.named.push(info.imported === local ? `${info.type ? 'type ' : ''}${local}` : `${info.type ? 'type ' : ''}${info.imported} as ${local}`)
|
|
307
|
+
}
|
|
308
|
+
for (const { source, name } of extraImports) {
|
|
309
|
+
const group = entry(source)
|
|
310
|
+
if (!group.named.includes(name)) group.named.push(name)
|
|
311
|
+
}
|
|
312
|
+
const importLines = ["import type { ReactNode } from 'react'"]
|
|
313
|
+
for (const [source, group] of bySource) {
|
|
314
|
+
const target = rebase(source)
|
|
315
|
+
if (group.namespace) importLines.push(`import ${group.default ? `${group.default}, ` : ''}* as ${group.namespace} from '${target}'`)
|
|
316
|
+
const parts = []
|
|
317
|
+
if (group.default && !group.namespace) parts.push(group.default)
|
|
318
|
+
if (group.named.length) parts.push(`{ ${group.named.join(', ')} }`)
|
|
319
|
+
if (parts.length) importLines.push(`import ${parts.join(', ')} from '${target}'`)
|
|
320
|
+
}
|
|
321
|
+
const statements = program.body.filter((statement) => needed.statements.has(statement)).map((statement) => code.slice(statement.start, statement.end))
|
|
322
|
+
|
|
323
|
+
const relEntry = toPosix(relative(resolve(designDir, '..'), entryFile))
|
|
324
|
+
const header = [
|
|
325
|
+
`// Generated once by seji setup from ${relEntry}: the providers around the app, so design`,
|
|
326
|
+
'// frames render inside the same context. Yours to edit; setup never overwrites this file.',
|
|
327
|
+
...notes.map((note) => `// Changed: ${note}.`),
|
|
328
|
+
...todos.map((todo) => `// TODO: ${todo}`),
|
|
329
|
+
]
|
|
330
|
+
const text = [
|
|
331
|
+
...header,
|
|
332
|
+
...importLines,
|
|
333
|
+
'',
|
|
334
|
+
...(statements.length ? [...statements, ''] : []),
|
|
335
|
+
'export function Providers({ children }: { children: ReactNode }) {',
|
|
336
|
+
' return (',
|
|
337
|
+
body,
|
|
338
|
+
' )',
|
|
339
|
+
'}',
|
|
340
|
+
'',
|
|
341
|
+
].join('\n')
|
|
342
|
+
|
|
343
|
+
return { ok: true, wrappers: kept, leaf: leafName, todos, notes, text }
|
|
344
|
+
}
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
import crypto from 'node:crypto'
|
|
2
|
+
|
|
3
|
+
import { mutateReview } from '../shared/reviewStore.mjs'
|
|
4
|
+
import { resolveReminder } from '../shared/sketches.mjs'
|
|
5
|
+
import { gitHead, workingTreeChanges } from '../shared/gitChanges.mjs'
|
|
6
|
+
|
|
7
|
+
const VALID_STATUSES = new Set(['in_progress', 'resolved'])
|
|
8
|
+
|
|
9
|
+
// Locked read-modify-write of one item; concurrent editor/CLI writes are serialized.
|
|
10
|
+
function updateItem(root, design, itemId, update) {
|
|
11
|
+
if (!design) throw new Error('design id is required')
|
|
12
|
+
let updated
|
|
13
|
+
const { file } = mutateReview(root, design, (review) => {
|
|
14
|
+
const index = review.items.findIndex((entry) => entry?.id === itemId)
|
|
15
|
+
if (index === -1) throw new Error(`review item not found in ${design}: ${itemId}`)
|
|
16
|
+
updated = update(review.items[index])
|
|
17
|
+
return { ...review, items: review.items.map((entry, idx) => (idx === index ? updated : entry)) }
|
|
18
|
+
})
|
|
19
|
+
return { item: updated, file }
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
/** Moving a comment to in_progress records the commit the work starts from (`baseCommit`). */
|
|
23
|
+
function startedAt(root, existing) {
|
|
24
|
+
if (existing.kind !== 'comment' || existing.status === 'in_progress') return {}
|
|
25
|
+
const head = gitHead(root)
|
|
26
|
+
return head ? { baseCommit: head } : {}
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
/** Reminder for a product-targeted comment resolved with changes only under design/ (never blocks). */
|
|
30
|
+
function reminderFor(root, item, changedFiles) {
|
|
31
|
+
if (item?.status !== 'resolved' || item.kind !== 'comment') return null
|
|
32
|
+
return resolveReminder(item, changedFiles === undefined ? workingTreeChanges(root, item.baseCommit) : changedFiles)
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
export function replyReviewItem({ root = process.cwd(), argv = [], changedFiles } = {}) {
|
|
36
|
+
let resolveItem = false
|
|
37
|
+
const positionals = []
|
|
38
|
+
for (const token of argv) {
|
|
39
|
+
if (token === '--resolve') {
|
|
40
|
+
resolveItem = true
|
|
41
|
+
continue
|
|
42
|
+
}
|
|
43
|
+
if (token.startsWith('--')) {
|
|
44
|
+
throw new Error(`unknown option: ${token}`)
|
|
45
|
+
}
|
|
46
|
+
positionals.push(token)
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
const [design, itemId, message] = positionals
|
|
50
|
+
if (!design || !itemId || !message || !message.trim()) {
|
|
51
|
+
throw new Error('reply requires <design> <itemId> "<message>" [--resolve]')
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
const now = new Date().toISOString()
|
|
55
|
+
const reply = {
|
|
56
|
+
id: `reply-${crypto.randomUUID?.() ?? `${Date.now()}-${Math.random().toString(36).slice(2, 8)}`}`,
|
|
57
|
+
author: 'agent',
|
|
58
|
+
body: message.trim(),
|
|
59
|
+
createdAt: now,
|
|
60
|
+
}
|
|
61
|
+
const { item, file } = updateItem(root, design, itemId, (existing) => ({
|
|
62
|
+
...existing,
|
|
63
|
+
thread: Array.isArray(existing.thread) ? [...existing.thread, reply] : [reply],
|
|
64
|
+
updatedAt: now,
|
|
65
|
+
...(resolveItem ? { status: 'resolved', resolvedAt: existing.resolvedAt ?? now } : {}),
|
|
66
|
+
}))
|
|
67
|
+
return { item, reply, file, reminder: resolveItem ? reminderFor(root, item, changedFiles) : null }
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
export function updateReviewItemStatus({ root = process.cwd(), argv = [], changedFiles } = {}) {
|
|
71
|
+
let agentReply
|
|
72
|
+
const positionals = []
|
|
73
|
+
for (let i = 0; i < argv.length; i += 1) {
|
|
74
|
+
const token = argv[i]
|
|
75
|
+
if (token === '--reply') {
|
|
76
|
+
const next = argv[i + 1]
|
|
77
|
+
if (next === undefined) throw new Error('--reply requires a summary string')
|
|
78
|
+
agentReply = next
|
|
79
|
+
i += 1
|
|
80
|
+
continue
|
|
81
|
+
}
|
|
82
|
+
if (token.startsWith('--reply=')) {
|
|
83
|
+
agentReply = token.slice('--reply='.length)
|
|
84
|
+
continue
|
|
85
|
+
}
|
|
86
|
+
if (token.startsWith('--')) {
|
|
87
|
+
throw new Error(`unknown option: ${token}`)
|
|
88
|
+
}
|
|
89
|
+
positionals.push(token)
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
const [design, itemId, status] = positionals
|
|
93
|
+
if (!design || !itemId || !status) {
|
|
94
|
+
throw new Error('status requires <design> <itemId> <in_progress|resolved> [--reply "<summary>"]')
|
|
95
|
+
}
|
|
96
|
+
if (!VALID_STATUSES.has(status)) {
|
|
97
|
+
throw new Error(`Invalid status "${status}". Expected "in_progress" or "resolved".`)
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
const now = new Date().toISOString()
|
|
101
|
+
const result = updateItem(root, design, itemId, (existing) => ({
|
|
102
|
+
...existing,
|
|
103
|
+
status,
|
|
104
|
+
updatedAt: now,
|
|
105
|
+
...(status === 'resolved' ? { resolvedAt: now } : {}),
|
|
106
|
+
...(agentReply !== undefined ? { agentReply } : {}),
|
|
107
|
+
...(status === 'in_progress' ? startedAt(root, existing) : {}),
|
|
108
|
+
}))
|
|
109
|
+
return { ...result, reminder: status === 'resolved' ? reminderFor(root, result.item, changedFiles) : null }
|
|
110
|
+
}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
// Semver precedence (semver.org §11): major.minor.patch numerically; a version with a
|
|
2
|
+
// prerelease ranks below the same version without one (0.4.2-rc.0 < 0.4.2); prerelease
|
|
3
|
+
// identifiers compare dot by dot (numeric ones numerically, others in ASCII order, numeric below
|
|
4
|
+
// alphanumeric, a shorter list below a longer one with the same prefix); build metadata (+…) is
|
|
5
|
+
// ignored. A leading `v` / range operator (`^`, `~`, `>=`) is skipped.
|
|
6
|
+
|
|
7
|
+
/** `{ core: [major, minor, patch], pre: [identifier…] }` */
|
|
8
|
+
export function parseVersion(version) {
|
|
9
|
+
const text = String(version ?? '').trim().replace(/^[^\d]*/, '').split('+')[0]
|
|
10
|
+
const dash = text.indexOf('-')
|
|
11
|
+
const core = (dash < 0 ? text : text.slice(0, dash)).split('.').slice(0, 3)
|
|
12
|
+
const pre = dash < 0 ? [] : text.slice(dash + 1).split('.').filter((id) => id !== '')
|
|
13
|
+
return { core: [0, 1, 2].map((i) => Number.parseInt(core[i] ?? '0', 10) || 0), pre }
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
const NUMERIC = /^\d+$/
|
|
17
|
+
function compareIdentifier(a, b) {
|
|
18
|
+
const [na, nb] = [NUMERIC.test(a), NUMERIC.test(b)]
|
|
19
|
+
if (na && nb) {
|
|
20
|
+
// Arbitrary length: compare by length first, then lexically.
|
|
21
|
+
const [x, y] = [a.replace(/^0+(?=\d)/, ''), b.replace(/^0+(?=\d)/, '')]
|
|
22
|
+
if (x.length !== y.length) return x.length < y.length ? -1 : 1
|
|
23
|
+
return x === y ? 0 : x < y ? -1 : 1
|
|
24
|
+
}
|
|
25
|
+
if (na !== nb) return na ? -1 : 1
|
|
26
|
+
return a === b ? 0 : a < b ? -1 : 1
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
/** -1 / 0 / 1 by semver precedence. */
|
|
30
|
+
export function compareVersions(a, b) {
|
|
31
|
+
const [x, y] = [parseVersion(a), parseVersion(b)]
|
|
32
|
+
for (let i = 0; i < 3; i += 1) if (x.core[i] !== y.core[i]) return x.core[i] < y.core[i] ? -1 : 1
|
|
33
|
+
if (!x.pre.length || !y.pre.length) return x.pre.length === y.pre.length ? 0 : x.pre.length ? -1 : 1
|
|
34
|
+
for (let i = 0; i < Math.min(x.pre.length, y.pre.length); i += 1) {
|
|
35
|
+
const order = compareIdentifier(x.pre[i], y.pre[i])
|
|
36
|
+
if (order) return order
|
|
37
|
+
}
|
|
38
|
+
return x.pre.length === y.pre.length ? 0 : x.pre.length < y.pre.length ? -1 : 1
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
/** Same major.minor (prerelease ignored). */
|
|
42
|
+
export function sameMinor(a, b) {
|
|
43
|
+
const [x, y] = [parseVersion(a).core, parseVersion(b).core]
|
|
44
|
+
return x[0] === y[0] && x[1] === y[1]
|
|
45
|
+
}
|