@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,30 @@
1
+ // Node-only git helpers for the sketch resolve reminder (shared/sketches.mjs): the commit a
2
+ // comment was made against, and which files changed since then.
3
+ import { spawnSync } from 'node:child_process'
4
+
5
+ const run = (root, args) => spawnSync('git', args, { cwd: root, encoding: 'utf8' })
6
+ const COMMIT_RE = /^[0-9a-f]{7,64}$/i
7
+
8
+ /** Current HEAD commit of the work tree at `root`, or null (no git, no commits). */
9
+ export function gitHead(root) {
10
+ const result = run(root, ['rev-parse', '--verify', '--quiet', 'HEAD'])
11
+ const sha = result.status === 0 ? result.stdout.trim() : ''
12
+ return COMMIT_RE.test(sha) ? sha : null
13
+ }
14
+
15
+ /**
16
+ * Files this change touched, relative to `root`: everything that differs from `baseCommit`
17
+ * (committed since then and uncommitted, staged or not) plus untracked, non-ignored files.
18
+ * Without a base, or when the commit is unknown here, the base is HEAD. Null outside git.
19
+ */
20
+ export function workingTreeChanges(root, baseCommit) {
21
+ const known =
22
+ typeof baseCommit === 'string' &&
23
+ COMMIT_RE.test(baseCommit) &&
24
+ run(root, ['cat-file', '-e', `${baseCommit}^{commit}`]).status === 0
25
+ const diff = run(root, ['diff', '--name-only', '--relative', known ? baseCommit : 'HEAD', '--'])
26
+ if (diff.status !== 0) return null
27
+ const untracked = run(root, ['ls-files', '--others', '--exclude-standard', '--', '.'])
28
+ const lines = `${diff.stdout}\n${untracked.status === 0 ? untracked.stdout : ''}`
29
+ return [...new Set(lines.split('\n').map((line) => line.trim()).filter(Boolean))]
30
+ }
@@ -0,0 +1,6 @@
1
+ export declare const NEUTRAL_CHROMA: number
2
+ export declare const HUE_LIMIT: number
3
+ export declare function rgbToOklab(rgb: [number, number, number] | number[]): [number, number, number]
4
+ export declare function oklch(lab: [number, number, number] | number[]): { L: number; C: number; h: number }
5
+ export declare function deltaE(labA: number[], labB: number[], alphaA?: number, alphaB?: number): number
6
+ export declare function sameHue(labA: number[], labB: number[]): boolean
@@ -0,0 +1,56 @@
1
+ // Perceptual color math, one owner for the consolidate scan (backend) and the editor's token
2
+ // pickers: sRGB → OKLab, ΔE (OKLab × 100, where ~2 is a just-noticeable difference), and the
3
+ // hue rule — colors whose hue differs are never "close", however small their ΔE.
4
+ //
5
+ // Hue rule (OKLCH): chroma C = |(a, b)|, hue h = atan2(b, a). One threshold, one rule:
6
+ // colors of different hue families are never close.
7
+ // - A color with C < NEUTRAL_CHROMA is neutral (gray / white): one family, its hue means nothing.
8
+ // - Every other color has a perceptible hue and is never in the neutral family, however light:
9
+ // #f8fbff (C 0.006, a faint blue white) is not white; #f5f3ff (violet, C 0.016) is not
10
+ // #f4f4f5 (gray, C 0.001) although they are ΔE 1.6 apart.
11
+ // - Two hued colors are one family when their hues are at most HUE_LIMIT degrees apart:
12
+ // #fef2f2 (red, h 17°) and #f5f3ff (violet, h 294°) are not.
13
+
14
+ /** Below this OKLCH chroma a color is neutral; from it on, its hue is perceptible. */
15
+ export const NEUTRAL_CHROMA = 0.005
16
+ /** Largest hue difference (degrees) between two chromatic colors of the same hue family. */
17
+ export const HUE_LIMIT = 30
18
+
19
+ const srgbToLinear = (c) => (c <= 0.04045 ? c / 12.92 : ((c + 0.055) / 1.055) ** 2.4)
20
+
21
+ /** sRGB (0..1) → OKLab `[L, a, b]`. */
22
+ export function rgbToOklab([r, g, b]) {
23
+ const lr = srgbToLinear(r)
24
+ const lg = srgbToLinear(g)
25
+ const lb = srgbToLinear(b)
26
+ const l = Math.cbrt(0.4122214708 * lr + 0.5363325363 * lg + 0.0514459929 * lb)
27
+ const m = Math.cbrt(0.2119034982 * lr + 0.6806995451 * lg + 0.1073969566 * lb)
28
+ const s = Math.cbrt(0.0883024619 * lr + 0.2817188376 * lg + 0.6299787005 * lb)
29
+ return [
30
+ 0.2104542553 * l + 0.793617785 * m - 0.0040720468 * s,
31
+ 1.9779984951 * l - 2.428592205 * m + 0.4505937099 * s,
32
+ 0.0259040371 * l + 0.7827717662 * m - 0.808675766 * s,
33
+ ]
34
+ }
35
+
36
+ /** OKLab → OKLCH `{ L, C, h }` (h in degrees, 0..360). */
37
+ export function oklch([L, a, b]) {
38
+ return { L, C: Math.hypot(a, b), h: ((Math.atan2(b, a) * 180) / Math.PI + 360) % 360 }
39
+ }
40
+
41
+ /** ΔE between two OKLab colors × 100, alpha difference × 100 in quadrature. */
42
+ export function deltaE(labA, labB, alphaA = 1, alphaB = 1) {
43
+ const d = Math.hypot(labA[0] - labB[0], labA[1] - labB[1], labA[2] - labB[2]) * 100
44
+ return Math.hypot(d, (alphaA - alphaB) * 100)
45
+ }
46
+
47
+ /** Do two OKLab colors have the same hue family (the hue rule above)? */
48
+ export function sameHue(labA, labB) {
49
+ const a = oklch(labA)
50
+ const b = oklch(labB)
51
+ const neutralA = a.C < NEUTRAL_CHROMA
52
+ const neutralB = b.C < NEUTRAL_CHROMA
53
+ if (neutralA || neutralB) return neutralA === neutralB
54
+ const diff = Math.abs(a.h - b.h) % 360
55
+ return Math.min(diff, 360 - diff) <= HUE_LIMIT
56
+ }
@@ -0,0 +1,5 @@
1
+ export declare function designOptimizeEntries(options?: {
2
+ dir?: string
3
+ componentGroups?: Array<{ globs?: string[] }>
4
+ userEntries?: string | string[] | null
5
+ }): string[]
@@ -0,0 +1,24 @@
1
+ // Dependency pre-bundling entries for the dev server. Vite crawls only index.html by default, so
2
+ // a package first imported from design/ (or from a component only the design files reach) is
3
+ // discovered at runtime: Vite re-optimizes and full-reloads every window, the editor included.
4
+ // Listing the design files and the catalog's component globs lets the startup scan find them.
5
+
6
+ const posixPath = (value) => String(value).split('\\').join('/').replace(/\/+$/, '')
7
+
8
+ /**
9
+ * `dir`: the design directory relative to the Vite root; `componentGroups`: the catalog groups;
10
+ * `userEntries`: the app's own optimizeDeps.entries (Vite concatenates ours onto them). When the
11
+ * app sets none, Vite's default (every .html) is listed too, since any entries replace it.
12
+ */
13
+ export function designOptimizeEntries({ dir = 'design', componentGroups = [], userEntries } = {}) {
14
+ const designDir = posixPath(dir || 'design') || '.'
15
+ const entries = []
16
+ if (userEntries === undefined || userEntries === null) entries.push('**/*.html')
17
+ entries.push(`${designDir}/**/*.{tsx,ts,jsx,js}`, `!${designDir}/**/*.d.ts`)
18
+ for (const group of componentGroups ?? []) {
19
+ for (const pattern of group?.globs ?? []) {
20
+ if (typeof pattern === 'string' && pattern && !pattern.startsWith('!')) entries.push(pattern.replace(/^\.\//, ''))
21
+ }
22
+ }
23
+ return [...new Set(entries)]
24
+ }
@@ -0,0 +1,11 @@
1
+ export declare const DESIGN_PACKAGE: '@rien7/seji'
2
+ export declare const RUNTIME_PACKAGE: '@rien7/design-surface-runtime'
3
+ export declare const PACKAGE_ROOT: string
4
+ export declare function findPackageDir(fromDir: string, name: string): string | null
5
+ export declare function readPackageVersion(dir: string): string | null
6
+ export declare function ownRuntimeDir(): string | null
7
+ export declare function runtimeAliases(projectRoot: string): {
8
+ aliases: Array<{ find: RegExp; replacement: string }>
9
+ dirs: string[]
10
+ }
11
+ export declare function workspaceRootOf(root: string): string
@@ -0,0 +1,96 @@
1
+ // Package lookup by directory walk (node_modules/<name>/package.json up the tree), shared by the
2
+ // CLI and the Vite plugin. No `require.resolve`: the runtime's exports only have an `import`
3
+ // condition, which CommonJS resolution refuses.
4
+ import { existsSync, readFileSync, realpathSync } from 'node:fs'
5
+ import { dirname, join, resolve } from 'node:path'
6
+ import { fileURLToPath } from 'node:url'
7
+
8
+ export const DESIGN_PACKAGE = '@rien7/seji'
9
+ export const RUNTIME_PACKAGE = '@rien7/design-surface-runtime'
10
+ /** This package's directory (the running CLI / plugin). */
11
+ export const PACKAGE_ROOT = resolve(dirname(fileURLToPath(import.meta.url)), '../..')
12
+
13
+ /** The real directory of package `name` resolvable from `fromDir`, or null. */
14
+ export function findPackageDir(fromDir, name) {
15
+ let dir = resolve(fromDir)
16
+ for (;;) {
17
+ const candidate = join(dir, 'node_modules', ...name.split('/'))
18
+ if (existsSync(join(candidate, 'package.json'))) {
19
+ try {
20
+ return realpathSync(candidate)
21
+ } catch {
22
+ return candidate
23
+ }
24
+ }
25
+ const parent = dirname(dir)
26
+ if (parent === dir) return null
27
+ dir = parent
28
+ }
29
+ }
30
+
31
+ export const readPackageVersion = (dir) => {
32
+ try {
33
+ return JSON.parse(readFileSync(join(dir, 'package.json'), 'utf8')).version ?? null
34
+ } catch {
35
+ return null
36
+ }
37
+ }
38
+
39
+ /** The runtime shipped with this CLI (its dependency), or null in a broken install. */
40
+ export const ownRuntimeDir = () => findPackageDir(PACKAGE_ROOT, RUNTIME_PACKAGE)
41
+
42
+ const firstExisting = (...files) => files.find((file) => existsSync(file)) ?? null
43
+
44
+ /**
45
+ * Vite aliases for a project that cannot resolve the runtime itself: `@rien7/design-surface-runtime`
46
+ * (and the `@rien7/seji/runtime` | `editor-ui` | `inspector` subpaths, when the project
47
+ * has no @rien7/seji either) point at this CLI's own copies. A project that installs
48
+ * them keeps its own. Returns `{ aliases, dirs }` (`dirs` for server.fs.allow).
49
+ */
50
+ export function runtimeAliases(projectRoot) {
51
+ const aliases = []
52
+ const dirs = []
53
+ if (!findPackageDir(projectRoot, RUNTIME_PACKAGE)) {
54
+ const runtimeDir = ownRuntimeDir()
55
+ const entry = runtimeDir && firstExisting(join(runtimeDir, 'dist/index.js'), join(runtimeDir, 'src/index.tsx'))
56
+ if (entry) {
57
+ aliases.push({ find: /^@rien7\/design-surface-runtime$/, replacement: entry })
58
+ dirs.push(runtimeDir)
59
+ }
60
+ }
61
+ if (!findPackageDir(projectRoot, DESIGN_PACKAGE)) {
62
+ const entries = {
63
+ runtime: firstExisting(join(PACKAGE_ROOT, 'dist/runtime/index.js'), join(PACKAGE_ROOT, 'src/runtime/index.tsx')),
64
+ 'editor-ui': firstExisting(join(PACKAGE_ROOT, 'dist/editor-ui.js'), join(PACKAGE_ROOT, 'src/editor-ui.ts')),
65
+ inspector: firstExisting(join(PACKAGE_ROOT, 'dist/inspector/runtime.js'), join(PACKAGE_ROOT, 'src/inspector/runtime.ts')),
66
+ }
67
+ for (const [sub, entry] of Object.entries(entries)) {
68
+ if (entry) aliases.push({ find: new RegExp(`^@rien7\\/seji\\/${sub}$`), replacement: entry })
69
+ }
70
+ if (entries.runtime) aliases.push({ find: /^@rien7\/seji$/, replacement: entries.runtime })
71
+ }
72
+ return { aliases, dirs }
73
+ }
74
+
75
+ /**
76
+ * The workspace root around `root` for server.fs.allow (Vite's default list, which a plugin's
77
+ * `allow` would otherwise replace): the nearest pnpm-workspace.yaml / package.json#workspaces /
78
+ * .git directory above it, else `root`.
79
+ */
80
+ export function workspaceRootOf(root) {
81
+ let dir = resolve(root)
82
+ let gitRoot = null
83
+ for (;;) {
84
+ if (existsSync(join(dir, 'pnpm-workspace.yaml')) || existsSync(join(dir, 'lerna.json'))) return dir
85
+ try {
86
+ const pkg = JSON.parse(readFileSync(join(dir, 'package.json'), 'utf8'))
87
+ if (pkg.workspaces) return dir
88
+ } catch {
89
+ // no package.json here
90
+ }
91
+ if (!gitRoot && existsSync(join(dir, '.git'))) gitRoot = dir
92
+ const parent = dirname(dir)
93
+ if (parent === dir) return gitRoot ?? resolve(root)
94
+ dir = parent
95
+ }
96
+ }
@@ -0,0 +1,23 @@
1
+ export declare const CACHE_DIR_NAME: '.seji'
2
+ export declare const CACHE_DIR: string
3
+ export declare const CACHE_PATHS: {
4
+ types: string
5
+ tsconfig: string
6
+ tokensTs: string
7
+ manifest: string
8
+ snapshots: string
9
+ consolidate: string
10
+ session: string
11
+ canvas: string
12
+ devLog: string
13
+ }
14
+ export declare const LEGACY_PATHS: { tokensTs: string; manifest: string; consolidate: string }
15
+ export declare function cachePath(root: string, key: keyof typeof CACHE_PATHS, ...rest: string[]): string
16
+ export declare function sessionDir(root: string, design: string): string
17
+ export declare function cameraFile(root: string, design: string): string
18
+ export declare const GITIGNORE_ENTRY: string
19
+ export declare function ensureCacheGitignore(
20
+ root: string,
21
+ options?: { dryRun?: boolean },
22
+ ): { status: 'created' | 'updated' | 'unchanged'; file: string }
23
+ export declare function isCacheIgnored(root: string): boolean
@@ -0,0 +1,72 @@
1
+ // Who owns which file in a project (README "What lives in your project"):
2
+ //
3
+ // app-owned <css dir>/tokens.generated.css and the one `@import` of it in the app's CSS entry
4
+ // yours design/tokens/*.tokens.json, tokens.config.json, surface.config.json,
5
+ // <design>/design.tsx, <design>/review.json, <design>/canvas.json, components.ts,
6
+ // components.json, providers.tsx, tokens.ts, tsconfig.json (committed, never overwritten)
7
+ // tool cache design/.seji/ (regenerated by setup / dev / tokens build, gitignored,
8
+ // delete anytime)
9
+ //
10
+ // Every path the tool regenerates lives under the one cache directory below.
11
+ import { existsSync, mkdirSync, readFileSync, writeFileSync } from 'node:fs'
12
+ import { dirname, join, resolve } from 'node:path'
13
+
14
+ export const CACHE_DIR_NAME = '.seji'
15
+ export const CACHE_DIR = `design/${CACHE_DIR_NAME}`
16
+
17
+ export const CACHE_PATHS = {
18
+ types: `${CACHE_DIR}/types`,
19
+ tsconfig: `${CACHE_DIR}/tsconfig.json`,
20
+ tokensTs: `${CACHE_DIR}/tokens.generated.ts`,
21
+ manifest: `${CACHE_DIR}/tokens.manifest.json`,
22
+ snapshots: `${CACHE_DIR}/snapshots`,
23
+ consolidate: `${CACHE_DIR}/consolidate`,
24
+ session: `${CACHE_DIR}/session`,
25
+ canvas: `${CACHE_DIR}/canvas`,
26
+ devLog: `${CACHE_DIR}/dev.log`,
27
+ }
28
+
29
+ /** Where 0.4.2 and earlier wrote the files that now live in the cache. */
30
+ export const LEGACY_PATHS = {
31
+ tokensTs: 'design/tokens.generated.ts',
32
+ manifest: 'design/tokens.manifest.json',
33
+ consolidate: 'design/.consolidate',
34
+ }
35
+
36
+ export const cachePath = (root, key, ...rest) => resolve(root, CACHE_PATHS[key], ...rest)
37
+
38
+ /** design/.seji/session/<design>/ (legacy per-frame session files, read once into review.json). */
39
+ export const sessionDir = (root, design) => resolve(root, CACHE_PATHS.session, design)
40
+ /** design/.seji/canvas/<design>.json: this person's camera (zoom + viewport). */
41
+ export const cameraFile = (root, design) => resolve(root, CACHE_PATHS.canvas, `${design}.json`)
42
+
43
+ const GITIGNORE_HEADER = '# seji tool cache: regenerated by seji setup / dev / tokens build. Delete anytime.'
44
+ export const GITIGNORE_ENTRY = `${CACHE_DIR_NAME}/`
45
+
46
+ const ignoresCache = (text) =>
47
+ text.split(/\r?\n/).some((line) => /^\/?\.seji\/?(?:\*\*)?$/.test(line.trim()))
48
+
49
+ /**
50
+ * design/.gitignore lists the cache: created, or the entry appended to an existing file (other
51
+ * lines kept). Idempotent. `{ status: 'created' | 'updated' | 'unchanged', file }`.
52
+ */
53
+ export function ensureCacheGitignore(root, { dryRun = false } = {}) {
54
+ const file = resolve(root, 'design', '.gitignore')
55
+ const rel = 'design/.gitignore'
56
+ if (!existsSync(file)) {
57
+ if (!dryRun) {
58
+ mkdirSync(dirname(file), { recursive: true })
59
+ writeFileSync(file, `${GITIGNORE_HEADER}\n${GITIGNORE_ENTRY}\n`)
60
+ }
61
+ return { status: 'created', file: rel }
62
+ }
63
+ const text = readFileSync(file, 'utf8')
64
+ if (ignoresCache(text)) return { status: 'unchanged', file: rel }
65
+ if (!dryRun) writeFileSync(file, `${text}${text.endsWith('\n') || !text ? '' : '\n'}${GITIGNORE_HEADER}\n${GITIGNORE_ENTRY}\n`)
66
+ return { status: 'updated', file: rel }
67
+ }
68
+
69
+ export const isCacheIgnored = (root) => {
70
+ const file = join(root, 'design', '.gitignore')
71
+ return existsSync(file) && ignoresCache(readFileSync(file, 'utf8'))
72
+ }
@@ -0,0 +1,20 @@
1
+ import type { ReviewItem } from './types'
2
+
3
+ export declare const PROMPT_RULES: readonly string[]
4
+ export declare function isUnreviewedProposal(item: ReviewItem): boolean
5
+ export declare function isCopyableReviewItem(item: ReviewItem): boolean
6
+ export declare function itemTargetLabel(item: ReviewItem): string
7
+ export declare function itemDetailLabel(item: ReviewItem): string
8
+ export declare function snapshotRejectionLabel(item: ReviewItem): string
9
+ export declare function shotLabel(item: ReviewItem): string
10
+ export declare function sketchLabel(item: ReviewItem): string
11
+ export declare function missingComponentPages(
12
+ catalog: ReadonlyArray<{ name: string; file: string }> | undefined,
13
+ hasPage: (name: string) => boolean,
14
+ ): Array<{ name: string; file: string }>
15
+ export declare function buildAgentPrompt(options: {
16
+ design: string
17
+ items: ReviewItem[]
18
+ batchId?: string
19
+ missingComponents?: Array<{ name: string; file: string }>
20
+ }): string
@@ -0,0 +1,201 @@
1
+ import { itemTargetKind } from './sketches.mjs'
2
+
3
+ export const PROMPT_RULES = [
4
+ '- The review ledger is the source of truth. Do not delete items or create per-frame session files.',
5
+ '- Tokens are design-scoped. Apply the tokenAction to the DTCG source named on the item (`design/tokens/*.tokens.json`), then run `seji tokens build` and `seji tokens check` (or `pnpm tokens:build` and `pnpm tokens:check`). Do not invent token names or edit generated token files. The surface verifies the generated value/alias before archiving.',
6
+ '- New tokens (`[create]`) go in the tier named on the item (never guess one) and get the item `$description` as their DTCG `$description`. When an item lists `replace hard-coded …`, also rewrite those literals in the listed files to the new token; `seji usage --hardcoded <file>` shows what is left.',
7
+ '- Tool-executed token items (`[tool …]`: rename, merge, deprecate, delete, describe, set, create, replace-literal, consolidate) are already applied: the DTCG source is edited, every static reference the parsers could locate is rewritten and tokens are rebuilt. Do NOT redo the token change or touch the rewritten places. Only fix the listed leftovers (dynamic class/style expressions, token names in strings, unsupported schemes such as styled-components / emotion / vanilla-extract / UnoCSS, mixed or shorthand values) to use the new token, then mark the item `resolved`; verification checks the end state.',
8
+ '- Approved agent token proposals (`[approved proposal]`): write the approved token to the named DTCG source (`design/tokens/*.tokens.json`), run `tokens build` + `tokens check`, and mark `resolved`.',
9
+ '- Rejected agent token proposals (`[rejected proposal]`): do NOT create or write that token into the DTCG source; update usages to existing tokens following `decisionNote` if provided, then mark `resolved`.',
10
+ '- Styles and free layout are frame-scoped; use the frame, component, source, and anchor context to locate the source change. Prefer idiomatic React + Tailwind (or `FreeItem` props) instead of introducing a parallel styling system.',
11
+ '- Style suggestions must use the named token (`var(--token)` or token class), not a resolved literal. If a suggestion should not become a token, reply why.',
12
+ '- `component`-scoped style items change the shared component source itself (every use), not the frame that showed it. A `:hover` / `:active` / `:focus` / `:disabled` suffix on the property means the change belongs to that interaction state (e.g. Tailwind `hover:` / `disabled:` variants), not the resting style.',
13
+ '- `component` items change a component itself. Tool-executed component items (`[tool rename|merge|replace]`) are already applied: the tool rewrote the export, its file name, imports, JSX, `as={X}` / `createElement` / re-exports and the `design/components.ts` / `design/components.json` entries from the syntax tree (merge and replace also marked the old component deprecated in `design/components.json`). Do NOT redo them; fix only the listed leftovers (strings, object keys, dynamic imports, files outside the project root …) with an AST / language-service rename (tsserver rename, ts-morph), never a text search-and-replace, then mark the item `resolved`. `delete`: search the whole project first to confirm nothing uses it; if something does, replace those usages first, then remove the component, its page and its registrations. `tidy`: move the listed frames off the component page (`usage` frames go to the page of the component or screen they belong to) and keep the page to style × state × content. Deprecation lives in `design/components.json` only: `component deprecate` / `component undeprecate` change it.',
14
+ '- `extract` items (Promote to component) ask for a NEW component `<to>` made from the element at `node` (anchor / source / path; `from: design` = in the design\'s code, `from: component` = inside the app component `parent`, which keeps its public props). (1) Create `<to>` in `dir` (one file named after it, like the components next to it); use existing tokens wherever a value matches one (`seji usage --hardcoded <file>`), never new literals for them. (2) Add props only for what differs between uses; keep everything else inside. (3) Replace the original element with `<to>` (in the design file, or in `parent`) so nothing looks different. (4) Add a component page with a default frame and register it in `design/components.ts`, and write the item `componentDescription` as its `$description` (`seji component describe <to> "<text>"`); `seji component show <to>` must then find it with its page. (5) Mark the item `resolved`; do not archive it.',
15
+ '- `[suggested]` token items (Suggest promoting to token) leave the name and tier to you: pick a name and tier that fit the existing token files (reuse an existing token if one already has this value), create it with a `$description`, run `tokens build`, replace the same literal across the project with the token (`seji usage --hardcoded`), write the chosen CSS name into the item `target.token` and the tier into `tokenTier` (edit `review.json` in place), then mark the item `resolved`; verification checks the token exists and the literal is gone.',
16
+ '- Read a component\'s `$description` in `design/components.json` (or `seji component show <Name>`) before choosing it; deprecated components name their replacement.',
17
+ '- Update item status with `seji status <design> <itemId> <in_progress|resolved> [--reply "<summary>"]` (or edit `status` / `resolvedAt` / `updatedAt` in place).',
18
+ '- Items with a `Screenshot:` line carry a PNG of the frame exactly as the person saw it (tab, state, scroll) when posting; read it before acting on the item.',
19
+ '- Comments with `Sketch: yes` point at a sketch component (source under `design/`, canvas-only): change the sketch and say in the reply that only the sketch changed and the product did not. Other comments about product UI change `src/`: follow the source to the component the product renders, and write the call chain from the product entry point plus the `src/` file you changed in the reply before resolving. Unsure which one it is: ask first.',
20
+ '- Reply to comment threads with `seji reply <design> <itemId> "<message>" [--resolve]`.',
21
+ '- Do not write `verifiedAt` or `archivedAt`, and do not delete or archive items manually. Token items archive only after verification plus 10 minutes; rejected proposals and non-token resolved items archive after 10 minutes; items with a snapshot baseline also wait for a passing snapshot check.',
22
+ '- Before editing source for these items, run `seji snapshot wait <design>`: the canvas captures "before" snapshots of new items in the background, and editing first would record the changed state as the baseline.',
23
+ '- Items with `snapshot rejected …` were sent back from snapshot review: fix what the reason describes on the named screens, mark the item `resolved`, then run `seji verify --snapshots` so the screens are compared again. Do not accept or reject snapshots yourself.',
24
+ '- Run the project checks (typecheck, build, and `seji tokens check`).',
25
+ ]
26
+
27
+ /** ` | snapshot rejected <frame>: <reason>` for every rejected snapshot of an item. */
28
+ export function snapshotRejectionLabel(item) {
29
+ const rejected = (item?.snapshots?.frames ?? []).filter((frame) => frame.decision === 'rejected')
30
+ return rejected.map((frame) => ` | snapshot rejected ${frame.key}: ${frame.reason ?? ''}`).join('')
31
+ }
32
+
33
+ /** `Sketch: yes` for comments that pointed at a sketch component (source under design/). */
34
+ export function sketchLabel(item) {
35
+ return item?.kind === 'comment' && itemTargetKind(item) === 'sketch' ? 'Sketch: yes' : ''
36
+ }
37
+
38
+ /** `Screenshot: <root-relative png>`: the frame as the person saw it when posting the item. */
39
+ export function shotLabel(item) {
40
+ return item?.shot ? `Screenshot: ${item.shot}` : ''
41
+ }
42
+
43
+ export function isUnreviewedProposal(item) {
44
+ return Boolean(item && item.author === 'agent' && !item.proposalDecision && item.status === 'open')
45
+ }
46
+
47
+ export function isCopyableReviewItem(item) {
48
+ if (!item) return false
49
+ if (item.status !== 'open' && item.status !== 'in_progress') return false
50
+ return !isUnreviewedProposal(item)
51
+ }
52
+
53
+ export function itemTargetLabel(item) {
54
+ const target = item?.target
55
+ const name =
56
+ target?.type === 'node'
57
+ ? target.node?.anchor ?? target.node?.name ?? target.node?.tag
58
+ : target?.type === 'token'
59
+ ? target.token || (item?.tokenSuggested ? '(name undecided)' : target.token)
60
+ : target?.type === 'component'
61
+ ? target.component
62
+ : target?.area
63
+ const action =
64
+ item?.kind === 'token' && item?.tokenAction
65
+ ? ` · ${item.tokenAction}`
66
+ : item?.kind === 'component' && item?.componentAction
67
+ ? ` · ${item.componentAction}`
68
+ : ''
69
+ const decision =
70
+ item?.author === 'agent' && item?.proposalDecision === 'approved'
71
+ ? ' [approved proposal]'
72
+ : item?.author === 'agent' && item?.proposalDecision === 'rejected'
73
+ ? ' [rejected proposal]'
74
+ : ''
75
+ return `${item?.kind ?? 'unknown'} · ${item?.scope ?? 'unknown'} · ${name ?? 'unknown'}${action}${decision}`
76
+ }
77
+
78
+ export function itemDetailLabel(item) {
79
+ if (!item) return ''
80
+ if (item.kind === 'token' && item.tokenOp) {
81
+ const op = item.tokenOp
82
+ const leftovers = (op.leftovers ?? [])
83
+ .map((entry) => `${entry.file}:${entry.line} ${entry.reason}${entry.text ? ` (${entry.text})` : ''}`)
84
+ .join('; ')
85
+ return `[tool ${op.op}] ${op.summary} | tool changed ${op.changed} place(s), left ${op.left} for agent${leftovers ? `: ${leftovers}` : ''}`
86
+ }
87
+ if (item.kind === 'token' && item.tokenSuggested && !item.target?.token) {
88
+ const node = item.node ?? {}
89
+ const where = [node.anchor ? `anchor ${node.anchor}` : '', node.source ? `at ${node.source}` : '', item.frame ? `frame ${item.frame}` : '']
90
+ .filter(Boolean)
91
+ .join(', ')
92
+ const files = (item.replaces?.files ?? []).join(', ')
93
+ return `[suggested] promote hard-coded ${item.property ?? 'value'} ${String(item.to ?? '')} to a token; name and tier undecided (you pick)${where ? ` | element: ${where}` : ''} | replace it everywhere it is hard-coded${files ? ` (${files})` : ''}`
94
+ }
95
+ if (item.kind === 'token') {
96
+ const action = item.tokenAction && item.tokenAction !== 'update' ? ` [${item.tokenAction}]` : ''
97
+ const tier = item.tokenTier ? ` ${item.tokenTier}` : ''
98
+ const alias = item.tokenAlias ? ` alias ${item.tokenAlias}` : ''
99
+ const note =
100
+ item.author === 'agent' && item.decisionNote
101
+ ? ` | ${item.proposalDecision ?? 'decision'} note: ${item.decisionNote}`
102
+ : ''
103
+ const rationale = item.author === 'agent' && item.rationale ? ` | rationale: ${item.rationale}` : ''
104
+ const description = item.tokenDescription ? ` | $description: ${item.tokenDescription}` : ''
105
+ const replaces = item.replaces?.value
106
+ ? ` | replace hard-coded ${item.replaces.value} with var(${item.target?.token}) in ${(item.replaces.files ?? []).join(', ') || 'its usages'}`
107
+ : ''
108
+ return `${action}${tier} ${String(item.from ?? '')} → ${String(item.to ?? '')}${alias}${item.source ? ` (${item.source})` : ''}${description}${replaces}${note}${rationale}`.trim()
109
+ }
110
+ if (item.kind === 'style' || item.kind === 'suggestion') {
111
+ const source = item.target?.type === 'node' && item.target.node?.source ? ` (${item.target.node.source})` : ''
112
+ const state = item.state && item.state !== 'default' ? `:${item.state}` : ''
113
+ return `${item.property ?? ''}${state}: ${String(item.from ?? '')} → ${String(item.to ?? '')}${source}`
114
+ }
115
+ if (item.kind === 'free') {
116
+ const from = item.from
117
+ const to = item.to
118
+ return from && to
119
+ ? `${Math.round(from.x ?? 0)},${Math.round(from.y ?? 0)} → ${Math.round(to.x ?? 0)},${Math.round(to.y ?? 0)}`
120
+ : ''
121
+ }
122
+ if (item.kind === 'comment') return item.body ?? ''
123
+ if (item.kind === 'component' && item.componentOp) {
124
+ const op = item.componentOp
125
+ const leftovers = (op.leftovers ?? [])
126
+ .map((entry) => `${entry.file}:${entry.line} ${entry.reason}${entry.text ? ` (${entry.text})` : ''}`)
127
+ .join('; ')
128
+ const reverted = op.revertedAt ? ' | reverted' : ''
129
+ return `[tool ${op.op}] ${op.summary} | tool changed ${op.changed} place(s), left ${op.left} for agent${leftovers ? `: ${leftovers}` : ''}${reverted}`
130
+ }
131
+ if (item.kind === 'component') {
132
+ const source = item.source ? ` (${item.source})` : ''
133
+ const reason = item.body ? ` | reason: ${item.body}` : ''
134
+ const rationale = item.author === 'agent' && item.rationale ? ` | rationale: ${item.rationale}` : ''
135
+ const note = item.decisionNote ? ` | ${item.proposalDecision ?? 'decision'} note: ${item.decisionNote}` : ''
136
+ const action = item.componentAction
137
+ if (action === 'extract') {
138
+ const origin =
139
+ item.from === 'component'
140
+ ? `split out of ${item.parent ?? '?'}${item.parentFile ? ` (${item.parentFile})` : ''}`
141
+ : 'from the design'
142
+ const node = item.node ?? {}
143
+ const where = [node.anchor ? `anchor ${node.anchor}` : '', node.source ? `at ${node.source}` : '', node.path ? `path ${node.path}` : '']
144
+ .filter(Boolean)
145
+ .join(', ')
146
+ return `promote to component ${item.to ?? ''} ${origin} → ${item.dir ?? '(component dir)'}${where ? ` | element: ${where}` : ''} | purpose: ${item.componentDescription ?? ''}${reason}${note}`
147
+ }
148
+ const detail =
149
+ action === 'rename'
150
+ ? `${item.from ?? ''} → ${item.to ?? ''}`
151
+ : action === 'merge'
152
+ ? `merge ${item.from ?? ''} into ${item.to ?? ''}`
153
+ : action === 'deprecate'
154
+ ? `deprecate ${item.from ?? ''} → ${item.to ?? 'no replacement'}${item.componentMode === 'replace' ? ' · replace usages now' : ' · mark only'}`
155
+ : action === 'undeprecate'
156
+ ? `undeprecate ${item.from ?? ''}`
157
+ : action === 'tidy'
158
+ ? `move frames ${(item.frames ?? []).join(', ')} off the ${item.from ?? ''} page`
159
+ : `delete ${item.from ?? ''} (search the whole project for uses first; replace any, then delete)`
160
+ return `${detail}${source}${reason}${rationale}${note}`
161
+ }
162
+ return `${item.property ?? ''}: ${String(item.from ?? '')} → ${String(item.to ?? '')}`
163
+ }
164
+
165
+ /**
166
+ * Catalog components without a registered page, as the prompt lists them. One function for
167
+ * the editor's Hand to agent and `seji prompt`; files are shown root-relative.
168
+ */
169
+ export function missingComponentPages(catalog, hasPage) {
170
+ return (catalog ?? [])
171
+ .filter((component) => !hasPage(component.name))
172
+ .map((component) => ({ name: component.name, file: String(component.file).replace(/^(?:\.\.\/)+/, '') }))
173
+ }
174
+
175
+ export function buildAgentPrompt({ design, items, batchId, missingComponents = [] }) {
176
+ const lines = [
177
+ 'Apply the pending review items from the design surface.',
178
+ '',
179
+ `Design: design/${design}/design.tsx`,
180
+ `Review ledger: design/${design}/review.json`,
181
+ ...(batchId ? [`Batch: ${batchId}`] : []),
182
+ 'Items:',
183
+ ...items.map((item) => {
184
+ const detail = `${itemDetailLabel(item)}${snapshotRejectionLabel(item)}`.trim()
185
+ const line = `- ${item.id} (${itemTargetLabel(item)})${detail ? `: ${detail}` : ''}`
186
+ return [line, sketchLabel(item), shotLabel(item)].filter(Boolean).join('\n ')
187
+ }),
188
+ '',
189
+ ...(missingComponents.length
190
+ ? [
191
+ 'Missing component pages:',
192
+ ...missingComponents.map((component) => `- ${component.name} (${component.file})`),
193
+ 'Create a normal page for each missing component and register it in design/components.ts.',
194
+ '',
195
+ ]
196
+ : []),
197
+ 'Rules:',
198
+ ...PROMPT_RULES,
199
+ ]
200
+ return lines.join('\n')
201
+ }
@@ -0,0 +1,11 @@
1
+ import type { ReviewItem } from './types'
2
+
3
+ export declare const PROPOSAL_DECISIONS: Array<'approve' | 'reject' | 'reset'>
4
+ export declare function decideProposal(options: {
5
+ root?: string
6
+ design: string
7
+ id: string
8
+ decision: 'approve' | 'reject' | 'reset'
9
+ note?: string
10
+ value?: string
11
+ }): { item: ReviewItem; reviewPath: string }
@@ -0,0 +1,42 @@
1
+ // Decisions on agent proposals (`author: 'agent'` review items: proposed tokens, component
2
+ // tidy proposals): approve, reject or reset. The editor's proposal cards write the same
3
+ // fields; the CLI (`seji proposal …`) and HTTP (`POST /__seji/api/proposal`)
4
+ // go through here.
5
+ import { mutateReview } from './reviewStore.mjs'
6
+
7
+ export const PROPOSAL_DECISIONS = ['approve', 'reject', 'reset']
8
+
9
+ /**
10
+ * Decide one proposal. `value` (approve only) replaces a token proposal's value; `note` is
11
+ * kept as `decisionNote` for the agent. Returns the updated item.
12
+ */
13
+ export function decideProposal({ root = process.cwd(), design, id, decision, note, value }) {
14
+ if (!design) throw new Error('design id is required')
15
+ if (!id) throw new Error('proposal id is required')
16
+ if (!PROPOSAL_DECISIONS.includes(decision)) {
17
+ throw new Error(`unknown decision: ${decision} (expected ${PROPOSAL_DECISIONS.join(', ')})`)
18
+ }
19
+ const trimmed = String(note ?? '').trim()
20
+ let updated
21
+ const { file } = mutateReview(root, design, (review) => {
22
+ const index = review.items.findIndex((item) => item?.id === id)
23
+ if (index === -1) throw new Error(`review item not found in ${design}: ${id}`)
24
+ const item = review.items[index]
25
+ if (item.author !== 'agent') throw new Error(`${id} is not an agent proposal`)
26
+ if (item.status === 'archived' || item.status === 'resolved') throw new Error(`${id} is already ${item.status}`)
27
+ const now = new Date().toISOString()
28
+ const { proposalDecision: _decision, decisionNote: _note, ...rest } = item
29
+ updated =
30
+ decision === 'reset'
31
+ ? { ...rest, updatedAt: now }
32
+ : {
33
+ ...rest,
34
+ ...(decision === 'approve' && value !== undefined && value !== null && item.kind === 'token' ? { to: String(value) } : {}),
35
+ proposalDecision: decision === 'approve' ? 'approved' : 'rejected',
36
+ ...(trimmed ? { decisionNote: trimmed } : {}),
37
+ updatedAt: now,
38
+ }
39
+ return { ...review, items: review.items.map((entry, position) => (position === index ? updated : entry)) }
40
+ })
41
+ return { item: updated, reviewPath: file }
42
+ }