@rien7/seji 0.0.0 → 0.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (412) hide show
  1. package/bin/design-surface.mjs +6 -0
  2. package/bin/postinstall.mjs +19 -0
  3. package/bin/seji.mjs +573 -0
  4. package/dist/agent/host.d.mts +34 -0
  5. package/dist/agent/host.mjs +387 -0
  6. package/dist/agent/messages.d.mts +9 -0
  7. package/dist/agent/messages.mjs +70 -0
  8. package/dist/agent/runtimes.mjs +157 -0
  9. package/dist/cli/app.mjs +321 -0
  10. package/dist/cli/appScan.mjs +284 -0
  11. package/dist/cli/catalog.mjs +78 -0
  12. package/dist/cli/component.mjs +165 -0
  13. package/dist/cli/consolidate.mjs +159 -0
  14. package/dist/cli/cssImport.mjs +68 -0
  15. package/dist/cli/dev.mjs +335 -0
  16. package/dist/cli/doctor.mjs +306 -0
  17. package/dist/cli/init.mjs +338 -0
  18. package/dist/cli/legacyNames.mjs +266 -0
  19. package/dist/cli/migrate.mjs +163 -0
  20. package/dist/cli/prompt.mjs +34 -0
  21. package/dist/cli/propose.mjs +208 -0
  22. package/dist/cli/providers.mjs +344 -0
  23. package/dist/cli/reviewOps.mjs +110 -0
  24. package/dist/cli/semver.mjs +45 -0
  25. package/dist/cli/setup.mjs +357 -0
  26. package/dist/cli/sketches.mjs +47 -0
  27. package/dist/cli/skills.mjs +150 -0
  28. package/dist/cli/snapshot.mjs +107 -0
  29. package/dist/cli/tokenOps.mjs +120 -0
  30. package/dist/cli/types.mjs +191 -0
  31. package/dist/cli/updater.mjs +274 -0
  32. package/dist/components/astIndex.mjs +992 -0
  33. package/dist/components/ops.mjs +1069 -0
  34. package/dist/editor/AgentProposalCard.d.ts +10 -0
  35. package/dist/editor/AgentProposalCard.d.ts.map +1 -0
  36. package/dist/editor/AgentProposalCard.js +31 -0
  37. package/dist/editor/AgentProposalCard.js.map +1 -0
  38. package/dist/editor/App.d.ts +2 -0
  39. package/dist/editor/App.d.ts.map +1 -0
  40. package/dist/editor/App.js +2832 -0
  41. package/dist/editor/App.js.map +1 -0
  42. package/dist/editor/CanvasHud.d.ts +12 -0
  43. package/dist/editor/CanvasHud.d.ts.map +1 -0
  44. package/dist/editor/CanvasHud.js +13 -0
  45. package/dist/editor/CanvasHud.js.map +1 -0
  46. package/dist/editor/CanvasSurface.d.ts +31 -0
  47. package/dist/editor/CanvasSurface.d.ts.map +1 -0
  48. package/dist/editor/CanvasSurface.js +270 -0
  49. package/dist/editor/CanvasSurface.js.map +1 -0
  50. package/dist/editor/CommentPopover.d.ts +17 -0
  51. package/dist/editor/CommentPopover.d.ts.map +1 -0
  52. package/dist/editor/CommentPopover.js +62 -0
  53. package/dist/editor/CommentPopover.js.map +1 -0
  54. package/dist/editor/Comments.d.ts +13 -0
  55. package/dist/editor/Comments.d.ts.map +1 -0
  56. package/dist/editor/Comments.js +41 -0
  57. package/dist/editor/Comments.js.map +1 -0
  58. package/dist/editor/ComponentPage.d.ts +28 -0
  59. package/dist/editor/ComponentPage.d.ts.map +1 -0
  60. package/dist/editor/ComponentPage.js +55 -0
  61. package/dist/editor/ComponentPage.js.map +1 -0
  62. package/dist/editor/ComponentPanel.d.ts +38 -0
  63. package/dist/editor/ComponentPanel.d.ts.map +1 -0
  64. package/dist/editor/ComponentPanel.js +275 -0
  65. package/dist/editor/ComponentPanel.js.map +1 -0
  66. package/dist/editor/Glyph.d.ts +51 -0
  67. package/dist/editor/Glyph.d.ts.map +1 -0
  68. package/dist/editor/Glyph.js +50 -0
  69. package/dist/editor/Glyph.js.map +1 -0
  70. package/dist/editor/History.d.ts +7 -0
  71. package/dist/editor/History.d.ts.map +1 -0
  72. package/dist/editor/History.js +51 -0
  73. package/dist/editor/History.js.map +1 -0
  74. package/dist/editor/Inspector.d.ts +56 -0
  75. package/dist/editor/Inspector.d.ts.map +1 -0
  76. package/dist/editor/Inspector.js +510 -0
  77. package/dist/editor/Inspector.js.map +1 -0
  78. package/dist/editor/LazyMount.d.ts +10 -0
  79. package/dist/editor/LazyMount.d.ts.map +1 -0
  80. package/dist/editor/LazyMount.js +29 -0
  81. package/dist/editor/LazyMount.js.map +1 -0
  82. package/dist/editor/LocaleSwitch.d.ts +3 -0
  83. package/dist/editor/LocaleSwitch.d.ts.map +1 -0
  84. package/dist/editor/LocaleSwitch.js +9 -0
  85. package/dist/editor/LocaleSwitch.js.map +1 -0
  86. package/dist/editor/PreviewFrame.d.ts +10 -0
  87. package/dist/editor/PreviewFrame.d.ts.map +1 -0
  88. package/dist/editor/PreviewFrame.js +22 -0
  89. package/dist/editor/PreviewFrame.js.map +1 -0
  90. package/dist/editor/ProjectIndex.d.ts +12 -0
  91. package/dist/editor/ProjectIndex.d.ts.map +1 -0
  92. package/dist/editor/ProjectIndex.js +43 -0
  93. package/dist/editor/ProjectIndex.js.map +1 -0
  94. package/dist/editor/PromoteComponent.d.ts +28 -0
  95. package/dist/editor/PromoteComponent.d.ts.map +1 -0
  96. package/dist/editor/PromoteComponent.js +33 -0
  97. package/dist/editor/PromoteComponent.js.map +1 -0
  98. package/dist/editor/PromoteForm.d.ts +18 -0
  99. package/dist/editor/PromoteForm.d.ts.map +1 -0
  100. package/dist/editor/PromoteForm.js +35 -0
  101. package/dist/editor/PromoteForm.js.map +1 -0
  102. package/dist/editor/PromoteToken.d.ts +31 -0
  103. package/dist/editor/PromoteToken.d.ts.map +1 -0
  104. package/dist/editor/PromoteToken.js +94 -0
  105. package/dist/editor/PromoteToken.js.map +1 -0
  106. package/dist/editor/StatePreviews.d.ts +28 -0
  107. package/dist/editor/StatePreviews.d.ts.map +1 -0
  108. package/dist/editor/StatePreviews.js +113 -0
  109. package/dist/editor/StatePreviews.js.map +1 -0
  110. package/dist/editor/ValueCombo.d.ts +51 -0
  111. package/dist/editor/ValueCombo.d.ts.map +1 -0
  112. package/dist/editor/ValueCombo.js +260 -0
  113. package/dist/editor/ValueCombo.js.map +1 -0
  114. package/dist/editor/agent/AgentPanel.d.ts +19 -0
  115. package/dist/editor/agent/AgentPanel.d.ts.map +1 -0
  116. package/dist/editor/agent/AgentPanel.js +271 -0
  117. package/dist/editor/agent/AgentPanel.js.map +1 -0
  118. package/dist/editor/agent/Markdown.d.ts +5 -0
  119. package/dist/editor/agent/Markdown.d.ts.map +1 -0
  120. package/dist/editor/agent/Markdown.js +28 -0
  121. package/dist/editor/agent/Markdown.js.map +1 -0
  122. package/dist/editor/agent/agentApi.d.ts +106 -0
  123. package/dist/editor/agent/agentApi.d.ts.map +1 -0
  124. package/dist/editor/agent/agentApi.js +66 -0
  125. package/dist/editor/agent/agentApi.js.map +1 -0
  126. package/dist/editor/agent/toolLines.d.ts +38 -0
  127. package/dist/editor/agent/toolLines.d.ts.map +1 -0
  128. package/dist/editor/agent/toolLines.js +159 -0
  129. package/dist/editor/agent/toolLines.js.map +1 -0
  130. package/dist/editor/agent/useAgent.d.ts +15 -0
  131. package/dist/editor/agent/useAgent.d.ts.map +1 -0
  132. package/dist/editor/agent/useAgent.js +65 -0
  133. package/dist/editor/agent/useAgent.js.map +1 -0
  134. package/dist/editor/api.d.ts +378 -0
  135. package/dist/editor/api.d.ts.map +1 -0
  136. package/dist/editor/api.js +247 -0
  137. package/dist/editor/api.js.map +1 -0
  138. package/dist/editor/camera.d.ts +18 -0
  139. package/dist/editor/camera.d.ts.map +1 -0
  140. package/dist/editor/camera.js +40 -0
  141. package/dist/editor/camera.js.map +1 -0
  142. package/dist/editor/canvas.d.ts +25 -0
  143. package/dist/editor/canvas.d.ts.map +1 -0
  144. package/dist/editor/canvas.js +35 -0
  145. package/dist/editor/canvas.js.map +1 -0
  146. package/dist/editor/changes/ChangesPage.d.ts +25 -0
  147. package/dist/editor/changes/ChangesPage.d.ts.map +1 -0
  148. package/dist/editor/changes/ChangesPage.js +132 -0
  149. package/dist/editor/changes/ChangesPage.js.map +1 -0
  150. package/dist/editor/changes/changeModel.d.ts +25 -0
  151. package/dist/editor/changes/changeModel.d.ts.map +1 -0
  152. package/dist/editor/changes/changeModel.js +81 -0
  153. package/dist/editor/changes/changeModel.js.map +1 -0
  154. package/dist/editor/changes/changeState.d.mts +29 -0
  155. package/dist/editor/changes/changeState.mjs +187 -0
  156. package/dist/editor/chrome/EditorChrome.d.ts +49 -0
  157. package/dist/editor/chrome/EditorChrome.d.ts.map +1 -0
  158. package/dist/editor/chrome/EditorChrome.js +21 -0
  159. package/dist/editor/chrome/EditorChrome.js.map +1 -0
  160. package/dist/editor/drafts.d.ts +46 -0
  161. package/dist/editor/drafts.d.ts.map +1 -0
  162. package/dist/editor/drafts.js +38 -0
  163. package/dist/editor/drafts.js.map +1 -0
  164. package/dist/editor/i18n.d.ts +29 -0
  165. package/dist/editor/i18n.d.ts.map +1 -0
  166. package/dist/editor/i18n.js +2320 -0
  167. package/dist/editor/i18n.js.map +1 -0
  168. package/dist/editor/iconStroke.d.ts +6 -0
  169. package/dist/editor/iconStroke.d.ts.map +1 -0
  170. package/dist/editor/iconStroke.js +6 -0
  171. package/dist/editor/iconStroke.js.map +1 -0
  172. package/dist/editor/main.d.ts +2 -0
  173. package/dist/editor/main.d.ts.map +1 -0
  174. package/dist/editor/main.js +14 -0
  175. package/dist/editor/main.js.map +1 -0
  176. package/dist/editor/model.d.ts +16 -0
  177. package/dist/editor/model.d.ts.map +1 -0
  178. package/dist/editor/model.js +11 -0
  179. package/dist/editor/model.js.map +1 -0
  180. package/dist/editor/reasons.d.ts +44 -0
  181. package/dist/editor/reasons.d.ts.map +1 -0
  182. package/dist/editor/reasons.js +131 -0
  183. package/dist/editor/reasons.js.map +1 -0
  184. package/dist/editor/reviewLifecycle.d.ts +8 -0
  185. package/dist/editor/reviewLifecycle.d.ts.map +1 -0
  186. package/dist/editor/reviewLifecycle.js +21 -0
  187. package/dist/editor/reviewLifecycle.js.map +1 -0
  188. package/dist/editor/styles.css +8737 -0
  189. package/dist/editor/tokenMatch.d.ts +59 -0
  190. package/dist/editor/tokenMatch.d.ts.map +1 -0
  191. package/dist/editor/tokenMatch.js +198 -0
  192. package/dist/editor/tokenMatch.js.map +1 -0
  193. package/dist/editor/tokens/ConsolidatePage.d.ts +16 -0
  194. package/dist/editor/tokens/ConsolidatePage.d.ts.map +1 -0
  195. package/dist/editor/tokens/ConsolidatePage.js +244 -0
  196. package/dist/editor/tokens/ConsolidatePage.js.map +1 -0
  197. package/dist/editor/tokens/TokenActivity.d.ts +18 -0
  198. package/dist/editor/tokens/TokenActivity.d.ts.map +1 -0
  199. package/dist/editor/tokens/TokenActivity.js +18 -0
  200. package/dist/editor/tokens/TokenActivity.js.map +1 -0
  201. package/dist/editor/tokens/TokenDialogs.d.ts +26 -0
  202. package/dist/editor/tokens/TokenDialogs.d.ts.map +1 -0
  203. package/dist/editor/tokens/TokenDialogs.js +119 -0
  204. package/dist/editor/tokens/TokenDialogs.js.map +1 -0
  205. package/dist/editor/tokens/TokenList.d.ts +21 -0
  206. package/dist/editor/tokens/TokenList.d.ts.map +1 -0
  207. package/dist/editor/tokens/TokenList.js +98 -0
  208. package/dist/editor/tokens/TokenList.js.map +1 -0
  209. package/dist/editor/tokens/TokenPage.d.ts +25 -0
  210. package/dist/editor/tokens/TokenPage.d.ts.map +1 -0
  211. package/dist/editor/tokens/TokenPage.js +108 -0
  212. package/dist/editor/tokens/TokenPage.js.map +1 -0
  213. package/dist/editor/tokens/tokenModel.d.ts +35 -0
  214. package/dist/editor/tokens/tokenModel.d.ts.map +1 -0
  215. package/dist/editor/tokens/tokenModel.js +72 -0
  216. package/dist/editor/tokens/tokenModel.js.map +1 -0
  217. package/dist/editor/ui/Button.d.ts +3 -0
  218. package/dist/editor/ui/Button.d.ts.map +1 -0
  219. package/dist/editor/ui/Button.js +6 -0
  220. package/dist/editor/ui/Button.js.map +1 -0
  221. package/dist/editor/ui/CommentBox.d.ts +23 -0
  222. package/dist/editor/ui/CommentBox.d.ts.map +1 -0
  223. package/dist/editor/ui/CommentBox.js +41 -0
  224. package/dist/editor/ui/CommentBox.js.map +1 -0
  225. package/dist/editor/ui/Icon.d.ts +8 -0
  226. package/dist/editor/ui/Icon.d.ts.map +1 -0
  227. package/dist/editor/ui/Icon.js +6 -0
  228. package/dist/editor/ui/Icon.js.map +1 -0
  229. package/dist/editor/ui/IconButton.d.ts +11 -0
  230. package/dist/editor/ui/IconButton.d.ts.map +1 -0
  231. package/dist/editor/ui/IconButton.js +6 -0
  232. package/dist/editor/ui/IconButton.js.map +1 -0
  233. package/dist/editor/ui/NumberInput.d.ts +14 -0
  234. package/dist/editor/ui/NumberInput.d.ts.map +1 -0
  235. package/dist/editor/ui/NumberInput.js +6 -0
  236. package/dist/editor/ui/NumberInput.js.map +1 -0
  237. package/dist/editor/ui/PageLine.d.ts +14 -0
  238. package/dist/editor/ui/PageLine.d.ts.map +1 -0
  239. package/dist/editor/ui/PageLine.js +7 -0
  240. package/dist/editor/ui/PageLine.js.map +1 -0
  241. package/dist/editor/ui/SearchPicker.d.ts +41 -0
  242. package/dist/editor/ui/SearchPicker.d.ts.map +1 -0
  243. package/dist/editor/ui/SearchPicker.js +82 -0
  244. package/dist/editor/ui/SearchPicker.js.map +1 -0
  245. package/dist/editor/ui/Select.d.ts +19 -0
  246. package/dist/editor/ui/Select.d.ts.map +1 -0
  247. package/dist/editor/ui/Select.js +12 -0
  248. package/dist/editor/ui/Select.js.map +1 -0
  249. package/dist/editor/ui/TokenField.d.ts +14 -0
  250. package/dist/editor/ui/TokenField.d.ts.map +1 -0
  251. package/dist/editor/ui/TokenField.js +41 -0
  252. package/dist/editor/ui/TokenField.js.map +1 -0
  253. package/dist/editor/ui/TokenPicker.d.ts +31 -0
  254. package/dist/editor/ui/TokenPicker.d.ts.map +1 -0
  255. package/dist/editor/ui/TokenPicker.js +26 -0
  256. package/dist/editor/ui/TokenPicker.js.map +1 -0
  257. package/dist/editor/useBuildError.d.ts +7 -0
  258. package/dist/editor/useBuildError.d.ts.map +1 -0
  259. package/dist/editor/useBuildError.js +30 -0
  260. package/dist/editor/useBuildError.js.map +1 -0
  261. package/dist/editor/useLatestRequest.d.ts +22 -0
  262. package/dist/editor/useLatestRequest.d.ts.map +1 -0
  263. package/dist/editor/useLatestRequest.js +49 -0
  264. package/dist/editor/useLatestRequest.js.map +1 -0
  265. package/dist/editor-bundle/editor.css +2 -0
  266. package/dist/editor-bundle/editor.js +83 -0
  267. package/dist/editor-ui.d.ts +15 -0
  268. package/dist/editor-ui.d.ts.map +1 -0
  269. package/dist/editor-ui.js +14 -0
  270. package/dist/editor-ui.js.map +1 -0
  271. package/dist/inspector/runtime.d.ts +18 -0
  272. package/dist/inspector/runtime.d.ts.map +1 -0
  273. package/dist/inspector/runtime.js +1280 -0
  274. package/dist/inspector/runtime.js.map +1 -0
  275. package/dist/preview/main.d.ts +3 -0
  276. package/dist/preview/main.d.ts.map +1 -0
  277. package/dist/preview/main.js +320 -0
  278. package/dist/preview/main.js.map +1 -0
  279. package/dist/preview/preview.css +40 -0
  280. package/dist/runtime/index.d.ts +3 -0
  281. package/dist/runtime/index.d.ts.map +1 -0
  282. package/dist/runtime/index.js +2 -0
  283. package/dist/runtime/index.js.map +1 -0
  284. package/dist/shared/buildError.d.mts +27 -0
  285. package/dist/shared/buildError.mjs +141 -0
  286. package/dist/shared/cameraFit.d.mts +16 -0
  287. package/dist/shared/cameraFit.mjs +47 -0
  288. package/dist/shared/canvasLayout.d.mts +13 -0
  289. package/dist/shared/canvasLayout.mjs +171 -0
  290. package/dist/shared/commentShots.d.mts +12 -0
  291. package/dist/shared/commentShots.mjs +53 -0
  292. package/dist/shared/componentExtract.d.mts +43 -0
  293. package/dist/shared/componentExtract.mjs +136 -0
  294. package/dist/shared/componentMeta.d.mts +26 -0
  295. package/dist/shared/componentMeta.mjs +87 -0
  296. package/dist/shared/componentOps.d.mts +70 -0
  297. package/dist/shared/componentOps.mjs +407 -0
  298. package/dist/shared/componentTarget.d.mts +15 -0
  299. package/dist/shared/componentTarget.mjs +58 -0
  300. package/dist/shared/components.d.mts +30 -0
  301. package/dist/shared/components.mjs +106 -0
  302. package/dist/shared/consolidateCategories.d.mts +2 -0
  303. package/dist/shared/consolidateCategories.mjs +6 -0
  304. package/dist/shared/env.d.mts +4 -0
  305. package/dist/shared/env.mjs +18 -0
  306. package/dist/shared/gitChanges.d.mts +2 -0
  307. package/dist/shared/gitChanges.mjs +30 -0
  308. package/dist/shared/oklab.d.mts +6 -0
  309. package/dist/shared/oklab.mjs +56 -0
  310. package/dist/shared/optimizeEntries.d.mts +5 -0
  311. package/dist/shared/optimizeEntries.mjs +24 -0
  312. package/dist/shared/packages.d.mts +11 -0
  313. package/dist/shared/packages.mjs +96 -0
  314. package/dist/shared/projectFiles.d.mts +23 -0
  315. package/dist/shared/projectFiles.mjs +72 -0
  316. package/dist/shared/prompt.d.mts +20 -0
  317. package/dist/shared/prompt.mjs +201 -0
  318. package/dist/shared/proposals.d.mts +11 -0
  319. package/dist/shared/proposals.mjs +42 -0
  320. package/dist/shared/protocol.d.ts +122 -0
  321. package/dist/shared/protocol.d.ts.map +1 -0
  322. package/dist/shared/protocol.js +7 -0
  323. package/dist/shared/protocol.js.map +1 -0
  324. package/dist/shared/reviewArchive.d.mts +4 -0
  325. package/dist/shared/reviewArchive.mjs +19 -0
  326. package/dist/shared/reviewStore.d.mts +30 -0
  327. package/dist/shared/reviewStore.mjs +218 -0
  328. package/dist/shared/reviewVerify.d.mts +21 -0
  329. package/dist/shared/reviewVerify.mjs +158 -0
  330. package/dist/shared/sizeModes.d.mts +15 -0
  331. package/dist/shared/sizeModes.mjs +53 -0
  332. package/dist/shared/sketches.d.mts +10 -0
  333. package/dist/shared/sketches.mjs +64 -0
  334. package/dist/shared/snapshotCheck.d.mts +13 -0
  335. package/dist/shared/snapshotCheck.mjs +81 -0
  336. package/dist/shared/timeout.d.mts +1 -0
  337. package/dist/shared/timeout.mjs +15 -0
  338. package/dist/shared/tokens.d.ts +2 -0
  339. package/dist/shared/tokens.d.ts.map +1 -0
  340. package/dist/shared/tokens.js +2 -0
  341. package/dist/shared/tokens.js.map +1 -0
  342. package/dist/shared/types.d.ts +689 -0
  343. package/dist/shared/types.d.ts.map +1 -0
  344. package/dist/shared/types.js +13 -0
  345. package/dist/shared/types.js.map +1 -0
  346. package/dist/shared/wheelRouting.d.mts +9 -0
  347. package/dist/shared/wheelRouting.mjs +31 -0
  348. package/dist/shared/writeScope.mjs +96 -0
  349. package/dist/snapshots/diff.d.mts +28 -0
  350. package/dist/snapshots/diff.mjs +263 -0
  351. package/dist/snapshots/index.d.mts +110 -0
  352. package/dist/snapshots/index.mjs +638 -0
  353. package/dist/snapshots/render.d.mts +24 -0
  354. package/dist/snapshots/render.mjs +250 -0
  355. package/dist/snapshots/toolOps.d.mts +25 -0
  356. package/dist/snapshots/toolOps.mjs +69 -0
  357. package/dist/tokens/adapters/css.mjs +51 -0
  358. package/dist/tokens/adapters/cssInCode.mjs +314 -0
  359. package/dist/tokens/adapters/oxcShared.mjs +80 -0
  360. package/dist/tokens/adapters/preprocessor.mjs +63 -0
  361. package/dist/tokens/adapters/registry.mjs +53 -0
  362. package/dist/tokens/adapters/tailwindcss.mjs +424 -0
  363. package/dist/tokens/adapters/types.mjs +117 -0
  364. package/dist/tokens/consolidate/index.d.mts +42 -0
  365. package/dist/tokens/consolidate/index.mjs +111 -0
  366. package/dist/tokens/consolidate/normalize.mjs +479 -0
  367. package/dist/tokens/consolidate/plan.mjs +726 -0
  368. package/dist/tokens/consolidate/scan.mjs +928 -0
  369. package/dist/tokens/extract.mjs +441 -0
  370. package/dist/tokens/moduleData.d.mts +14 -0
  371. package/dist/tokens/moduleData.mjs +32 -0
  372. package/dist/tokens/opLock.d.mts +4 -0
  373. package/dist/tokens/opLock.mjs +108 -0
  374. package/dist/tokens/ops.d.mts +71 -0
  375. package/dist/tokens/ops.mjs +1511 -0
  376. package/dist/tokens/pipeline.mjs +813 -0
  377. package/dist/tokens/report.d.mts +47 -0
  378. package/dist/tokens/report.mjs +257 -0
  379. package/dist/tokens/rewrite/code.mjs +172 -0
  380. package/dist/tokens/rewrite/css.mjs +154 -0
  381. package/dist/tokens/rewrite/index.mjs +244 -0
  382. package/dist/tokens/rewrite/tailwind.mjs +288 -0
  383. package/dist/tokens/rewrite/text.mjs +116 -0
  384. package/dist/tokens/rewrite/value.mjs +115 -0
  385. package/dist/tokens/usage.d.mts +97 -0
  386. package/dist/tokens/usage.mjs +680 -0
  387. package/dist/vite/agent.d.ts +21 -0
  388. package/dist/vite/agent.d.ts.map +1 -0
  389. package/dist/vite/agent.js +165 -0
  390. package/dist/vite/agent.js.map +1 -0
  391. package/dist/vite/events.d.ts +27 -0
  392. package/dist/vite/events.d.ts.map +1 -0
  393. package/dist/vite/events.js +156 -0
  394. package/dist/vite/events.js.map +1 -0
  395. package/dist/vite/layout.d.ts +2 -0
  396. package/dist/vite/layout.d.ts.map +1 -0
  397. package/dist/vite/layout.js +4 -0
  398. package/dist/vite/layout.js.map +1 -0
  399. package/dist/vite/plugin.d.ts +40 -0
  400. package/dist/vite/plugin.d.ts.map +1 -0
  401. package/dist/vite/plugin.js +1255 -0
  402. package/dist/vite/plugin.js.map +1 -0
  403. package/dist/vite/requestGuard.d.mts +3 -0
  404. package/dist/vite/requestGuard.mjs +43 -0
  405. package/dist/vite/review.d.ts +11 -0
  406. package/dist/vite/review.d.ts.map +1 -0
  407. package/dist/vite/review.js +283 -0
  408. package/dist/vite/review.js.map +1 -0
  409. package/package.json +106 -1
  410. package/skills/seji/SKILL.md +395 -0
  411. package/skills/seji-authoring/SKILL.md +397 -0
  412. package/skills/seji-tokens/SKILL.md +432 -0
@@ -0,0 +1,407 @@
1
+ // Component pages, headless: the list / one component's report, and the actions the
2
+ // component page offers. The CLI (`seji component …`), the HTTP API
3
+ // (`/__seji/api/components`) and the editor all go through here, so they behave the same;
4
+ // pass the same `catalog` (the plugin's scanned componentGroups, see cli/catalog.mjs) to get
5
+ // the same component set.
6
+ //
7
+ // Who owns what:
8
+ // - design/components.json owns the metadata: `$description` and the deprecation
9
+ // (`$deprecated` + replacement + deprecatedAt). `describe`, `deprecate` (mark only) and
10
+ // `undeprecate` write it directly; nothing else mirrors it.
11
+ // - rename, merge and `deprecate --replace-all` are executed by the tool itself
12
+ // (src/components/ops.mjs, AST-based): code, file name, registrations and metadata
13
+ // change in one revertible batch, and one review item lists what it changed and what it
14
+ // left for the agent (`component revert <batch>` undoes it).
15
+ // - delete and tidy need judgment and become `component` review items for the agent.
16
+ // Re-recording never overwrites an earlier item: each record gets its own id.
17
+ import { randomUUID } from 'node:crypto'
18
+ import { existsSync, readdirSync } from 'node:fs'
19
+ import { join } from 'node:path'
20
+
21
+ import { ComponentOpError, revertComponentBatch, runComponentOp } from '../components/ops.mjs'
22
+ import { buildUsageIndex, readComponentPages } from '../tokens/usage.mjs'
23
+ import { baseLayerFiles, deprecationOf, readComponentMeta, updateComponentMeta } from './componentMeta.mjs'
24
+ import { SAFE_DESIGN_ID, mutateReview, readReviewFile, reviewFilePath } from './reviewStore.mjs'
25
+
26
+ export const COMPONENT_ACTIONS = ['rename', 'merge', 'deprecate', 'undeprecate', 'delete', 'tidy']
27
+ /** Actions the tool executes on code (dry-run plans are available for them). */
28
+ export const TOOL_ACTIONS = ['rename', 'merge', 'deprecate']
29
+ const COMPONENT_NAME = /^[A-Z][A-Za-z0-9_]*$/
30
+
31
+ const nowIso = () => new Date().toISOString()
32
+
33
+ /** A user-facing error with a stable `code` (the editor translates codes; CLI prints the message). */
34
+ export class ComponentActionError extends Error {
35
+ constructor(message, code, details) {
36
+ super(message)
37
+ this.name = 'ComponentActionError'
38
+ this.code = code
39
+ if (details) this.details = details
40
+ }
41
+ }
42
+ const fail = (message, code, details) => {
43
+ throw new ComponentActionError(message, code, details)
44
+ }
45
+
46
+ function designIds(root) {
47
+ const base = join(root, 'design')
48
+ if (!existsSync(base)) return []
49
+ return readdirSync(base, { withFileTypes: true })
50
+ .filter((entry) => entry.isDirectory() && SAFE_DESIGN_ID.test(entry.name))
51
+ .filter((entry) => existsSync(join(base, entry.name, 'design.tsx')))
52
+ .map((entry) => entry.name)
53
+ .sort()
54
+ }
55
+
56
+ /**
57
+ * Whether a component item belongs on `name`'s page: its target, the new name of a tool
58
+ * rename (the renamed component's page keeps the rename, its leftovers and its undo), or the
59
+ * parent a Promote to component item splits a child out of.
60
+ */
61
+ const concerns = (item, name) =>
62
+ item.target?.component === name ||
63
+ (item.componentAction === 'rename' && Boolean(item.componentOp) && item.to === name) ||
64
+ (item.componentAction === 'extract' && item.parent === name)
65
+
66
+ /**
67
+ * The names a component had before pending tool renames to it (not reverted). A frame can
68
+ * still render it under such a name: a design importing a built package (or a package
69
+ * specifier the tool leaves for the agent) shows the old build until it is rebuilt, so state
70
+ * previews look for these names too (inspector runtime `aliases`).
71
+ */
72
+ const renamedFromOf = (items, name) => [
73
+ ...new Set(
74
+ items
75
+ .filter((item) => item.componentAction === 'rename' && item.componentOp && !item.componentOp.revertedAt && item.to === name)
76
+ .map((item) => String(item.from))
77
+ .filter((from) => from && from !== name),
78
+ ),
79
+ ]
80
+
81
+ /** Pending `component` review items (not resolved, not archived), across every design ledger. */
82
+ export function pendingComponentItems(root, name) {
83
+ const items = []
84
+ for (const design of designIds(root)) {
85
+ let review
86
+ try {
87
+ review = readReviewFile(reviewFilePath(root, design))
88
+ } catch {
89
+ continue
90
+ }
91
+ for (const item of review?.items ?? []) {
92
+ if (item?.kind !== 'component' || item.status === 'archived' || item.status === 'resolved') continue
93
+ if (name && !concerns(item, name)) continue
94
+ items.push(item)
95
+ }
96
+ }
97
+ return items
98
+ }
99
+
100
+ const isUndecidedProposal = (item) => item.author === 'agent' && !item.proposalDecision
101
+
102
+ /**
103
+ * Frame ids for tidy, the one parser for every entry: an array (HTTP `frames: [...]`, repeated
104
+ * CLI `--frame a --frame b`), a comma string (`--frames a,b`), or both mixed. Trimmed, deduped.
105
+ */
106
+ export function parseFrames(frames) {
107
+ const list = (Array.isArray(frames) ? frames : frames === undefined || frames === null ? [] : [frames])
108
+ .flatMap((entry) => String(entry).split(','))
109
+ .map((entry) => entry.trim())
110
+ .filter(Boolean)
111
+ return [...new Set(list)]
112
+ }
113
+
114
+ async function context(root, catalog) {
115
+ const meta = readComponentMeta(root)
116
+ const [index, baseFiles] = await Promise.all([buildUsageIndex({ root }), baseLayerFiles(root, meta)])
117
+ const pages = readComponentPages(root)
118
+ let entries
119
+ if (catalog?.length) {
120
+ entries = catalog.map((item) => ({ name: item.name, file: item.file, line: item.line }))
121
+ } else {
122
+ // No catalog configured: components with a page or a base-layer file. Metadata alone
123
+ // does not make a component (describe refuses unknown names).
124
+ const names = new Set(pages.keys())
125
+ if (baseFiles) {
126
+ for (const name of index.componentNames()) {
127
+ const entry = index.componentEntry(name)
128
+ if (entry && baseFiles.has(entry.file)) names.add(name)
129
+ }
130
+ }
131
+ entries = [...names]
132
+ .filter((name) => index.componentEntry(name))
133
+ .sort()
134
+ .map((name) => {
135
+ const entry = index.componentEntry(name)
136
+ return { name, file: entry.file, line: entry.line }
137
+ })
138
+ }
139
+ // Deprecated components stay listed (under "Deprecated") while their code exists.
140
+ for (const name of Object.keys(meta.components)) {
141
+ if (entries.some((entry) => entry.name === name) || !deprecationOf(meta.components[name])) continue
142
+ const entry = index.componentEntry(name)
143
+ if (entry) entries.push({ name, file: entry.file, line: entry.line })
144
+ }
145
+ const names = new Set(entries.map((entry) => entry.name))
146
+ const pending = pendingComponentItems(root)
147
+ return { meta, index, baseFiles, pages, entries, names, pending }
148
+ }
149
+
150
+ const knownIn = (ctx, name) => ctx.names.has(name) || Boolean(ctx.index.componentEntry(name))
151
+
152
+ function summaryOf(ctx, entry) {
153
+ const report = ctx.index.componentUsage(entry.name)
154
+ const metaEntry = ctx.meta.components[entry.name] ?? {}
155
+ const file = report?.file ?? entry.file
156
+ const items = ctx.pending.filter((item) => concerns(item, entry.name))
157
+ return {
158
+ report,
159
+ items,
160
+ summary: {
161
+ name: entry.name,
162
+ file,
163
+ ...(typeof (report?.line ?? entry.line) === 'number' ? { line: report?.line ?? entry.line } : {}),
164
+ layer: ctx.baseFiles ? (ctx.baseFiles.has(file) ? 'base' : 'composite') : null,
165
+ page: ctx.pages.get(entry.name) ?? null,
166
+ ...(typeof metaEntry.$description === 'string' && metaEntry.$description
167
+ ? { description: metaEntry.$description }
168
+ : {}),
169
+ deprecated: deprecationOf(metaEntry),
170
+ tokens: report?.summary.tokens ?? 0,
171
+ hardcoded: report?.summary.hardcoded ?? 0,
172
+ primitive: report?.summary.primitive ?? 0,
173
+ pending: items.length,
174
+ proposed: items.some(isUndecidedProposal),
175
+ },
176
+ }
177
+ }
178
+
179
+ /** Every catalog component with its layer, status and counts. */
180
+ export async function listComponents({ root = process.cwd(), catalog } = {}) {
181
+ const ctx = await context(root, catalog)
182
+ return {
183
+ layers: Boolean(ctx.baseFiles),
184
+ components: ctx.entries.map((entry) => summaryOf(ctx, entry).summary),
185
+ }
186
+ }
187
+
188
+ /** One component: metadata, tokens / literals its styles use, pending items. */
189
+ export async function showComponent({ root = process.cwd(), name, catalog } = {}) {
190
+ const ctx = await context(root, catalog)
191
+ const entry =
192
+ ctx.entries.find((item) => item.name === name) ??
193
+ (ctx.index.componentEntry(name) ? { name, file: ctx.index.componentEntry(name).file } : null)
194
+ if (!entry) return null
195
+ const { report, summary, items } = summaryOf(ctx, entry)
196
+ const replaces = Object.entries(ctx.meta.components)
197
+ .map(([other, value]) => ({ other, deprecation: deprecationOf(value) }))
198
+ .filter(({ other, deprecation }) => other !== name && deprecation?.replacement === name)
199
+ .filter(({ other }) => Boolean(ctx.index.componentEntry(other)))
200
+ .map(({ other, deprecation }) => ({
201
+ name: other,
202
+ ...(deprecation.at ? { at: deprecation.at } : {}),
203
+ }))
204
+ return {
205
+ ...summary,
206
+ tokenRows: report?.tokenRows ?? [],
207
+ literals: report?.literals ?? [],
208
+ summary: report?.summary ?? { tokens: 0, primitive: 0, hardcoded: 0 },
209
+ replaces,
210
+ items,
211
+ renamedFrom: renamedFromOf(items, name),
212
+ }
213
+ }
214
+
215
+ async function knownComponent(root, name, catalog) {
216
+ if (!COMPONENT_NAME.test(String(name ?? ''))) fail(`invalid component name: ${name}`, 'invalid-name')
217
+ const ctx = await context(root, catalog)
218
+ if (!knownIn(ctx, name)) fail(`unknown component: ${name}`, 'unknown-component')
219
+ return ctx
220
+ }
221
+
222
+ /** Write (or clear) a component's `$description`. Refuses names that are not components. */
223
+ export async function describeComponent({ root = process.cwd(), name, description, catalog }) {
224
+ await knownComponent(root, name, catalog)
225
+ const text = String(description ?? '').trim()
226
+ return updateComponentMeta(root, name, (entry) => {
227
+ const next = { ...entry }
228
+ if (text) next.$description = text
229
+ else delete next.$description
230
+ return next
231
+ })
232
+ }
233
+
234
+ function resolveDesign(root, design, page) {
235
+ const designs = designIds(root)
236
+ const id = design ?? page?.design ?? (designs.length === 1 ? designs[0] : undefined)
237
+ if (!id) fail('pass --design: the component has no page and the project has several designs', 'design-required')
238
+ if (!designs.includes(id)) fail(`unknown design: ${id}`, 'unknown-design')
239
+ return id
240
+ }
241
+
242
+ /** Check a merge / replacement target: a known, different, not deprecated component. */
243
+ function checkTarget(ctx, name, target, label) {
244
+ if (!target) fail(`${label} needs a component`, 'target-required')
245
+ if (target === name) fail('a component cannot replace itself', 'same-name')
246
+ if (!knownIn(ctx, target)) fail(`unknown component: ${target}`, 'unknown-component')
247
+ if (deprecationOf(ctx.meta.components[target])) {
248
+ fail(`${target} is deprecated itself; pick a component that is not`, 'target-deprecated')
249
+ }
250
+ }
251
+
252
+ function validate(ctx, { name, action, to, reason, mode }) {
253
+ const note = String(reason ?? '').trim()
254
+ const target = to === undefined || to === null || to === '' ? null : String(to).trim()
255
+ if (action === 'rename') {
256
+ if (!target || !COMPONENT_NAME.test(target)) fail('rename needs a PascalCase name', 'invalid-name')
257
+ if (target === name) fail('the new name is the current name', 'same-name')
258
+ if (knownIn(ctx, target)) fail(`${target} already exists`, 'name-taken')
259
+ }
260
+ if (action === 'merge') checkTarget(ctx, name, target, 'merge')
261
+ if (action === 'deprecate') {
262
+ if (!note) fail('deprecate needs a reason (it is written into the usage note)', 'reason-required')
263
+ if (target === null && mode === 'replace') fail('replacing usages needs a replacement', 'target-required')
264
+ if (target !== null) checkTarget(ctx, name, target, 'deprecate')
265
+ }
266
+ return { note, target }
267
+ }
268
+
269
+ /**
270
+ * What a tool-executed action would change, without writing anything: rename / merge /
271
+ * deprecate with `mode: 'replace'`. Same report as the real run (files, places, leftovers).
272
+ */
273
+ export async function planComponentAction({ root = process.cwd(), name, action, to, reason, mode, catalog }) {
274
+ if (!TOOL_ACTIONS.includes(action) || (action === 'deprecate' && mode !== 'replace')) {
275
+ fail(`${action}${action === 'deprecate' ? ' without replace-all' : ''} changes no code; nothing to plan`, 'no-plan')
276
+ }
277
+ const ctx = await knownComponent(root, name, catalog)
278
+ const { target } = validate(ctx, { name, action, to, reason, mode })
279
+ return wrapOp(() =>
280
+ runComponentOp({ root, op: action === 'deprecate' ? 'replace' : action, name, to: target, reason, dryRun: true }),
281
+ )
282
+ }
283
+
284
+ async function wrapOp(fn) {
285
+ try {
286
+ return await fn()
287
+ } catch (error) {
288
+ if (error instanceof ComponentOpError) fail(error.message, error.code ?? 'op-failed', error.details)
289
+ throw error
290
+ }
291
+ }
292
+
293
+ function recordItem(root, designId, item) {
294
+ const timestamp = nowIso()
295
+ const record = {
296
+ id: `component-${item.componentAction}-${item.from}-${randomUUID().slice(0, 8)}`,
297
+ design: designId,
298
+ kind: 'component',
299
+ scope: 'component',
300
+ target: { type: 'component', component: item.from },
301
+ status: 'open',
302
+ author: 'human',
303
+ createdAt: timestamp,
304
+ updatedAt: timestamp,
305
+ ...item,
306
+ }
307
+ const { file } = mutateReview(
308
+ root,
309
+ designId,
310
+ (review) => ({ ...review, items: [...review.items, record] }),
311
+ { create: true },
312
+ )
313
+ return { item: record, reviewPath: file }
314
+ }
315
+
316
+ /**
317
+ * Run a component action.
318
+ * rename / merge, deprecate --replace-all the tool rewrites the code (one batch, one item)
319
+ * deprecate (mark only) / undeprecate design/components.json only, no item
320
+ * delete / tidy a review item for the agent
321
+ * Returns `{ action, item?, reviewPath?, op?, entry? }`.
322
+ */
323
+ export async function recordComponentAction({
324
+ root = process.cwd(),
325
+ name,
326
+ action,
327
+ design,
328
+ to,
329
+ reason,
330
+ mode,
331
+ frames,
332
+ author = 'human',
333
+ rationale,
334
+ catalog,
335
+ }) {
336
+ if (!COMPONENT_ACTIONS.includes(action)) {
337
+ fail(`unknown component action: ${action} (expected ${COMPONENT_ACTIONS.join(', ')})`, 'unknown-action')
338
+ }
339
+ const ctx = await knownComponent(root, name, catalog)
340
+ const page = ctx.pages.get(name) ?? null
341
+ const { note, target } = validate(ctx, { name, action, to, reason, mode })
342
+ const pageField = page ? { page: page.page } : {}
343
+
344
+ if (action === 'rename' || action === 'merge' || (action === 'deprecate' && mode === 'replace')) {
345
+ const designId = resolveDesign(root, design, page)
346
+ const op = await wrapOp(() =>
347
+ runComponentOp({
348
+ root,
349
+ op: action === 'deprecate' ? 'replace' : action,
350
+ name,
351
+ to: target,
352
+ design: designId,
353
+ reason: note,
354
+ item: { componentAction: action, ...(action === 'deprecate' ? { componentMode: 'replace' } : {}), ...pageField },
355
+ }),
356
+ )
357
+ return { action, op, item: op.item, reviewPath: op.reviewPath }
358
+ }
359
+
360
+ if (action === 'deprecate') {
361
+ const entry = updateComponentMeta(root, name, (current) => ({
362
+ ...current,
363
+ $deprecated: note,
364
+ replacement: target,
365
+ deprecatedAt: nowIso(),
366
+ }))
367
+ return { action, entry }
368
+ }
369
+
370
+ if (action === 'undeprecate') {
371
+ if (!deprecationOf(ctx.meta.components[name])) fail(`${name} is not deprecated`, 'not-deprecated')
372
+ const entry = updateComponentMeta(root, name, (current) => {
373
+ const { $deprecated: _reason, replacement: _replacement, deprecatedAt: _at, ...rest } = current
374
+ return rest
375
+ })
376
+ return { action, entry }
377
+ }
378
+
379
+ const report = ctx.index.componentUsage(name)
380
+ let frameList
381
+ if (action === 'tidy') {
382
+ frameList = parseFrames(frames)
383
+ if (!frameList.length) fail('tidy needs frame ids', 'frames-required')
384
+ if (author !== 'agent' && ctx.pending.some((item) => item.target?.component === name && item.componentAction === 'tidy' && isUndecidedProposal(item))) {
385
+ fail(`an agent tidy proposal for ${name} is waiting for a decision; approve or reject it first`, 'proposal-pending')
386
+ }
387
+ }
388
+ const designId = resolveDesign(root, design, page)
389
+ return {
390
+ action,
391
+ ...recordItem(root, designId, {
392
+ ...pageField,
393
+ componentAction: action,
394
+ from: name,
395
+ ...(note ? { body: note } : {}),
396
+ ...(frameList ? { frames: frameList } : {}),
397
+ ...(report?.file ? { source: report.file } : {}),
398
+ author,
399
+ ...(author === 'agent' && rationale ? { rationale: String(rationale) } : {}),
400
+ }),
401
+ }
402
+ }
403
+
404
+ /** Undo a tool-executed component batch (rename / merge / replace). */
405
+ export async function revertComponentAction({ root = process.cwd(), batch, design, force = false, dryRun = false }) {
406
+ return wrapOp(() => revertComponentBatch({ root, batch, design, force, dryRun }))
407
+ }
@@ -0,0 +1,15 @@
1
+ import type { Rect } from './types'
2
+
3
+ export type ComponentBinding<E> = {
4
+ /** Re-check after a DOM or size change. Returns true when a (new) element was bound. */
5
+ refresh(): boolean
6
+ readonly element: E | null
7
+ stop(): void
8
+ }
9
+
10
+ export function createComponentBinding<E extends object>(deps: {
11
+ find: () => E | null
12
+ rectOf: (element: E) => Rect
13
+ bind: (element: E) => void
14
+ report: (rect: Rect) => void
15
+ }): ComponentBinding<E>
@@ -0,0 +1,58 @@
1
+ // A component state preview's live binding to the element its component renders, as one
2
+ // small state machine the inspector runtime owns per preview frame (one binding at a time)
3
+ // and tests can drive without a browser.
4
+ //
5
+ // The element is not fixed: when the source changes (a tool rename, any edit), the dev
6
+ // server's update makes React remount the component and the old element leaves the
7
+ // document. A binding made once would keep isolating and forcing a detached element, so
8
+ // the preview went blank (everything else hidden) or framed a stale rect. Instead the
9
+ // runtime calls `refresh()` on every DOM change and every size change of the bound element
10
+ // (MutationObserver / ResizeObserver, no timers): the binding re-finds the element, re-binds
11
+ // a new one (isolate + force the state again) and reports the rect only when it changed.
12
+
13
+ const sameRect = (a, b) =>
14
+ Boolean(a && b) && a.x === b.x && a.y === b.y && a.width === b.width && a.height === b.height
15
+
16
+ /**
17
+ * @param {object} deps
18
+ * @param {() => object | null} deps.find The element the component renders now, or null.
19
+ * @param {(element: object) => {x:number,y:number,width:number,height:number}} deps.rectOf
20
+ * @param {(element: object) => void} deps.bind Isolate + force the state on a new element.
21
+ * @param {(rect: object) => void} deps.report Tell the editor where the element is.
22
+ */
23
+ export function createComponentBinding({ find, rectOf, bind, report }) {
24
+ let element = null
25
+ let rect = null
26
+ let stopped = false
27
+ return {
28
+ /** Re-check after a DOM or size change. Returns true when a (new) element was bound. */
29
+ refresh() {
30
+ if (stopped) return false
31
+ const next = find()
32
+ if (!next) {
33
+ // Mid-update: the old element is gone and the new one is not there yet. Keep the last
34
+ // rect; the next change binds the new element.
35
+ element = null
36
+ return false
37
+ }
38
+ const rebound = next !== element
39
+ if (rebound) {
40
+ element = next
41
+ bind(next)
42
+ }
43
+ const nextRect = rectOf(next)
44
+ if (rebound || !sameRect(nextRect, rect)) {
45
+ rect = nextRect
46
+ report(nextRect)
47
+ }
48
+ return rebound
49
+ },
50
+ get element() {
51
+ return element
52
+ },
53
+ stop() {
54
+ stopped = true
55
+ element = null
56
+ },
57
+ }
58
+ }
@@ -0,0 +1,30 @@
1
+ import type { ComponentGroup, DesignComponent } from './types'
2
+
3
+ export type ComponentGroupInput = {
4
+ id: string
5
+ label: string
6
+ labelZh?: string
7
+ globs: string[]
8
+ names?: string[]
9
+ }
10
+
11
+ export declare function componentExportsOf(
12
+ source: string,
13
+ file: string,
14
+ ): Array<Omit<DesignComponent, 'file'>>
15
+ export declare function scanComponents(root: string, patterns: string[]): Promise<DesignComponent[]>
16
+ export declare function scanComponentGroups(
17
+ root: string,
18
+ groups: ComponentGroupInput[],
19
+ ): Promise<ComponentGroup[]>
20
+
21
+ export type ComponentDir = {
22
+ /** Root-relative directory (posix). */
23
+ dir: string
24
+ group: string
25
+ label: string
26
+ labelZh?: string
27
+ exists: boolean
28
+ }
29
+
30
+ export declare function componentDirsOf(root: string, groups: ComponentGroupInput[]): ComponentDir[]
@@ -0,0 +1,106 @@
1
+ import { existsSync, readFileSync, statSync } from 'node:fs'
2
+ import { join, posix, relative, sep } from 'node:path'
3
+
4
+ import { glob } from 'tinyglobby'
5
+
6
+ import { analyzeSource, localComponentExports } from '../components/astIndex.mjs'
7
+
8
+ const toPosix = (file) => file.split(sep).join('/')
9
+
10
+ /**
11
+ * Exported PascalCase components declared in one TSX/JSX source, read from its syntax tree
12
+ * (`export function X`, `export const X`, `export { X }`, `export default function X`, an
13
+ * anonymous default export named after the file). Re-exports are not declarations.
14
+ */
15
+ export function componentExportsOf(source, file) {
16
+ let info
17
+ try {
18
+ info = analyzeSource(file, source, { parseCache: new Map() })
19
+ } catch {
20
+ return []
21
+ }
22
+ return localComponentExports(info, file).map(({ name, exportName, line }) => ({ name, exportName, line }))
23
+ }
24
+
25
+ /** Scan root-relative globs for exported components. First declaration of a name wins. */
26
+ export async function scanComponents(root, patterns) {
27
+ if (!patterns.length) return []
28
+ const files = await glob(patterns, {
29
+ cwd: root,
30
+ absolute: true,
31
+ onlyFiles: true,
32
+ ignore: ['**/*.d.ts'],
33
+ })
34
+ const seen = new Set()
35
+ const entries = []
36
+ for (const absolute of files.sort()) {
37
+ if (!/\.(tsx|jsx)$/.test(absolute)) continue
38
+ const file = toPosix(relative(root, absolute))
39
+ for (const item of componentExportsOf(readFileSync(absolute, 'utf8'), file)) {
40
+ if (seen.has(item.name)) continue
41
+ seen.add(item.name)
42
+ entries.push({ ...item, file })
43
+ }
44
+ }
45
+ return entries.sort((a, b) => a.name.localeCompare(b.name))
46
+ }
47
+
48
+ /** Component groups as configured on the Vite plugin; a component appears in its first group only. */
49
+ export async function scanComponentGroups(root, groups) {
50
+ const seen = new Set()
51
+ const result = []
52
+ for (const group of groups) {
53
+ const entries = await scanComponents(root, group.globs)
54
+ const components = entries.filter((entry) => {
55
+ if (group.names?.length && !group.names.includes(entry.name)) return false
56
+ if (seen.has(entry.name)) return false
57
+ seen.add(entry.name)
58
+ return true
59
+ })
60
+ result.push({
61
+ id: group.id,
62
+ label: group.label,
63
+ ...(group.labelZh ? { labelZh: group.labelZh } : {}),
64
+ components,
65
+ })
66
+ }
67
+ return result
68
+ }
69
+
70
+ /**
71
+ * The directories component groups scan: the static prefix of each glob (`src/ui/**` plus a
72
+ * file pattern → `src/ui`; a plain file pattern → its directory), root-relative, in configuration order,
73
+ * deduped. "Promote to component" offers them as target directories (the first is the
74
+ * default).
75
+ */
76
+ export function componentDirsOf(root, groups) {
77
+ const dirs = []
78
+ const seen = new Set()
79
+ for (const group of groups ?? []) {
80
+ for (const pattern of group.globs ?? []) {
81
+ if (typeof pattern !== 'string' || pattern.startsWith('!')) continue
82
+ const segments = pattern.split('/')
83
+ const parts = []
84
+ for (const part of segments) {
85
+ if (/[*?{}[\]()!]/.test(part)) break
86
+ parts.push(part)
87
+ }
88
+ let dir = posix.normalize(parts.join('/') || '.')
89
+ const full = join(root, dir)
90
+ const exists = existsSync(full)
91
+ // A pattern without glob characters names a file: its directory is the one scanned.
92
+ if (parts.length === segments.length && (!exists || !statSync(full).isDirectory())) dir = posix.dirname(dir)
93
+ dir = dir.replace(/\/+$/, '') || '.'
94
+ if (seen.has(dir)) continue
95
+ seen.add(dir)
96
+ dirs.push({
97
+ dir,
98
+ group: group.id,
99
+ label: group.label,
100
+ ...(group.labelZh ? { labelZh: group.labelZh } : {}),
101
+ exists: existsSync(join(root, dir)),
102
+ })
103
+ }
104
+ }
105
+ return dirs
106
+ }
@@ -0,0 +1,2 @@
1
+ export declare const CATEGORIES: string[]
2
+ export declare const DEFAULT_CATEGORIES: string[]
@@ -0,0 +1,6 @@
1
+ // Value categories `consolidate` scans (`--category`). One list for the scanner
2
+ // (tokens/consolidate/normalize.mjs) and the editor's scan form.
3
+
4
+ export const CATEGORIES = ['color', 'spacing', 'radius', 'font-size', 'font-weight', 'line-height', 'border-width', 'shadow', 'size']
5
+ /** Categories scanned when none is given (`size` — widths/heights — is opt-in: mostly layout). */
6
+ export const DEFAULT_CATEGORIES = CATEGORIES.filter((category) => category !== 'size')
@@ -0,0 +1,4 @@
1
+ export declare const ENV_PREFIX: 'SEJI_'
2
+ export declare const LEGACY_ENV_PREFIX: 'DESIGN_SURFACE_'
3
+ export declare function toolEnv(name: string, env?: Record<string, string | undefined>): string | undefined
4
+ export declare function deleteToolEnv(name: string, env?: Record<string, string | undefined>): void
@@ -0,0 +1,18 @@
1
+ // The one reader of the tool's environment variables. `SEJI_<NAME>` is the name since 0.6.0;
2
+ // the 0.5.x name `DESIGN_SURFACE_<NAME>` is still honored (0.6.x compat). When both are set,
3
+ // SEJI_* wins.
4
+ export const ENV_PREFIX = 'SEJI_'
5
+ export const LEGACY_ENV_PREFIX = 'DESIGN_SURFACE_'
6
+
7
+ /** The value of SEJI_<name>, else DESIGN_SURFACE_<name>, else undefined. `name` has no prefix. */
8
+ export function toolEnv(name, env = process.env) {
9
+ const value = env[`${ENV_PREFIX}${name}`]
10
+ if (value !== undefined) return value
11
+ return env[`${LEGACY_ENV_PREFIX}${name}`]
12
+ }
13
+
14
+ /** Remove both spellings of a variable from `env` (in place). */
15
+ export function deleteToolEnv(name, env = process.env) {
16
+ delete env[`${ENV_PREFIX}${name}`]
17
+ delete env[`${LEGACY_ENV_PREFIX}${name}`]
18
+ }
@@ -0,0 +1,2 @@
1
+ export declare function gitHead(root: string): string | null
2
+ export declare function workingTreeChanges(root: string, baseCommit?: string | null): string[] | null