@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,122 @@
1
+ import type { FlowSnapshot, ForcedState, InspectorNode, Rect, TokenValue } from './types';
2
+ export type PreviewCommand = {
3
+ action: 'enable' | 'disable';
4
+ } | {
5
+ action: 'select';
6
+ id: number;
7
+ } | {
8
+ action: 'set-token';
9
+ name: string;
10
+ value: string;
11
+ } | {
12
+ action: 'reset-tokens';
13
+ } | {
14
+ action: 'set-free-rect';
15
+ id?: number;
16
+ anchor?: string | null;
17
+ path?: string;
18
+ rect: Rect;
19
+ } | {
20
+ action: 'set-style';
21
+ id?: number;
22
+ anchor?: string | null;
23
+ path?: string;
24
+ property: string;
25
+ value: string;
26
+ state?: ForcedState;
27
+ } | {
28
+ action: 'reset-style';
29
+ id?: number;
30
+ anchor?: string | null;
31
+ path?: string;
32
+ property?: string;
33
+ state?: ForcedState;
34
+ } | {
35
+ action: 'force-state';
36
+ id?: number;
37
+ anchor?: string | null;
38
+ path?: string;
39
+ /** Target the root element this component renders (and isolate it). */
40
+ component?: string;
41
+ /** Names the frame may still render it under (a pending rename; see `renamedFrom`). */
42
+ aliases?: string[];
43
+ state: ForcedState | null;
44
+ } | {
45
+ /** Show only this element (state thumbnails); everything else is hidden. */
46
+ action: 'isolate';
47
+ id?: number;
48
+ anchor?: string | null;
49
+ path?: string;
50
+ component?: string;
51
+ aliases?: string[];
52
+ }
53
+ /** Select the root element a component renders (waits until it is rendered). */
54
+ | {
55
+ action: 'select-component';
56
+ component: string;
57
+ aliases?: string[];
58
+ } | {
59
+ action: 'event';
60
+ event: string;
61
+ };
62
+ export type EditorCommand = {
63
+ type: 'design:command';
64
+ } & PreviewCommand;
65
+ export type PreviewEvent = {
66
+ type: 'design:hello';
67
+ frame: string;
68
+ } | ({
69
+ type: 'design:ready';
70
+ frame: string;
71
+ tokens: TokenValue[];
72
+ baseline?: TokenValue[];
73
+ } & Partial<FlowSnapshot>) | {
74
+ type: 'design:tree';
75
+ frame: string;
76
+ nodes: InspectorNode[];
77
+ truncated: boolean;
78
+ } | {
79
+ type: 'design:select';
80
+ frame: string;
81
+ node: InspectorNode | null;
82
+ additive?: boolean;
83
+ refresh?: boolean;
84
+ } | {
85
+ type: 'design:node';
86
+ frame: string;
87
+ node: InspectorNode;
88
+ } | {
89
+ type: 'design:hover';
90
+ frame: string;
91
+ id: number | null;
92
+ rect: Rect | null;
93
+ } | ({
94
+ type: 'design:state';
95
+ frame: string;
96
+ } & FlowSnapshot) | {
97
+ type: 'design:free';
98
+ frame: string;
99
+ node: InspectorNode;
100
+ rect: Rect;
101
+ from?: Rect;
102
+ }
103
+ /** A wheel over the frame the canvas should apply (shared/wheelRouting.mjs). Client coords of the frame. */
104
+ | {
105
+ type: 'design:wheel';
106
+ frame: string;
107
+ route: 'zoom' | 'pan';
108
+ clientX: number;
109
+ clientY: number;
110
+ deltaX: number;
111
+ deltaY: number;
112
+ deltaMode: number;
113
+ }
114
+ /** Answer to a `component` force-state / isolate: where that component's root is. */
115
+ | {
116
+ type: 'design:target';
117
+ frame: string;
118
+ component: string;
119
+ rect: Rect;
120
+ };
121
+ export declare const isEditorCommand: (value: unknown) => value is EditorCommand;
122
+ //# sourceMappingURL=protocol.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"protocol.d.ts","sourceRoot":"","sources":["../../src/shared/protocol.ts"],"names":[],"mappings":"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"}
@@ -0,0 +1,7 @@
1
+ export const isEditorCommand = (value) => {
2
+ if (!value || typeof value !== 'object')
3
+ return false;
4
+ const data = value;
5
+ return data.type === 'design:command' && typeof data.action === 'string';
6
+ };
7
+ //# sourceMappingURL=protocol.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"protocol.js","sourceRoot":"","sources":["../../src/shared/protocol.ts"],"names":[],"mappings":"AA+EA,MAAM,CAAC,MAAM,eAAe,GAAG,CAAC,KAAc,EAA0B,EAAE;IACxE,IAAI,CAAC,KAAK,IAAI,OAAO,KAAK,KAAK,QAAQ;QAAE,OAAO,KAAK,CAAA;IACrD,MAAM,IAAI,GAAG,KAA6C,CAAA;IAC1D,OAAO,IAAI,CAAC,IAAI,KAAK,gBAAgB,IAAI,OAAO,IAAI,CAAC,MAAM,KAAK,QAAQ,CAAA;AAC1E,CAAC,CAAA","sourcesContent":["import type { FlowSnapshot, ForcedState, InspectorNode, Rect, TokenValue } from './types'\n\nexport type PreviewCommand =\n | { action: 'enable' | 'disable' }\n | { action: 'select'; id: number }\n | { action: 'set-token'; name: string; value: string }\n | { action: 'reset-tokens' }\n | { action: 'set-free-rect'; id?: number; anchor?: string | null; path?: string; rect: Rect }\n | {\n action: 'set-style'\n id?: number\n anchor?: string | null\n path?: string\n property: string\n value: string\n state?: ForcedState\n }\n | {\n action: 'reset-style'\n id?: number\n anchor?: string | null\n path?: string\n property?: string\n state?: ForcedState\n }\n | {\n action: 'force-state'\n id?: number\n anchor?: string | null\n path?: string\n /** Target the root element this component renders (and isolate it). */\n component?: string\n /** Names the frame may still render it under (a pending rename; see `renamedFrom`). */\n aliases?: string[]\n state: ForcedState | null\n }\n | {\n /** Show only this element (state thumbnails); everything else is hidden. */\n action: 'isolate'\n id?: number\n anchor?: string | null\n path?: string\n component?: string\n aliases?: string[]\n }\n /** Select the root element a component renders (waits until it is rendered). */\n | { action: 'select-component'; component: string; aliases?: string[] }\n | { action: 'event'; event: string }\n\nexport type EditorCommand = { type: 'design:command' } & PreviewCommand\n\nexport type PreviewEvent =\n | { type: 'design:hello'; frame: string }\n | ({\n type: 'design:ready'\n frame: string\n tokens: TokenValue[]\n baseline?: TokenValue[]\n } & Partial<FlowSnapshot>)\n | { type: 'design:tree'; frame: string; nodes: InspectorNode[]; truncated: boolean }\n | { type: 'design:select'; frame: string; node: InspectorNode | null; additive?: boolean; refresh?: boolean }\n | { type: 'design:node'; frame: string; node: InspectorNode }\n | { type: 'design:hover'; frame: string; id: number | null; rect: Rect | null }\n | ({ type: 'design:state'; frame: string } & FlowSnapshot)\n | { type: 'design:free'; frame: string; node: InspectorNode; rect: Rect; from?: Rect }\n /** A wheel over the frame the canvas should apply (shared/wheelRouting.mjs). Client coords of the frame. */\n | {\n type: 'design:wheel'\n frame: string\n route: 'zoom' | 'pan'\n clientX: number\n clientY: number\n deltaX: number\n deltaY: number\n deltaMode: number\n }\n /** Answer to a `component` force-state / isolate: where that component's root is. */\n | { type: 'design:target'; frame: string; component: string; rect: Rect }\n\nexport const isEditorCommand = (value: unknown): value is EditorCommand => {\n if (!value || typeof value !== 'object') return false\n const data = value as { type?: unknown; action?: unknown }\n return data.type === 'design:command' && typeof data.action === 'string'\n}\n"]}
@@ -0,0 +1,4 @@
1
+ import type { ReviewItem } from './types'
2
+
3
+ export declare const REVIEW_ARCHIVE_AFTER_MS: number
4
+ export declare function isDueForArchive(item: ReviewItem, now?: number): boolean
@@ -0,0 +1,19 @@
1
+ // When a resolved review item may leave the ledger. Plain JS so the editor, the headless
2
+ // tools and the tests share one rule.
3
+ import { snapshotArchiveHold } from './snapshotCheck.mjs'
4
+
5
+ export const REVIEW_ARCHIVE_AFTER_MS = 10 * 60 * 1000
6
+
7
+ /**
8
+ * Resolved items archive 10 minutes after `resolvedAt`, except:
9
+ * - token items (other than rejected proposals) need `verifiedAt`;
10
+ * - items with a snapshot baseline need a passing snapshot check (compared, every change
11
+ * accepted, nothing missing, failed or still capturing).
12
+ */
13
+ export function isDueForArchive(item, now = Date.now()) {
14
+ if (item.status !== 'resolved' || !item.resolvedAt) return false
15
+ if (item.kind === 'token' && item.proposalDecision !== 'rejected' && !item.verifiedAt) return false
16
+ if (snapshotArchiveHold(item, now)) return false
17
+ const at = Date.parse(item.resolvedAt)
18
+ return Number.isFinite(at) && now - at >= REVIEW_ARCHIVE_AFTER_MS
19
+ }
@@ -0,0 +1,30 @@
1
+ import type { ReviewLog, ReviewOp, ReviewReply } from './types'
2
+
3
+ export declare const SAFE_DESIGN_ID: RegExp
4
+ export declare function reviewFilePath(root: string, design: string): string
5
+ export declare function readReviewFile(file: string): Partial<ReviewLog> | null
6
+ export declare function normalizeReview(design: string, value: unknown): ReviewLog
7
+ export declare function writeReviewFile(
8
+ file: string,
9
+ design: string,
10
+ review: ReviewLog,
11
+ now?: string,
12
+ ): ReviewLog
13
+ export declare function withFileLock<T>(file: string, fn: () => T): T
14
+ export declare function mutateReview(
15
+ root: string,
16
+ design: string,
17
+ mutate: (review: ReviewLog) => ReviewLog | undefined,
18
+ options?: { create?: boolean; fallback?: () => ReviewLog },
19
+ ): { review: ReviewLog; file: string; written: boolean }
20
+ export declare function mergeThreads(
21
+ a: ReviewReply[] | undefined,
22
+ b: ReviewReply[] | undefined,
23
+ ): ReviewReply[] | undefined
24
+ export declare function applyOpsToReview(
25
+ review: ReviewLog,
26
+ design: string,
27
+ ops: ReviewOp[] | unknown,
28
+ options?: { head?: string | null | (() => string | null) },
29
+ ): ReviewLog
30
+ export declare const TOOL_OWNED_FIELDS: readonly ['checks', 'snapshots', 'shot', 'baseCommit']
@@ -0,0 +1,218 @@
1
+ // Serialized, merge-safe access to design/<design>/review.json.
2
+ //
3
+ // Every writer (Vite plugin, CLI status/reply/propose/clear/verify) goes through
4
+ // `mutateReview`, which holds a cross-process lock for the whole
5
+ // read → modify → write cycle. Without it, two writers that read the same
6
+ // snapshot would each write back their own copy and the later write would drop
7
+ // the earlier one's changes.
8
+ import { createHash } from 'node:crypto'
9
+ import { mkdirSync, readFileSync, rmSync, statSync, writeFileSync } from 'node:fs'
10
+ import { tmpdir } from 'node:os'
11
+ import { dirname, join, resolve } from 'node:path'
12
+
13
+ export const SAFE_DESIGN_ID = /^[A-Za-z0-9][A-Za-z0-9_-]{0,63}$/
14
+
15
+ const LOCK_TIMEOUT_MS = 5_000
16
+ const LOCK_STALE_MS = 10_000
17
+ const sleeper = new Int32Array(new SharedArrayBuffer(4))
18
+ const sleep = (ms) => Atomics.wait(sleeper, 0, 0, ms)
19
+
20
+ export function reviewFilePath(root, design) {
21
+ if (typeof design !== 'string' || !SAFE_DESIGN_ID.test(design)) {
22
+ throw new Error(`Invalid design id: ${design}`)
23
+ }
24
+ return resolve(root, 'design', design, 'review.json')
25
+ }
26
+
27
+ /** Parsed ledger, or null when the file does not exist. Malformed JSON throws instead of reading as empty. */
28
+ export function readReviewFile(file) {
29
+ let text
30
+ try {
31
+ text = readFileSync(file, 'utf8')
32
+ } catch (error) {
33
+ if (error?.code === 'ENOENT') return null
34
+ throw error
35
+ }
36
+ try {
37
+ return JSON.parse(text)
38
+ } catch {
39
+ throw new Error(`failed to parse review ledger ${file}`)
40
+ }
41
+ }
42
+
43
+ export function normalizeReview(design, value) {
44
+ return {
45
+ version: 1,
46
+ design,
47
+ updatedAt: typeof value?.updatedAt === 'string' ? value.updatedAt : new Date().toISOString(),
48
+ items: Array.isArray(value?.items) ? value.items : [],
49
+ batches: Array.isArray(value?.batches) ? value.batches : [],
50
+ }
51
+ }
52
+
53
+ export function writeReviewFile(file, design, review, now = new Date().toISOString()) {
54
+ const next = { ...normalizeReview(design, review), updatedAt: now }
55
+ mkdirSync(dirname(file), { recursive: true })
56
+ writeFileSync(file, `${JSON.stringify(next, null, 2)}\n`)
57
+ return next
58
+ }
59
+
60
+ // The lock lives in the OS temp dir (keyed by the ledger path) so lock files never
61
+ // show up in the project tree, file watchers, or Tailwind source scanning.
62
+ function lockDirFor(file) {
63
+ const key = createHash('sha1').update(resolve(file)).digest('hex').slice(0, 20)
64
+ return join(tmpdir(), 'seji-locks', `${key}.lock`)
65
+ }
66
+
67
+ /** Run `fn` while holding an exclusive cross-process lock for `file`. */
68
+ export function withFileLock(file, fn) {
69
+ const lock = lockDirFor(file)
70
+ mkdirSync(dirname(lock), { recursive: true })
71
+ const started = Date.now()
72
+ for (;;) {
73
+ try {
74
+ mkdirSync(lock)
75
+ break
76
+ } catch (error) {
77
+ if (error?.code !== 'EEXIST') throw error
78
+ try {
79
+ if (Date.now() - statSync(lock).mtimeMs > LOCK_STALE_MS) {
80
+ rmSync(lock, { recursive: true, force: true })
81
+ continue
82
+ }
83
+ } catch {
84
+ continue
85
+ }
86
+ if (Date.now() - started > LOCK_TIMEOUT_MS) {
87
+ throw new Error(`timed out waiting for review ledger lock (${file})`)
88
+ }
89
+ sleep(15)
90
+ }
91
+ }
92
+ try {
93
+ return fn()
94
+ } finally {
95
+ rmSync(lock, { recursive: true, force: true })
96
+ }
97
+ }
98
+
99
+ /**
100
+ * Locked read-modify-write. `mutate(review)` returns the next review, or
101
+ * `undefined` to leave the file untouched. Missing ledgers throw unless
102
+ * `fallback()` supplies one or `create` starts an empty ledger.
103
+ */
104
+ export function mutateReview(root, design, mutate, { create = false, fallback } = {}) {
105
+ const file = reviewFilePath(root, design)
106
+ return withFileLock(file, () => {
107
+ const parsed = readReviewFile(file)
108
+ if (parsed && (parsed.version !== 1 || !Array.isArray(parsed.items))) {
109
+ throw new Error(`invalid review ledger shape for ${design}`)
110
+ }
111
+ let current = parsed ? normalizeReview(design, parsed) : null
112
+ if (!current && fallback) current = normalizeReview(design, fallback())
113
+ if (!current && create) current = normalizeReview(design, null)
114
+ if (!current) throw new Error(`no review ledger for ${design}`)
115
+ const next = mutate(current)
116
+ if (next === undefined) return { review: current, file, written: false }
117
+ return { review: writeReviewFile(file, design, next), file, written: true }
118
+ })
119
+ }
120
+
121
+ const replyKey = (reply) => reply?.id ?? `${reply?.author}:${reply?.createdAt}:${reply?.body}`
122
+
123
+ /** Union of two reply threads by id, oldest first. */
124
+ export function mergeThreads(a, b) {
125
+ if (!Array.isArray(a) && !Array.isArray(b)) return undefined
126
+ const map = new Map()
127
+ for (const reply of [...(a ?? []), ...(b ?? [])]) map.set(replyKey(reply), reply)
128
+ return [...map.values()].sort((x, y) => String(x.createdAt).localeCompare(String(y.createdAt)))
129
+ }
130
+
131
+ // `baseCommit` (comments: git HEAD when created / moved to in_progress) is set here from the
132
+ // `head` option, never from the editor.
133
+ // `checks`, `snapshots` and `shot` are owned by the tool (verify / snapshot / the comment
134
+ // screenshot endpoint, which write through mutateReview directly). Editor ops can neither set nor replace them: an upsert or
135
+ // patch keeps the stored values and drops whatever the editor sent.
136
+ export const TOOL_OWNED_FIELDS = ['checks', 'snapshots', 'shot', 'baseCommit']
137
+
138
+ function withoutToolFields(value) {
139
+ if (!value || typeof value !== 'object') return {}
140
+ const next = { ...value }
141
+ for (const key of TOOL_OWNED_FIELDS) delete next[key]
142
+ return next
143
+ }
144
+
145
+ function toolFieldsOf(item) {
146
+ const out = {}
147
+ for (const key of TOOL_OWNED_FIELDS) if (item && item[key] !== undefined) out[key] = item[key]
148
+ return out
149
+ }
150
+
151
+ /**
152
+ * Apply editor ops to a ledger. An upsert replaces the item but keeps agent
153
+ * replies and agentReply written concurrently (e.g. by `seji reply`)
154
+ * that the editor's copy has not seen yet.
155
+ */
156
+ export function applyOpsToReview(review, design, ops, { head } = {}) {
157
+ if (!Array.isArray(ops)) throw new Error('Invalid review ops')
158
+ // `head()` is the current git commit (or null); asked at most once, only when needed.
159
+ let headValue
160
+ const currentHead = () => {
161
+ if (headValue === undefined) headValue = (typeof head === 'function' ? head() : head) ?? null
162
+ return headValue
163
+ }
164
+ // A comment gets `baseCommit` when it is created and again when it moves to in_progress.
165
+ const baseFor = (prev, next) => {
166
+ if (next?.kind !== 'comment') return {}
167
+ const starts = !prev || (next.status === 'in_progress' && prev.status !== 'in_progress')
168
+ const base = starts ? currentHead() : null
169
+ return base ? { baseCommit: base } : {}
170
+ }
171
+ const now = new Date().toISOString()
172
+ const items = new Map(review.items.map((item) => [item.id, item]))
173
+ const batches = new Map(review.batches.map((batch) => [batch.id, batch]))
174
+
175
+ for (const raw of ops) {
176
+ if (!raw || typeof raw !== 'object') continue
177
+ if (raw.type === 'upsert' && raw.item?.id) {
178
+ const prev = items.get(raw.item.id)
179
+ const thread = mergeThreads(prev?.thread, raw.item.thread)
180
+ items.set(raw.item.id, {
181
+ ...withoutToolFields(raw.item),
182
+ ...(thread ? { thread } : {}),
183
+ ...(prev?.agentReply !== undefined && raw.item.agentReply === undefined
184
+ ? { agentReply: prev.agentReply }
185
+ : {}),
186
+ ...toolFieldsOf(prev),
187
+ ...baseFor(prev, raw.item),
188
+ design,
189
+ })
190
+ } else if (raw.type === 'remove' && raw.id) {
191
+ items.delete(raw.id)
192
+ } else if (raw.type === 'archive' && Array.isArray(raw.ids)) {
193
+ for (const id of raw.ids) {
194
+ const item = items.get(id)
195
+ if (!item) continue
196
+ items.set(id, { ...item, status: 'archived', archivedAt: raw.archivedAt ?? now, updatedAt: now })
197
+ }
198
+ } else if (raw.type === 'patch' && raw.id) {
199
+ const item = items.get(raw.id)
200
+ if (item) {
201
+ const next = { ...item, ...withoutToolFields(raw.patch), ...toolFieldsOf(item), id: item.id, design }
202
+ items.set(raw.id, { ...next, ...baseFor(item, next) })
203
+ }
204
+ } else if (raw.type === 'batch' && raw.batch?.id) {
205
+ // Tool batches (token / component operations, with revert data) are written only by the
206
+ // tool itself; a client may neither create nor overwrite one.
207
+ const prev = batches.get(raw.batch.id)
208
+ if (prev?.kind === 'token-op' || prev?.kind === 'component-op' || prev?.revert) continue
209
+ const { revert: _revert, revertedAt: _revertedAt, revertSkipped: _revertSkipped, ...batch } = raw.batch
210
+ batches.set(
211
+ raw.batch.id,
212
+ batch.kind === 'token-op' || batch.kind === 'component-op' ? { ...batch, kind: undefined } : batch,
213
+ )
214
+ }
215
+ }
216
+
217
+ return { ...review, items: [...items.values()], batches: [...batches.values()] }
218
+ }
@@ -0,0 +1,21 @@
1
+ import type { ReviewItem } from './types'
2
+
3
+ export declare function isAwaitingVerification(item: ReviewItem): boolean
4
+ export declare function tokenVerificationGap(
5
+ item: ReviewItem,
6
+ context: {
7
+ values: Record<string, string>
8
+ aliases: Record<string, string>
9
+ literalFiles?: (value: string) => string[]
10
+ /** CSS name → DTCG `$deprecated` (true or reason) for deprecated tokens. */
11
+ deprecated?: Record<string, boolean | string>
12
+ /** CSS name → DTCG `$description` (checks `describe` items when given). */
13
+ descriptions?: Record<string, string>
14
+ },
15
+ ): string | null
16
+
17
+ export type VerificationGap = { code: string; params: Record<string, string>; message: string }
18
+ export declare function tokenVerificationGapOf(
19
+ item: ReviewItem,
20
+ context: Parameters<typeof tokenVerificationGap>[1],
21
+ ): VerificationGap | null
@@ -0,0 +1,158 @@
1
+ // Token review verification: a resolved token item is verified only when the built token
2
+ // source actually contains the requested change. Shared by the editor and the headless
3
+ // `seji verify` / `health` commands so both agree.
4
+
5
+ const same = (a, b) => {
6
+ if (a === undefined || a === null || b === undefined || b === null) return false
7
+ return String(a).trim().toLowerCase() === String(b).trim().toLowerCase()
8
+ }
9
+
10
+ /** Resolved token items still waiting for verification. */
11
+ export function isAwaitingVerification(item) {
12
+ return Boolean(
13
+ item &&
14
+ item.kind === 'token' &&
15
+ item.status === 'resolved' &&
16
+ !item.verifiedAt &&
17
+ item.proposalDecision !== 'rejected' &&
18
+ item.target?.type === 'token',
19
+ )
20
+ }
21
+
22
+ /**
23
+ * Why a token item is not verified yet, or null when the source matches.
24
+ * `values` / `aliases` map CSS names to built values / alias paths;
25
+ * `literalFiles(value)` lists files that still hard-code a value (optional).
26
+ *
27
+ * Tool-executed token operations (rename / merge / deprecate / delete / …) carry the end
28
+ * state they produced in `tokenOp.expect`: CSS names that must exist or be gone, aliases and
29
+ * values.
30
+ *
31
+ * `tokenVerificationGapOf` returns `{ code, params, message }` (the editor translates `code`);
32
+ * `tokenVerificationGap` returns just the message.
33
+ */
34
+ const gapOf = (code, params, message) => ({ code, params, message })
35
+
36
+ function expectedStateGap(expect, { values, aliases }) {
37
+ for (const name of expect.present ?? []) {
38
+ if (values[name] === undefined) return gapOf('missing', { token: name }, `${name} is not in the token source`)
39
+ }
40
+ for (const name of expect.absent ?? []) {
41
+ if (values[name] !== undefined) return gapOf('still-exists', { token: name }, `${name} still exists in the token source`)
42
+ }
43
+ for (const [name, path] of Object.entries(expect.aliases ?? {})) {
44
+ if (aliases[name] !== path) {
45
+ return gapOf('alias-differs', { token: name, actual: aliases[name] ?? '', expected: path }, `${name} aliases ${aliases[name] ?? '(nothing)'}, expected ${path}`)
46
+ }
47
+ }
48
+ for (const [name, value] of Object.entries(expect.values ?? {})) {
49
+ if (!same(values[name], value)) {
50
+ return gapOf('value-differs', { token: name, actual: values[name] ?? '', expected: value }, `${name} is ${values[name] ?? '(missing)'}, expected ${value}`)
51
+ }
52
+ }
53
+ return null
54
+ }
55
+
56
+ // A token named by DTCG dot path (`color.surface`) or CSS name (`--color-surface`).
57
+ const cssNameOfRef = (ref) => {
58
+ const text = String(ref ?? '').trim()
59
+ if (!text) return ''
60
+ return text.startsWith('--') ? text : `--${text.split('.').join('-')}`
61
+ }
62
+ const pathOfRef = (ref) => {
63
+ const text = String(ref ?? '').trim()
64
+ return text.startsWith('--') ? text.slice(2).split('-').join('.') : text
65
+ }
66
+ const missing = (token) => gapOf('missing', { token }, `${token} is not in the token source`)
67
+
68
+ // Hand-proposed (no tokenOp) rename / delete / describe / replace-literal items: each action
69
+ // has its own end state; none of them is "the value equals `to`".
70
+ function actionGap(item, { values, aliases, literalFiles, descriptions }) {
71
+ const token = item.target.token
72
+ switch (item.tokenAction) {
73
+ case 'rename': {
74
+ // The new name exists; the old one is gone or kept as an alias of the new one.
75
+ const next = cssNameOfRef(item.tokenAlias ?? item.to)
76
+ if (!next || values[next] === undefined) return missing(next || String(item.to ?? ''))
77
+ if (values[token] !== undefined && aliases[token] !== pathOfRef(item.tokenAlias ?? item.to)) {
78
+ return gapOf('still-exists', { token }, `${token} still exists in the token source`)
79
+ }
80
+ return null
81
+ }
82
+ case 'delete':
83
+ return values[token] === undefined ? null : gapOf('still-exists', { token }, `${token} still exists in the token source`)
84
+ case 'describe': {
85
+ if (values[token] === undefined) return missing(token)
86
+ const expected = String(item.tokenDescription ?? item.to ?? '').trim()
87
+ if (descriptions && (descriptions[token] ?? '').trim() !== expected) {
88
+ return gapOf(
89
+ 'description-differs',
90
+ { token, actual: descriptions[token] ?? '', expected },
91
+ `${token} has $description "${descriptions[token] ?? ''}", expected "${expected}"`,
92
+ )
93
+ }
94
+ return null
95
+ }
96
+ case 'replace-literal': {
97
+ // `to` names the token; `from` is the literal it replaced.
98
+ const target = values[token] !== undefined ? token : cssNameOfRef(item.to)
99
+ if (!target || values[target] === undefined) return missing(target || token)
100
+ if (item.from && literalFiles) {
101
+ const scope = item.replaces?.files
102
+ const left = literalFiles(item.from).filter((file) => !scope || scope.includes(file))
103
+ if (left.length) {
104
+ return gapOf('still-hardcoded', { value: item.from, files: left.join(', ') }, `${item.from} is still hard-coded in ${left.join(', ')}`)
105
+ }
106
+ }
107
+ return null
108
+ }
109
+ default:
110
+ return undefined
111
+ }
112
+ }
113
+
114
+ export function tokenVerificationGapOf(item, { values, aliases, literalFiles, deprecated, descriptions }) {
115
+ const token = item.target.token
116
+ const byAction = item.tokenOp?.expect ? undefined : actionGap(item, { values, aliases, literalFiles, descriptions })
117
+ if (byAction) return byAction
118
+ if (byAction === null) {
119
+ // fall through to the shared `replaces` check below
120
+ } else if (item.tokenOp?.expect) {
121
+ const gap = expectedStateGap(item.tokenOp.expect, { values, aliases })
122
+ if (gap) return gap
123
+ } else if (item.tokenAction === 'deprecate') {
124
+ // Deprecation keeps the token (DTCG `$deprecated`, usually aliased to the replacement);
125
+ // a token that is gone altogether also satisfies it.
126
+ if (values[token] === undefined || deprecated?.[token]) return null
127
+ return deprecated
128
+ ? gapOf('not-deprecated', { token }, `${token} is not marked $deprecated in the token source`)
129
+ : gapOf('still-exists', { token }, `${token} still exists in the token source`)
130
+ } else if (item.tokenAction === 'alias' || item.tokenAction === 'merge') {
131
+ if (item.to === undefined || aliases[token] !== item.to) {
132
+ return gapOf(
133
+ 'alias-differs',
134
+ { token, actual: aliases[token] ?? '', expected: String(item.to) },
135
+ `${token} aliases ${aliases[token] ?? '(nothing)'}, expected ${String(item.to)}`,
136
+ )
137
+ }
138
+ } else if (!same(values[token], item.to)) {
139
+ return values[token] === undefined
140
+ ? gapOf('missing', { token }, `${token} is not in the token source`)
141
+ : gapOf('value-differs', { token, actual: values[token], expected: String(item.to) }, `${token} is ${values[token]}, expected ${String(item.to)}`)
142
+ }
143
+ if (item.replaces?.value && literalFiles) {
144
+ const left = literalFiles(item.replaces.value).filter((file) => (item.replaces.files ?? []).includes(file))
145
+ if (left.length) {
146
+ return gapOf(
147
+ 'still-hardcoded',
148
+ { value: item.replaces.value, files: left.join(', ') },
149
+ `${item.replaces.value} is still hard-coded in ${left.join(', ')}`,
150
+ )
151
+ }
152
+ }
153
+ return null
154
+ }
155
+
156
+ export function tokenVerificationGap(item, context) {
157
+ return tokenVerificationGapOf(item, context)?.message ?? null
158
+ }
@@ -0,0 +1,15 @@
1
+ export type SizeMode = 'fixed' | 'fill' | 'hug'
2
+ export type ParentKind = 'row' | 'column' | 'block'
3
+
4
+ export declare function parentKindOf(display: string | null | undefined, flexDirection: string | null | undefined): ParentKind
5
+ export declare function heightModeOf(input?: {
6
+ height?: string | null
7
+ alignSelf?: string | null
8
+ flexGrow?: string | null
9
+ parentKind?: ParentKind
10
+ }): SizeMode
11
+ export declare function heightEdits(
12
+ mode: SizeMode,
13
+ parentKind?: ParentKind,
14
+ height?: number,
15
+ ): Array<{ property: string; value: string }>
@@ -0,0 +1,53 @@
1
+ // Height as a designer reads it (the Inspector's height row, mirroring the width row): a
2
+ // fixed length, filling the parent, or hugging the content. Pure: the inspector runtime
3
+ // reads the element's authored CSS and passes it in; the editor turns a mode into edits.
4
+
5
+ /** The parent's layout: `row` / `column` flex, or `block` (anything else). */
6
+ export function parentKindOf(display, flexDirection) {
7
+ if (!/flex/.test(String(display ?? ''))) return 'block'
8
+ return String(flexDirection ?? '').startsWith('column') ? 'column' : 'row'
9
+ }
10
+
11
+ const clean = (value) => String(value ?? '').trim().toLowerCase()
12
+
13
+ /**
14
+ * The height mode from the authored (declared, not computed) values: `height`, `alignSelf`,
15
+ * `flexGrow`. No explicit height reads as hug.
16
+ */
17
+ export function heightModeOf({ height, alignSelf, flexGrow, parentKind = 'block' } = {}) {
18
+ const authored = clean(height)
19
+ if (parentKind === 'column' && Number.parseFloat(clean(flexGrow)) > 0) return 'fill'
20
+ if (parentKind === 'row' && clean(alignSelf) === 'stretch' && (!authored || authored === 'auto')) return 'fill'
21
+ if (authored === '100%') return 'fill'
22
+ if (/^-?[\d.]+(px|rem|em)$/.test(authored)) return 'fixed'
23
+ return 'hug'
24
+ }
25
+
26
+ /** The style edits that put an element in a height mode (`height` is the current px height). */
27
+ export function heightEdits(mode, parentKind = 'block', height = 0) {
28
+ if (mode === 'fill') {
29
+ if (parentKind === 'column') {
30
+ return [
31
+ { property: 'flex-grow', value: '1' },
32
+ { property: 'flex-basis', value: '0%' },
33
+ { property: 'height', value: 'auto' },
34
+ ]
35
+ }
36
+ if (parentKind === 'row') {
37
+ return [
38
+ { property: 'align-self', value: 'stretch' },
39
+ { property: 'height', value: 'auto' },
40
+ ]
41
+ }
42
+ return [{ property: 'height', value: '100%' }]
43
+ }
44
+ // fixed / hug undo what fill set in this parent.
45
+ const undo =
46
+ parentKind === 'column'
47
+ ? [{ property: 'flex-grow', value: '0' }]
48
+ : parentKind === 'row'
49
+ ? [{ property: 'align-self', value: 'auto' }]
50
+ : []
51
+ if (mode === 'fixed') return [{ property: 'height', value: `${Math.round(Number(height) || 0)}px` }, ...undo]
52
+ return [{ property: 'height', value: 'auto' }, ...undo]
53
+ }