forgebook 0.1.3 → 0.1.4

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 (339) hide show
  1. package/README.md +74 -6
  2. package/dist/bin/forgebook/agentClient.d.ts +17 -0
  3. package/dist/bin/forgebook/agentClient.d.ts.map +1 -1
  4. package/dist/bin/forgebook/agentClient.js +21 -0
  5. package/dist/bin/forgebook/agentClient.js.map +1 -1
  6. package/dist/bin/forgebook/agentLoopCommands.d.mts +9 -0
  7. package/dist/bin/forgebook/agentLoopCommands.d.mts.map +1 -0
  8. package/dist/bin/forgebook/agentLoopCommands.mjs +217 -0
  9. package/dist/bin/forgebook/agentLoopCommands.mjs.map +1 -0
  10. package/dist/bin/forgebook/agentText.d.ts +37 -1
  11. package/dist/bin/forgebook/agentText.d.ts.map +1 -1
  12. package/dist/bin/forgebook/agentText.js +49 -2
  13. package/dist/bin/forgebook/agentText.js.map +1 -1
  14. package/dist/bin/forgebook/agents.md +46 -0
  15. package/dist/bin/forgebook/agentsText.d.ts +29 -0
  16. package/dist/bin/forgebook/agentsText.d.ts.map +1 -0
  17. package/dist/bin/forgebook/agentsText.js +48 -0
  18. package/dist/bin/forgebook/agentsText.js.map +1 -0
  19. package/dist/bin/forgebook/catalogueCommands.d.ts +51 -0
  20. package/dist/bin/forgebook/catalogueCommands.d.ts.map +1 -0
  21. package/dist/bin/forgebook/catalogueCommands.js +90 -0
  22. package/dist/bin/forgebook/catalogueCommands.js.map +1 -0
  23. package/dist/bin/forgebook/errorsRun.d.ts +27 -0
  24. package/dist/bin/forgebook/errorsRun.d.ts.map +1 -0
  25. package/dist/bin/forgebook/errorsRun.js +60 -0
  26. package/dist/bin/forgebook/errorsRun.js.map +1 -0
  27. package/dist/bin/forgebook/forgebook.mjs +109 -84
  28. package/dist/bin/forgebook/forgebook.mjs.map +1 -1
  29. package/dist/bin/forgebook/importers/storybook.d.ts +53 -0
  30. package/dist/bin/forgebook/importers/storybook.d.ts.map +1 -0
  31. package/dist/bin/forgebook/importers/storybook.js +318 -0
  32. package/dist/bin/forgebook/importers/storybook.js.map +1 -0
  33. package/dist/bin/forgebook/initCommands.d.mts +9 -0
  34. package/dist/bin/forgebook/initCommands.d.mts.map +1 -0
  35. package/dist/bin/forgebook/initCommands.mjs +86 -0
  36. package/dist/bin/forgebook/initCommands.mjs.map +1 -0
  37. package/dist/bin/forgebook/initConfig.d.ts +22 -0
  38. package/dist/bin/forgebook/initConfig.d.ts.map +1 -0
  39. package/dist/bin/forgebook/initConfig.js +51 -0
  40. package/dist/bin/forgebook/initConfig.js.map +1 -0
  41. package/dist/bin/forgebook/mcpTools.d.ts +29 -3
  42. package/dist/bin/forgebook/mcpTools.d.ts.map +1 -1
  43. package/dist/bin/forgebook/mcpTools.js +130 -7
  44. package/dist/bin/forgebook/mcpTools.js.map +1 -1
  45. package/dist/bin/forgebook/newStories.d.ts +27 -0
  46. package/dist/bin/forgebook/newStories.d.ts.map +1 -0
  47. package/dist/bin/forgebook/newStories.js +109 -0
  48. package/dist/bin/forgebook/newStories.js.map +1 -0
  49. package/dist/bin/forgebook/newStoriesFile.d.ts +18 -0
  50. package/dist/bin/forgebook/newStoriesFile.d.ts.map +1 -0
  51. package/dist/bin/forgebook/newStoriesFile.js +58 -0
  52. package/dist/bin/forgebook/newStoriesFile.js.map +1 -0
  53. package/dist/bin/forgebook/storyCheckRun.d.ts +39 -0
  54. package/dist/bin/forgebook/storyCheckRun.d.ts.map +1 -0
  55. package/dist/bin/forgebook/storyCheckRun.js +177 -0
  56. package/dist/bin/forgebook/storyCheckRun.js.map +1 -0
  57. package/dist/bin/forgebook-docs/catalogueDocs.d.ts +24 -0
  58. package/dist/bin/forgebook-docs/catalogueDocs.d.ts.map +1 -0
  59. package/dist/bin/forgebook-docs/catalogueDocs.js +71 -0
  60. package/dist/bin/forgebook-docs/catalogueDocs.js.map +1 -0
  61. package/dist/bin/forgebook-docs/catalogueDocs.types.d.ts +8 -0
  62. package/dist/bin/forgebook-docs/catalogueDocs.types.d.ts.map +1 -1
  63. package/dist/bin/forgebook-docs/catalogueMarkdown.d.ts +3 -1
  64. package/dist/bin/forgebook-docs/catalogueMarkdown.d.ts.map +1 -1
  65. package/dist/bin/forgebook-docs/catalogueMarkdown.js +62 -42
  66. package/dist/bin/forgebook-docs/catalogueMarkdown.js.map +1 -1
  67. package/dist/bin/forgebook-docs/catalogueOptions.d.ts +39 -0
  68. package/dist/bin/forgebook-docs/catalogueOptions.d.ts.map +1 -0
  69. package/dist/bin/forgebook-docs/catalogueOptions.js +76 -0
  70. package/dist/bin/forgebook-docs/catalogueOptions.js.map +1 -0
  71. package/dist/bin/forgebook-docs/collectDocs.d.ts +3 -1
  72. package/dist/bin/forgebook-docs/collectDocs.d.ts.map +1 -1
  73. package/dist/bin/forgebook-docs/collectDocs.js +37 -13
  74. package/dist/bin/forgebook-docs/collectDocs.js.map +1 -1
  75. package/dist/bin/forgebook-docs/forgebook-docs.mjs +17 -80
  76. package/dist/bin/forgebook-docs/forgebook-docs.mjs.map +1 -1
  77. package/dist/bin/forgebook-docs/llmsText.d.ts +24 -0
  78. package/dist/bin/forgebook-docs/llmsText.d.ts.map +1 -0
  79. package/dist/bin/forgebook-docs/llmsText.js +33 -0
  80. package/dist/bin/forgebook-docs/llmsText.js.map +1 -0
  81. package/dist/bin/forgebook-docs/sourceId.d.ts +9 -0
  82. package/dist/bin/forgebook-docs/sourceId.d.ts.map +1 -0
  83. package/dist/bin/forgebook-docs/sourceId.js +45 -0
  84. package/dist/bin/forgebook-docs/sourceId.js.map +1 -0
  85. package/dist/bin/frameworkDocs.d.ts +10 -0
  86. package/dist/bin/frameworkDocs.d.ts.map +1 -0
  87. package/dist/bin/frameworkDocs.js +43 -0
  88. package/dist/bin/frameworkDocs.js.map +1 -0
  89. package/dist/src/argTypes.d.ts +23 -0
  90. package/dist/src/argTypes.d.ts.map +1 -1
  91. package/dist/src/argTypes.js +27 -0
  92. package/dist/src/argTypes.js.map +1 -1
  93. package/dist/src/catalogue.d.ts +70 -3
  94. package/dist/src/catalogue.d.ts.map +1 -1
  95. package/dist/src/catalogue.js +85 -3
  96. package/dist/src/catalogue.js.map +1 -1
  97. package/dist/src/controlKeys.d.ts +85 -0
  98. package/dist/src/controlKeys.d.ts.map +1 -0
  99. package/dist/src/controlKeys.js +118 -0
  100. package/dist/src/controlKeys.js.map +1 -0
  101. package/dist/src/frame/frame.css +33 -2
  102. package/dist/src/frame/frameView.d.ts +2 -2
  103. package/dist/src/frame/frameView.d.ts.map +1 -1
  104. package/dist/src/frame/frameView.js +7 -3
  105. package/dist/src/frame/frameView.js.map +1 -1
  106. package/dist/src/frame/mountFrame.d.ts.map +1 -1
  107. package/dist/src/frame/mountFrame.js +26 -2
  108. package/dist/src/frame/mountFrame.js.map +1 -1
  109. package/dist/src/frame/spillOutline.d.ts +10 -0
  110. package/dist/src/frame/spillOutline.d.ts.map +1 -0
  111. package/dist/src/frame/spillOutline.js +80 -0
  112. package/dist/src/frame/spillOutline.js.map +1 -0
  113. package/dist/src/liveErrors.d.ts +57 -0
  114. package/dist/src/liveErrors.d.ts.map +1 -0
  115. package/dist/src/liveErrors.js +52 -0
  116. package/dist/src/liveErrors.js.map +1 -0
  117. package/dist/src/messages.d.ts +12 -0
  118. package/dist/src/messages.d.ts.map +1 -1
  119. package/dist/src/messages.js +4 -0
  120. package/dist/src/messages.js.map +1 -1
  121. package/dist/src/namedViews.d.ts +80 -0
  122. package/dist/src/namedViews.d.ts.map +1 -0
  123. package/dist/src/namedViews.js +88 -0
  124. package/dist/src/namedViews.js.map +1 -0
  125. package/dist/src/shell/AppearanceMenu.d.ts +15 -0
  126. package/dist/src/shell/AppearanceMenu.d.ts.map +1 -0
  127. package/dist/src/shell/AppearanceMenu.js +28 -0
  128. package/dist/src/shell/AppearanceMenu.js.map +1 -0
  129. package/dist/src/shell/BoxWidth.d.ts +40 -0
  130. package/dist/src/shell/BoxWidth.d.ts.map +1 -0
  131. package/dist/src/shell/BoxWidth.js +56 -0
  132. package/dist/src/shell/BoxWidth.js.map +1 -0
  133. package/dist/src/shell/ComponentPage.d.ts +17 -1
  134. package/dist/src/shell/ComponentPage.d.ts.map +1 -1
  135. package/dist/src/shell/ComponentPage.js +19 -54
  136. package/dist/src/shell/ComponentPage.js.map +1 -1
  137. package/dist/src/shell/ControlKeyField.d.ts +21 -0
  138. package/dist/src/shell/ControlKeyField.d.ts.map +1 -0
  139. package/dist/src/shell/ControlKeyField.js +46 -0
  140. package/dist/src/shell/ControlKeyField.js.map +1 -0
  141. package/dist/src/shell/ControlRow.d.ts +31 -0
  142. package/dist/src/shell/ControlRow.d.ts.map +1 -0
  143. package/dist/src/shell/ControlRow.js +27 -0
  144. package/dist/src/shell/ControlRow.js.map +1 -0
  145. package/dist/src/shell/Example.d.ts +58 -0
  146. package/dist/src/shell/Example.d.ts.map +1 -0
  147. package/dist/src/shell/Example.js +89 -0
  148. package/dist/src/shell/Example.js.map +1 -0
  149. package/dist/src/shell/NamedViews.d.ts +23 -0
  150. package/dist/src/shell/NamedViews.d.ts.map +1 -0
  151. package/dist/src/shell/NamedViews.js +49 -0
  152. package/dist/src/shell/NamedViews.js.map +1 -0
  153. package/dist/src/shell/PinnedControl.d.ts +25 -0
  154. package/dist/src/shell/PinnedControl.d.ts.map +1 -0
  155. package/dist/src/shell/PinnedControl.js +81 -0
  156. package/dist/src/shell/PinnedControl.js.map +1 -0
  157. package/dist/src/shell/PropsTab.d.ts +5 -2
  158. package/dist/src/shell/PropsTab.d.ts.map +1 -1
  159. package/dist/src/shell/PropsTab.js +12 -15
  160. package/dist/src/shell/PropsTab.js.map +1 -1
  161. package/dist/src/shell/Shell.d.ts.map +1 -1
  162. package/dist/src/shell/Shell.js +27 -2
  163. package/dist/src/shell/Shell.js.map +1 -1
  164. package/dist/src/shell/Sidebar.d.ts +11 -9
  165. package/dist/src/shell/Sidebar.d.ts.map +1 -1
  166. package/dist/src/shell/Sidebar.js +48 -42
  167. package/dist/src/shell/Sidebar.js.map +1 -1
  168. package/dist/src/shell/SidebarEntries.d.ts +50 -0
  169. package/dist/src/shell/SidebarEntries.d.ts.map +1 -0
  170. package/dist/src/shell/SidebarEntries.js +51 -0
  171. package/dist/src/shell/SidebarEntries.js.map +1 -0
  172. package/dist/src/shell/Stage.d.ts.map +1 -1
  173. package/dist/src/shell/Stage.js +19 -2
  174. package/dist/src/shell/Stage.js.map +1 -1
  175. package/dist/src/shell/Toolbar.d.ts +7 -3
  176. package/dist/src/shell/Toolbar.d.ts.map +1 -1
  177. package/dist/src/shell/Toolbar.js +38 -68
  178. package/dist/src/shell/Toolbar.js.map +1 -1
  179. package/dist/src/shell/ToolbarControl.d.ts +47 -0
  180. package/dist/src/shell/ToolbarControl.d.ts.map +1 -0
  181. package/dist/src/shell/ToolbarControl.js +150 -0
  182. package/dist/src/shell/ToolbarControl.js.map +1 -0
  183. package/dist/src/shell/UsedIn.d.ts +38 -0
  184. package/dist/src/shell/UsedIn.d.ts.map +1 -0
  185. package/dist/src/shell/UsedIn.js +77 -0
  186. package/dist/src/shell/UsedIn.js.map +1 -0
  187. package/dist/src/shell/ViewMenu.d.ts +37 -0
  188. package/dist/src/shell/ViewMenu.d.ts.map +1 -0
  189. package/dist/src/shell/ViewMenu.js +216 -0
  190. package/dist/src/shell/ViewMenu.js.map +1 -0
  191. package/dist/src/shell/controlCycle.d.ts +28 -0
  192. package/dist/src/shell/controlCycle.d.ts.map +1 -0
  193. package/dist/src/shell/controlCycle.js +51 -0
  194. package/dist/src/shell/controlCycle.js.map +1 -0
  195. package/dist/src/shell/dockTabs.d.ts +3 -0
  196. package/dist/src/shell/dockTabs.d.ts.map +1 -1
  197. package/dist/src/shell/dockTabs.js +1 -1
  198. package/dist/src/shell/dockTabs.js.map +1 -1
  199. package/dist/src/shell/icons.d.ts +6 -0
  200. package/dist/src/shell/icons.d.ts.map +1 -1
  201. package/dist/src/shell/icons.js +7 -1
  202. package/dist/src/shell/icons.js.map +1 -1
  203. package/dist/src/shell/keyboard.d.ts +2 -1
  204. package/dist/src/shell/keyboard.d.ts.map +1 -1
  205. package/dist/src/shell/keyboard.js +5 -2
  206. package/dist/src/shell/keyboard.js.map +1 -1
  207. package/dist/src/shell/shell.css +826 -243
  208. package/dist/src/shell/strings.d.ts +45 -0
  209. package/dist/src/shell/strings.d.ts.map +1 -1
  210. package/dist/src/shell/strings.js +45 -0
  211. package/dist/src/shell/strings.js.map +1 -1
  212. package/dist/src/shell/useAppearance.d.ts +17 -0
  213. package/dist/src/shell/useAppearance.d.ts.map +1 -0
  214. package/dist/src/shell/useAppearance.js +36 -0
  215. package/dist/src/shell/useAppearance.js.map +1 -0
  216. package/dist/src/shell/useControlKeys.d.ts +23 -0
  217. package/dist/src/shell/useControlKeys.d.ts.map +1 -0
  218. package/dist/src/shell/useControlKeys.js +44 -0
  219. package/dist/src/shell/useControlKeys.js.map +1 -0
  220. package/dist/src/shell/useFold.d.ts +27 -0
  221. package/dist/src/shell/useFold.d.ts.map +1 -0
  222. package/dist/src/shell/useFold.js +87 -0
  223. package/dist/src/shell/useFold.js.map +1 -0
  224. package/dist/src/shell/useFrameMessages.d.ts +2 -0
  225. package/dist/src/shell/useFrameMessages.d.ts.map +1 -1
  226. package/dist/src/shell/useFrameMessages.js +3 -0
  227. package/dist/src/shell/useFrameMessages.js.map +1 -1
  228. package/dist/src/shell/useFullPage.d.ts +45 -0
  229. package/dist/src/shell/useFullPage.d.ts.map +1 -0
  230. package/dist/src/shell/useFullPage.js +149 -0
  231. package/dist/src/shell/useFullPage.js.map +1 -0
  232. package/dist/src/shell/usePopover.d.ts +17 -3
  233. package/dist/src/shell/usePopover.d.ts.map +1 -1
  234. package/dist/src/shell/usePopover.js +65 -4
  235. package/dist/src/shell/usePopover.js.map +1 -1
  236. package/dist/src/shell/useStored.d.ts +13 -2
  237. package/dist/src/shell/useStored.d.ts.map +1 -1
  238. package/dist/src/shell/useStored.js +1 -1
  239. package/dist/src/shell/useStored.js.map +1 -1
  240. package/dist/src/shell/useToolbarLayout.d.ts +39 -0
  241. package/dist/src/shell/useToolbarLayout.d.ts.map +1 -0
  242. package/dist/src/shell/useToolbarLayout.js +58 -0
  243. package/dist/src/shell/useToolbarLayout.js.map +1 -0
  244. package/dist/src/shell/useToolbarOverflow.d.ts +31 -0
  245. package/dist/src/shell/useToolbarOverflow.d.ts.map +1 -0
  246. package/dist/src/shell/useToolbarOverflow.js +62 -0
  247. package/dist/src/shell/useToolbarOverflow.js.map +1 -0
  248. package/dist/src/shell/useWorstCase.d.ts +46 -0
  249. package/dist/src/shell/useWorstCase.d.ts.map +1 -0
  250. package/dist/src/shell/useWorstCase.js +42 -0
  251. package/dist/src/shell/useWorstCase.js.map +1 -0
  252. package/dist/src/shell/worstArgs.d.ts +42 -0
  253. package/dist/src/shell/worstArgs.d.ts.map +1 -0
  254. package/dist/src/shell/worstArgs.js +47 -0
  255. package/dist/src/shell/worstArgs.js.map +1 -0
  256. package/dist/src/spills.d.ts +31 -0
  257. package/dist/src/spills.d.ts.map +1 -0
  258. package/dist/src/spills.js +65 -0
  259. package/dist/src/spills.js.map +1 -0
  260. package/dist/src/storyCheck.d.ts +105 -0
  261. package/dist/src/storyCheck.d.ts.map +1 -0
  262. package/dist/src/storyCheck.js +63 -0
  263. package/dist/src/storyCheck.js.map +1 -0
  264. package/dist/src/switches.d.ts +16 -4
  265. package/dist/src/switches.d.ts.map +1 -1
  266. package/dist/src/switches.js +30 -5
  267. package/dist/src/switches.js.map +1 -1
  268. package/dist/src/toolbarLayout.d.ts +119 -0
  269. package/dist/src/toolbarLayout.d.ts.map +1 -0
  270. package/dist/src/toolbarLayout.js +155 -0
  271. package/dist/src/toolbarLayout.js.map +1 -0
  272. package/dist/src/usedIn.d.ts +60 -0
  273. package/dist/src/usedIn.d.ts.map +1 -0
  274. package/dist/src/usedIn.js +92 -0
  275. package/dist/src/usedIn.js.map +1 -0
  276. package/dist/src/viewState.d.ts +6 -10
  277. package/dist/src/viewState.d.ts.map +1 -1
  278. package/dist/src/viewState.js +20 -18
  279. package/dist/src/viewState.js.map +1 -1
  280. package/dist/src/viewWords.d.ts +26 -0
  281. package/dist/src/viewWords.d.ts.map +1 -0
  282. package/dist/src/viewWords.js +29 -0
  283. package/dist/src/viewWords.js.map +1 -0
  284. package/dist/src/vite/adapter.d.ts +13 -4
  285. package/dist/src/vite/adapter.d.ts.map +1 -1
  286. package/dist/src/vite/adapter.js +4 -2
  287. package/dist/src/vite/adapter.js.map +1 -1
  288. package/dist/src/vite/agent.types.d.ts +32 -2
  289. package/dist/src/vite/agent.types.d.ts.map +1 -1
  290. package/dist/src/vite/agentApi.d.ts +15 -3
  291. package/dist/src/vite/agentApi.d.ts.map +1 -1
  292. package/dist/src/vite/agentApi.js +63 -9
  293. package/dist/src/vite/agentApi.js.map +1 -1
  294. package/dist/src/vite/agentRoutes.d.ts +8 -3
  295. package/dist/src/vite/agentRoutes.d.ts.map +1 -1
  296. package/dist/src/vite/agentRoutes.js +84 -23
  297. package/dist/src/vite/agentRoutes.js.map +1 -1
  298. package/dist/src/vite/configFile.d.ts +2 -1
  299. package/dist/src/vite/configFile.d.ts.map +1 -1
  300. package/dist/src/vite/configFile.js +29 -11
  301. package/dist/src/vite/configFile.js.map +1 -1
  302. package/dist/src/vite/docsExtractor.d.ts +26 -2
  303. package/dist/src/vite/docsExtractor.d.ts.map +1 -1
  304. package/dist/src/vite/docsExtractor.js +12 -9
  305. package/dist/src/vite/docsExtractor.js.map +1 -1
  306. package/dist/src/vite/docsWorker.js +18 -2
  307. package/dist/src/vite/docsWorker.js.map +1 -1
  308. package/dist/src/vite/forgebookPlugin.d.ts.map +1 -1
  309. package/dist/src/vite/forgebookPlugin.js +109 -16
  310. package/dist/src/vite/forgebookPlugin.js.map +1 -1
  311. package/dist/src/vite/indexStoryFile.d.ts +14 -0
  312. package/dist/src/vite/indexStoryFile.d.ts.map +1 -1
  313. package/dist/src/vite/indexStoryFile.js +13 -4
  314. package/dist/src/vite/indexStoryFile.js.map +1 -1
  315. package/dist/src/vite/mcpProtocol.d.ts +9 -0
  316. package/dist/src/vite/mcpProtocol.d.ts.map +1 -1
  317. package/dist/src/vite/mcpProtocol.js +6 -3
  318. package/dist/src/vite/mcpProtocol.js.map +1 -1
  319. package/dist/src/vite/storyFilesModule.d.ts +28 -1
  320. package/dist/src/vite/storyFilesModule.d.ts.map +1 -1
  321. package/dist/src/vite/storyFilesModule.js +34 -14
  322. package/dist/src/vite/storyFilesModule.js.map +1 -1
  323. package/dist/src/vite/usageGraph.d.ts +45 -0
  324. package/dist/src/vite/usageGraph.d.ts.map +1 -0
  325. package/dist/src/vite/usageGraph.js +246 -0
  326. package/dist/src/vite/usageGraph.js.map +1 -0
  327. package/dist/src/vite/usageModule.d.ts +33 -0
  328. package/dist/src/vite/usageModule.d.ts.map +1 -0
  329. package/dist/src/vite/usageModule.js +135 -0
  330. package/dist/src/vite/usageModule.js.map +1 -0
  331. package/dist/src/worstCase.d.ts +16 -0
  332. package/dist/src/worstCase.d.ts.map +1 -0
  333. package/dist/src/worstCase.js +16 -0
  334. package/dist/src/worstCase.js.map +1 -0
  335. package/package.json +14 -2
  336. package/dist/src/shell/SchemeSwitches.d.ts +0 -24
  337. package/dist/src/shell/SchemeSwitches.d.ts.map +0 -1
  338. package/dist/src/shell/SchemeSwitches.js +0 -36
  339. package/dist/src/shell/SchemeSwitches.js.map +0 -1
@@ -0,0 +1,46 @@
1
+ ## Stories (Forgebook)
2
+
3
+ This project's components have stories, shown by [Forgebook](https://github.com/ensiria/forgebook) (`forgebook dev`).
4
+ When you add or change a component, add or change its stories, then check them with the commands below: they answer
5
+ in JSON with `--json`, and every answer carries the links that open a story for a person.
6
+
7
+ ### Writing a story file
8
+
9
+ - One file per component, beside it: `Badge.tsx` and `Badge.stories.tsx`, in CSF 3 (Storybook's format; Forgebook
10
+ reads it, never MDX or addons).
11
+ - The meta is the default export; the stories are named exports, each with a one-line TSDoc saying what it shows (the
12
+ catalogue shows that sentence):
13
+
14
+ ```tsx
15
+ import type { Meta, Story } from "@forgebook/react";
16
+
17
+ import { Badge } from "./Badge";
18
+
19
+ export default { title: "Data/Badge", component: Badge } satisfies Meta<typeof Badge>;
20
+
21
+ /** The label as most pages use it. */
22
+ export const Default: Story<typeof Badge> = { args: { label: "New" }, parameters: { main: true } };
23
+ ```
24
+
25
+ - `parameters.main: true` marks the one real, well-made use drawn at the top of the component's page.
26
+ - `parameters.group` puts a story under a heading of the page (`"states"`, `"worst-case"`); keep one story per
27
+ meaningful state, not one per prop value.
28
+ - Add a worst case: very long text, words without spaces, huge numbers (`forgebook new` writes one).
29
+ - `parameters.height` gives the frame the room an overlay the story opens needs (a menu, a popover), in CSS px.
30
+ - Texts a person reads come from the source's texts, not from the story: `args: { label: storyText("badge.new") }`
31
+ (`@forgebook/story-format/texts`), or `useStoryText()` inside a `render`.
32
+ - Write `title`, `parameters.main`, `group` and `height` as plain values: the catalogue reads them without running
33
+ the file.
34
+
35
+ ### Commands
36
+
37
+ | Command | What it is for |
38
+ |---|---|
39
+ | `npx forgebook new src/Badge.tsx` | A component's first stories, from its typed props |
40
+ | `npx forgebook stories --component badge --json` | The stories and their ids; fails when a story file is broken |
41
+ | `npx forgebook story <id> --json` | One story: its args, its component's props, the components whose stories use it |
42
+ | `npx forgebook check <id> --json` | The catalogue's checks on one story: accessibility, spills, overlays, errors, a failed play |
43
+ | `npx forgebook errors --json` | What the open frames reported while you edited: render errors, failed plays |
44
+ | `npx forgebook shot <id> --view "dark 360"` | The story as a picture, to look at it (a view as words, or `theme=dark&width=360`) |
45
+
46
+ Run `npx forgebook <command> --help` for the options. With an MCP client, `npx forgebook mcp` offers the same as tools.
@@ -0,0 +1,29 @@
1
+ /**
2
+ * The instructions `forgebook agents` gives a project's coding agents: Forgebook's section of the project's
3
+ * `AGENTS.md`, and the same text as a Claude Code skill.
4
+ *
5
+ * @remarks
6
+ * The section sits between two markers, so running the command again replaces its own text and leaves the rest of the
7
+ * file as the project wrote it. `AGENTS.md` is the file Codex reads and Claude Code reads when the project has no
8
+ * `CLAUDE.md` (one that has can import it with `@AGENTS.md`). Pure: texts in, text out.
9
+ *
10
+ * @module
11
+ */
12
+ /** The line before Forgebook's section. */
13
+ export declare const AGENTS_START = "<!-- forgebook:start: written by `forgebook agents`, replaced when it runs again -->";
14
+ /** The line after it. */
15
+ export declare const AGENTS_END = "<!-- forgebook:end -->";
16
+ /**
17
+ * A file's text with Forgebook's section in it: put in place of the one already there, else added at the end.
18
+ *
19
+ * @param existing - the file's text, or none when there is no file yet.
20
+ * @param section - the instructions.
21
+ */
22
+ export declare const withAgentsSection: (existing: string | undefined, section: string) => string;
23
+ /**
24
+ * The instructions as a Claude Code skill: its name and when to use it, then the text.
25
+ *
26
+ * @param section - the instructions.
27
+ */
28
+ export declare const agentsSkill: (section: string) => string;
29
+ //# sourceMappingURL=agentsText.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"agentsText.d.ts","sourceRoot":"","sources":["../../../bin/forgebook/agentsText.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,2CAA2C;AAC3C,eAAO,MAAM,YAAY,yFAC+D,CAAC;AAEzF,yBAAyB;AACzB,eAAO,MAAM,UAAU,2BAA2B,CAAC;AAEnD;;;;;GAKG;AACH,eAAO,MAAM,iBAAiB,GAAI,UAAU,MAAM,GAAG,SAAS,EAAE,SAAS,MAAM,KAAG,MAUjF,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,WAAW,GAAI,SAAS,MAAM,KAAG,MAShC,CAAC"}
@@ -0,0 +1,48 @@
1
+ /**
2
+ * The instructions `forgebook agents` gives a project's coding agents: Forgebook's section of the project's
3
+ * `AGENTS.md`, and the same text as a Claude Code skill.
4
+ *
5
+ * @remarks
6
+ * The section sits between two markers, so running the command again replaces its own text and leaves the rest of the
7
+ * file as the project wrote it. `AGENTS.md` is the file Codex reads and Claude Code reads when the project has no
8
+ * `CLAUDE.md` (one that has can import it with `@AGENTS.md`). Pure: texts in, text out.
9
+ *
10
+ * @module
11
+ */
12
+ /** The line before Forgebook's section. */
13
+ export const AGENTS_START = "<!-- forgebook:start: written by `forgebook agents`, replaced when it runs again -->";
14
+ /** The line after it. */
15
+ export const AGENTS_END = "<!-- forgebook:end -->";
16
+ /**
17
+ * A file's text with Forgebook's section in it: put in place of the one already there, else added at the end.
18
+ *
19
+ * @param existing - the file's text, or none when there is no file yet.
20
+ * @param section - the instructions.
21
+ */
22
+ export const withAgentsSection = (existing, section) => {
23
+ const block = `${AGENTS_START}\n${section.trim()}\n${AGENTS_END}\n`;
24
+ if (existing === undefined || existing.trim() === "")
25
+ return block;
26
+ const start = existing.indexOf(AGENTS_START);
27
+ const end = existing.indexOf(AGENTS_END, start);
28
+ if (start !== -1 && end !== -1) {
29
+ const after = existing.slice(end + AGENTS_END.length).replace(/^\n/, "");
30
+ return `${existing.slice(0, start)}${block}${after}`;
31
+ }
32
+ return `${existing.replace(/\n*$/, "")}\n\n${block}`;
33
+ };
34
+ /**
35
+ * The instructions as a Claude Code skill: its name and when to use it, then the text.
36
+ *
37
+ * @param section - the instructions.
38
+ */
39
+ export const agentsSkill = (section) => [
40
+ "---",
41
+ "name: forgebook",
42
+ "description: Write, check and look at this project's component stories with Forgebook (CSF 3). Use when adding or changing a component, or its stories.",
43
+ "---",
44
+ "",
45
+ section.trim(),
46
+ ""
47
+ ].join("\n");
48
+ //# sourceMappingURL=agentsText.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"agentsText.js","sourceRoot":"","sources":["../../../bin/forgebook/agentsText.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,2CAA2C;AAC3C,MAAM,CAAC,MAAM,YAAY,GACvB,sFAAsF,CAAC;AAEzF,yBAAyB;AACzB,MAAM,CAAC,MAAM,UAAU,GAAG,wBAAwB,CAAC;AAEnD;;;;;GAKG;AACH,MAAM,CAAC,MAAM,iBAAiB,GAAG,CAAC,QAA4B,EAAE,OAAe,EAAU,EAAE;IACzF,MAAM,KAAK,GAAG,GAAG,YAAY,KAAK,OAAO,CAAC,IAAI,EAAE,KAAK,UAAU,IAAI,CAAC;IACpE,IAAI,QAAQ,KAAK,SAAS,IAAI,QAAQ,CAAC,IAAI,EAAE,KAAK,EAAE;QAAE,OAAO,KAAK,CAAC;IACnE,MAAM,KAAK,GAAG,QAAQ,CAAC,OAAO,CAAC,YAAY,CAAC,CAAC;IAC7C,MAAM,GAAG,GAAG,QAAQ,CAAC,OAAO,CAAC,UAAU,EAAE,KAAK,CAAC,CAAC;IAChD,IAAI,KAAK,KAAK,CAAC,CAAC,IAAI,GAAG,KAAK,CAAC,CAAC,EAAE,CAAC;QAC/B,MAAM,KAAK,GAAG,QAAQ,CAAC,KAAK,CAAC,GAAG,GAAG,UAAU,CAAC,MAAM,CAAC,CAAC,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC;QACzE,OAAO,GAAG,QAAQ,CAAC,KAAK,CAAC,CAAC,EAAE,KAAK,CAAC,GAAG,KAAK,GAAG,KAAK,EAAE,CAAC;IACvD,CAAC;IACD,OAAO,GAAG,QAAQ,CAAC,OAAO,CAAC,MAAM,EAAE,EAAE,CAAC,OAAO,KAAK,EAAE,CAAC;AACvD,CAAC,CAAC;AAEF;;;;GAIG;AACH,MAAM,CAAC,MAAM,WAAW,GAAG,CAAC,OAAe,EAAU,EAAE,CACrD;IACE,KAAK;IACL,iBAAiB;IACjB,yJAAyJ;IACzJ,KAAK;IACL,EAAE;IACF,OAAO,CAAC,IAAI,EAAE;IACd,EAAE;CACH,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC"}
@@ -0,0 +1,51 @@
1
+ import type { ScriptIo } from "@ensiria/cli-kit/io.types";
2
+ import type { Logger } from "@ensiria/cli-kit/log.types";
3
+ import type { StoriesDocument, StoryDocument } from "../../src/vite/agent.types.ts";
4
+ import { type ResolvedConfig } from "../../src/vite/configFile.ts";
5
+ /** The options every `forgebook` command takes: the configuration file. */
6
+ export type ForgebookOptions = {
7
+ /** The configuration file. */
8
+ readonly config: {
9
+ readonly type: "string";
10
+ readonly valueName: string;
11
+ readonly description: string;
12
+ };
13
+ };
14
+ /** The options every `forgebook` command takes. */
15
+ export declare const FORGEBOOK_OPTIONS: ForgebookOptions;
16
+ /** The command, as the hints print it. */
17
+ export declare const COMMAND = "forgebook";
18
+ /**
19
+ * The catalogue's configuration: the file given, or the one in the folder the command runs in.
20
+ *
21
+ * @param file - the configuration file given; none to look in the current folder.
22
+ * @throws a `ScriptError` when there is none, or it cannot be used.
23
+ */
24
+ export declare const configOf: (file: string | undefined) => Promise<ResolvedConfig>;
25
+ /**
26
+ * Asks the catalogue one of its answers, from its running dev server or one started for the answer.
27
+ *
28
+ * @param config - the catalogue's configuration.
29
+ * @param url - where `forgebook dev` runs, when not at Vite's default address.
30
+ * @param route - the answer (`stories`, `story`).
31
+ * @param params - its query.
32
+ * @param log - where to say where the answer comes from.
33
+ * @throws a `ScriptError` when the catalogue answers with an error.
34
+ */
35
+ export declare const askCatalogue: (config: ResolvedConfig, url: string | undefined, route: string, params: URLSearchParams, log: Logger) => Promise<unknown>;
36
+ /**
37
+ * Prints an answer, its JSON with `--json`, its problems as warnings, and ends with a failure when it has problems,
38
+ * so a CI step fails on a broken story file.
39
+ *
40
+ * @param text - the answer as text for a terminal.
41
+ * @param document - the answer as data.
42
+ * @param problems - what is wrong in it.
43
+ * @param context - the run's io, logger and `--json` mode.
44
+ * @throws a reported `ScriptError` when there are problems.
45
+ */
46
+ export declare const printAnswer: (text: string, document: StoriesDocument | StoryDocument, problems: readonly string[], context: {
47
+ readonly io: ScriptIo;
48
+ readonly log: Logger;
49
+ readonly isJson: boolean;
50
+ }) => void;
51
+ //# sourceMappingURL=catalogueCommands.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"catalogueCommands.d.ts","sourceRoot":"","sources":["../../../bin/forgebook/catalogueCommands.ts"],"names":[],"mappings":"AAUA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,2BAA2B,CAAC;AAC1D,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,4BAA4B,CAAC;AAGzD,OAAO,KAAK,EAAE,eAAe,EAAE,aAAa,EAAE,MAAM,+BAA+B,CAAC;AAEpF,OAAO,EAIL,KAAK,cAAc,EACpB,MAAM,8BAA8B,CAAC;AAGtC,2EAA2E;AAC3E,MAAM,MAAM,gBAAgB,GAAG;IAC7B,8BAA8B;IAC9B,QAAQ,CAAC,MAAM,EAAE;QAAE,QAAQ,CAAC,IAAI,EAAE,QAAQ,CAAC;QAAC,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;QAAC,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAA;KAAE,CAAC;CACxG,CAAC;AAEF,mDAAmD;AACnD,eAAO,MAAM,iBAAiB,EAAE,gBAM/B,CAAC;AAEF,0CAA0C;AAC1C,eAAO,MAAM,OAAO,cAAc,CAAC;AAEnC;;;;;GAKG;AACH,eAAO,MAAM,QAAQ,GAAU,MAAM,MAAM,GAAG,SAAS,KAAG,OAAO,CAAC,cAAc,CAW/E,CAAC;AAEF;;;;;;;;;GASG;AACH,eAAO,MAAM,YAAY,GACvB,QAAQ,cAAc,EACtB,KAAK,MAAM,GAAG,SAAS,EACvB,OAAO,MAAM,EACb,QAAQ,eAAe,EACvB,KAAK,MAAM,KACV,OAAO,CAAC,OAAO,CAsBjB,CAAC;AAEF;;;;;;;;;GASG;AACH,eAAO,MAAM,WAAW,GACtB,MAAM,MAAM,EACZ,UAAU,eAAe,GAAG,aAAa,EACzC,UAAU,SAAS,MAAM,EAAE,EAC3B,SAAS;IAAE,QAAQ,CAAC,EAAE,EAAE,QAAQ,CAAC;IAAC,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,MAAM,EAAE,OAAO,CAAA;CAAE,KACjF,IAKF,CAAC"}
@@ -0,0 +1,90 @@
1
+ /**
2
+ * What the `forgebook` commands share: their common options, the command's name for hints, the catalogue's
3
+ * configuration, an answer asked of the catalogue, and an answer printed.
4
+ *
5
+ * @module
6
+ */
7
+ import { resolve } from "node:path";
8
+ import { EXIT } from "@ensiria/cli-kit/constants";
9
+ import { formatJson } from "@ensiria/cli-kit/files";
10
+ import { ScriptError } from "@ensiria/cli-kit/script";
11
+ import { CONFIG_FILES, findConfigFile, loadConfigFile } from "../../src/vite/configFile.js";
12
+ import { catalogueClient } from "./agentClient.js";
13
+ /** The options every `forgebook` command takes. */
14
+ export const FORGEBOOK_OPTIONS = {
15
+ config: {
16
+ type: "string",
17
+ valueName: "file",
18
+ description: "The configuration file; forgebook.config.ts in the current folder by default."
19
+ }
20
+ };
21
+ /** The command, as the hints print it. */
22
+ export const COMMAND = "forgebook";
23
+ /**
24
+ * The catalogue's configuration: the file given, or the one in the folder the command runs in.
25
+ *
26
+ * @param file - the configuration file given; none to look in the current folder.
27
+ * @throws a `ScriptError` when there is none, or it cannot be used.
28
+ */
29
+ export const configOf = async (file) => {
30
+ const found = file === undefined ? findConfigFile(process.cwd()) : resolve(file);
31
+ if (found === undefined)
32
+ throw new ScriptError(`No ${CONFIG_FILES[0]} here`, {
33
+ hint: `Run ${COMMAND} in the catalogue's folder, or give --config`
34
+ });
35
+ try {
36
+ return await loadConfigFile(found);
37
+ }
38
+ catch (error) {
39
+ throw new ScriptError(error instanceof Error ? error.message : String(error));
40
+ }
41
+ };
42
+ /**
43
+ * Asks the catalogue one of its answers, from its running dev server or one started for the answer.
44
+ *
45
+ * @param config - the catalogue's configuration.
46
+ * @param url - where `forgebook dev` runs, when not at Vite's default address.
47
+ * @param route - the answer (`stories`, `story`).
48
+ * @param params - its query.
49
+ * @param log - where to say where the answer comes from.
50
+ * @throws a `ScriptError` when the catalogue answers with an error.
51
+ */
52
+ export const askCatalogue = async (config, url, route, params, log) => {
53
+ const client = await catalogueClient(config, url);
54
+ log.debug(client.runningAt === undefined
55
+ ? "No catalogue running: answered by a server of its own"
56
+ : `Asked ${client.runningAt}`);
57
+ let answer;
58
+ try {
59
+ answer = await client.ask(route, params);
60
+ }
61
+ finally {
62
+ await client.close();
63
+ }
64
+ if (answer.status !== 200) {
65
+ const { body } = answer;
66
+ const message = typeof body === "object" && body !== null && "error" in body && typeof body.error === "string"
67
+ ? body.error
68
+ : `The catalogue answered ${answer.status}`;
69
+ throw new ScriptError(message);
70
+ }
71
+ return answer.body;
72
+ };
73
+ /**
74
+ * Prints an answer, its JSON with `--json`, its problems as warnings, and ends with a failure when it has problems,
75
+ * so a CI step fails on a broken story file.
76
+ *
77
+ * @param text - the answer as text for a terminal.
78
+ * @param document - the answer as data.
79
+ * @param problems - what is wrong in it.
80
+ * @param context - the run's io, logger and `--json` mode.
81
+ * @throws a reported `ScriptError` when there are problems.
82
+ */
83
+ export const printAnswer = (text, document, problems, context) => {
84
+ context.io.stdout.write(context.isJson ? formatJson(document) : `${text}\n`);
85
+ for (const problem of problems)
86
+ context.log.warn(problem);
87
+ if (problems.length > 0)
88
+ throw new ScriptError(`${problems.length} problems`, { exitCode: EXIT.failure, isReported: true });
89
+ };
90
+ //# sourceMappingURL=catalogueCommands.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"catalogueCommands.js","sourceRoot":"","sources":["../../../bin/forgebook/catalogueCommands.ts"],"names":[],"mappings":"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"}
@@ -0,0 +1,27 @@
1
+ import type { ErrorsDocument } from "../../src/vite/agent.types.ts";
2
+ import type { CatalogueClient } from "./agentClient.ts";
3
+ /**
4
+ * The number to ask for the errors after, from the command line: 0, every error kept, when none or not a number.
5
+ *
6
+ * @param text - `--since`'s value, if given.
7
+ */
8
+ export declare const sinceOf: (text: string | undefined) => number;
9
+ /**
10
+ * The errors after a number, and the index's problems.
11
+ *
12
+ * @param ask - asks the catalogue.
13
+ * @param since - the number of the last error already read; 0 for every one kept.
14
+ * @returns the document, or why the catalogue could not answer.
15
+ */
16
+ export declare const askErrors: (ask: CatalogueClient["ask"], since: number) => Promise<ErrorsDocument | string>;
17
+ /**
18
+ * Follows the errors: each answer with new ones handed on, until the catalogue stops answering or the signal aborts.
19
+ *
20
+ * @param ask - asks the catalogue.
21
+ * @param since - the number of the last error already read.
22
+ * @param onErrors - called with each answer that has new errors.
23
+ * @param signal - stops following; none to follow until the process ends.
24
+ * @returns why it stopped, when the catalogue could not answer.
25
+ */
26
+ export declare const followErrors: (ask: CatalogueClient["ask"], since: number, onErrors: (document: ErrorsDocument) => void, signal?: AbortSignal) => Promise<string | undefined>;
27
+ //# sourceMappingURL=errorsRun.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"errorsRun.d.ts","sourceRoot":"","sources":["../../../bin/forgebook/errorsRun.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,+BAA+B,CAAC;AAEpE,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AAKxD;;;;GAIG;AACH,eAAO,MAAM,OAAO,GAAI,MAAM,MAAM,GAAG,SAAS,KAAG,MAGlD,CAAC;AAEF;;;;;;GAMG;AACH,eAAO,MAAM,SAAS,GACpB,KAAK,eAAe,CAAC,KAAK,CAAC,EAC3B,OAAO,MAAM,KACZ,OAAO,CAAC,cAAc,GAAG,MAAM,CAKjC,CAAC;AAEF;;;;;;;;GAQG;AACH,eAAO,MAAM,YAAY,GACvB,KAAK,eAAe,CAAC,KAAK,CAAC,EAC3B,OAAO,MAAM,EACb,UAAU,CAAC,QAAQ,EAAE,cAAc,KAAK,IAAI,EAC5C,SAAS,WAAW,KACnB,OAAO,CAAC,MAAM,GAAG,SAAS,CAc5B,CAAC"}
@@ -0,0 +1,60 @@
1
+ /**
2
+ * What `forgebook errors` and the MCP tool `recent_errors` run: the errors the open frames reported, asked of the
3
+ * catalogue once, or followed as they come.
4
+ *
5
+ * @module
6
+ */
7
+ import { setTimeout as sleep } from "node:timers/promises";
8
+ import { isErrorsDocument } from "../../src/vite/agentApi.js";
9
+ /** How often a follower asks for new errors, in ms. */
10
+ const FOLLOW_MS = 1000;
11
+ /**
12
+ * The number to ask for the errors after, from the command line: 0, every error kept, when none or not a number.
13
+ *
14
+ * @param text - `--since`'s value, if given.
15
+ */
16
+ export const sinceOf = (text) => {
17
+ const since = Number(text ?? "0");
18
+ return Number.isInteger(since) && since > 0 ? since : 0;
19
+ };
20
+ /**
21
+ * The errors after a number, and the index's problems.
22
+ *
23
+ * @param ask - asks the catalogue.
24
+ * @param since - the number of the last error already read; 0 for every one kept.
25
+ * @returns the document, or why the catalogue could not answer.
26
+ */
27
+ export const askErrors = async (ask, since) => {
28
+ const answer = await ask("errors", new URLSearchParams({ since: String(since) }));
29
+ return answer.status === 200 && isErrorsDocument(answer.body)
30
+ ? answer.body
31
+ : `The catalogue answered ${answer.status} for its errors`;
32
+ };
33
+ /**
34
+ * Follows the errors: each answer with new ones handed on, until the catalogue stops answering or the signal aborts.
35
+ *
36
+ * @param ask - asks the catalogue.
37
+ * @param since - the number of the last error already read.
38
+ * @param onErrors - called with each answer that has new errors.
39
+ * @param signal - stops following; none to follow until the process ends.
40
+ * @returns why it stopped, when the catalogue could not answer.
41
+ */
42
+ export const followErrors = async (ask, since, onErrors, signal) => {
43
+ let last = since;
44
+ while (signal?.aborted !== true) {
45
+ const document = await askErrors(ask, last);
46
+ if (typeof document === "string")
47
+ return document;
48
+ if (document.errors.length > 0)
49
+ onErrors(document);
50
+ last = document.last;
51
+ try {
52
+ await sleep(FOLLOW_MS, undefined, signal === undefined ? {} : { signal });
53
+ }
54
+ catch {
55
+ // aborted while waiting: the loop's own check ends it
56
+ }
57
+ }
58
+ return undefined;
59
+ };
60
+ //# sourceMappingURL=errorsRun.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"errorsRun.js","sourceRoot":"","sources":["../../../bin/forgebook/errorsRun.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,OAAO,EAAE,UAAU,IAAI,KAAK,EAAE,MAAM,sBAAsB,CAAC;AAG3D,OAAO,EAAE,gBAAgB,EAAE,MAAM,4BAA4B,CAAC;AAG9D,uDAAuD;AACvD,MAAM,SAAS,GAAG,IAAI,CAAC;AAEvB;;;;GAIG;AACH,MAAM,CAAC,MAAM,OAAO,GAAG,CAAC,IAAwB,EAAU,EAAE;IAC1D,MAAM,KAAK,GAAG,MAAM,CAAC,IAAI,IAAI,GAAG,CAAC,CAAC;IAClC,OAAO,MAAM,CAAC,SAAS,CAAC,KAAK,CAAC,IAAI,KAAK,GAAG,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC;AAC1D,CAAC,CAAC;AAEF;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,SAAS,GAAG,KAAK,EAC5B,GAA2B,EAC3B,KAAa,EACqB,EAAE;IACpC,MAAM,MAAM,GAAG,MAAM,GAAG,CAAC,QAAQ,EAAE,IAAI,eAAe,CAAC,EAAE,KAAK,EAAE,MAAM,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC,CAAC;IAClF,OAAO,MAAM,CAAC,MAAM,KAAK,GAAG,IAAI,gBAAgB,CAAC,MAAM,CAAC,IAAI,CAAC;QAC3D,CAAC,CAAC,MAAM,CAAC,IAAI;QACb,CAAC,CAAC,0BAA0B,MAAM,CAAC,MAAM,iBAAiB,CAAC;AAC/D,CAAC,CAAC;AAEF;;;;;;;;GAQG;AACH,MAAM,CAAC,MAAM,YAAY,GAAG,KAAK,EAC/B,GAA2B,EAC3B,KAAa,EACb,QAA4C,EAC5C,MAAoB,EACS,EAAE;IAC/B,IAAI,IAAI,GAAG,KAAK,CAAC;IACjB,OAAO,MAAM,EAAE,OAAO,KAAK,IAAI,EAAE,CAAC;QAChC,MAAM,QAAQ,GAAG,MAAM,SAAS,CAAC,GAAG,EAAE,IAAI,CAAC,CAAC;QAC5C,IAAI,OAAO,QAAQ,KAAK,QAAQ;YAAE,OAAO,QAAQ,CAAC;QAClD,IAAI,QAAQ,CAAC,MAAM,CAAC,MAAM,GAAG,CAAC;YAAE,QAAQ,CAAC,QAAQ,CAAC,CAAC;QACnD,IAAI,GAAG,QAAQ,CAAC,IAAI,CAAC;QACrB,IAAI,CAAC;YACH,MAAM,KAAK,CAAC,SAAS,EAAE,SAAS,EAAE,MAAM,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,CAAC;QAC5E,CAAC;QAAC,MAAM,CAAC;YACP,sDAAsD;QACxD,CAAC;IACH,CAAC;IACD,OAAO,SAAS,CAAC;AACnB,CAAC,CAAC"}
@@ -1,106 +1,36 @@
1
1
  #!/usr/bin/env node
2
2
  /**
3
3
  * The `forgebook` command: runs a catalogue from its `forgebook.config.ts` (`dev`, the dev server) or builds it into
4
- * static files (`build`), with no page or Vite configuration of the app's own; and answers tools and agents
5
- * (`stories`, `story`) with what the catalogue shows.
4
+ * static files (`build`), with no page or Vite configuration of the app's own; answers tools and agents with what the
5
+ * catalogue shows (`stories`, `story`, `mcp`); and writes what a project keeps (`docs`, `new`, `agents`).
6
6
  *
7
7
  * @module
8
8
  */
9
- import { resolve } from "node:path";
9
+ import { existsSync, writeFileSync } from "node:fs";
10
+ import { relative, resolve } from "node:path";
10
11
  import { createInterface } from "node:readline";
11
12
  import { defineCommands } from "@ensiria/cli-kit/commands";
12
- import { EXIT } from "@ensiria/cli-kit/constants";
13
- import { formatJson, readPackageVersion } from "@ensiria/cli-kit/files";
13
+ import { readPackageVersion } from "@ensiria/cli-kit/files";
14
14
  import { ScriptError } from "@ensiria/cli-kit/script";
15
15
  import { build, createServer } from "vite";
16
16
  import { filteredStories, isStoriesDocument, isStoryDocument } from "../../src/vite/agentApi.js";
17
- import { CONFIG_FILES, findConfigFile, loadConfigFile } from "../../src/vite/configFile.js";
18
17
  import { answerMcpMessage, NEW_SESSION } from "../../src/vite/mcpProtocol.js";
18
+ import { catalogueDocs } from "../forgebook-docs/catalogueDocs.js";
19
19
  import { catalogueClient } from "./agentClient.js";
20
+ import { agentLoopCommands } from "./agentLoopCommands.mjs";
20
21
  import { storiesText, storyText } from "./agentText.js";
22
+ import { askCatalogue, COMMAND, configOf, FORGEBOOK_OPTIONS, printAnswer } from "./catalogueCommands.js";
21
23
  import { catalogueVite } from "./catalogueVite.js";
24
+ import { initCommands } from "./initCommands.mjs";
22
25
  import { catalogueTools } from "./mcpTools.js";
23
- /** The command, as the hints print it. */
24
- const COMMAND = "forgebook";
25
- /**
26
- * The catalogue's configuration: the file given, or the one in the folder the command runs in.
27
- *
28
- * @param file - the configuration file given; none to look in the current folder.
29
- * @throws a `ScriptError` when there is none, or it cannot be used.
30
- */
31
- const configOf = async (file) => {
32
- const found = file === undefined ? findConfigFile(process.cwd()) : resolve(file);
33
- if (found === undefined)
34
- throw new ScriptError(`No ${CONFIG_FILES[0]} here`, {
35
- hint: `Run ${COMMAND} in the catalogue's folder, or give --config`
36
- });
37
- try {
38
- return await loadConfigFile(found);
39
- }
40
- catch (error) {
41
- throw new ScriptError(error instanceof Error ? error.message : String(error));
42
- }
43
- };
44
- /**
45
- * Asks the catalogue one of its answers, from its running dev server or one started for the answer.
46
- *
47
- * @param config - the catalogue's configuration.
48
- * @param url - where `forgebook dev` runs, when not at Vite's default address.
49
- * @param route - the answer (`stories`, `story`).
50
- * @param params - its query.
51
- * @param log - where to say where the answer comes from.
52
- * @throws a `ScriptError` when the catalogue answers with an error.
53
- */
54
- const askCatalogue = async (config, url, route, params, log) => {
55
- const client = await catalogueClient(config, url);
56
- log.debug(client.runningAt === undefined
57
- ? "No catalogue running: answered by a server of its own"
58
- : `Asked ${client.runningAt}`);
59
- let answer;
60
- try {
61
- answer = await client.ask(route, params);
62
- }
63
- finally {
64
- await client.close();
65
- }
66
- if (answer.status !== 200) {
67
- const { body } = answer;
68
- const message = typeof body === "object" && body !== null && "error" in body && typeof body.error === "string"
69
- ? body.error
70
- : `The catalogue answered ${answer.status}`;
71
- throw new ScriptError(message);
72
- }
73
- return answer.body;
74
- };
75
- /**
76
- * Prints an answer, its JSON with `--json`, its problems as warnings, and ends with a failure when it has problems,
77
- * so a CI step fails on a broken story file.
78
- *
79
- * @param text - the answer as text for a terminal.
80
- * @param document - the answer as data.
81
- * @param problems - what is wrong in it.
82
- * @param context - the run's io, logger and `--json` mode.
83
- * @throws a reported `ScriptError` when there are problems.
84
- */
85
- const printAnswer = (text, document, problems, context) => {
86
- context.io.stdout.write(context.isJson ? formatJson(document) : `${text}\n`);
87
- for (const problem of problems)
88
- context.log.warn(problem);
89
- if (problems.length > 0)
90
- throw new ScriptError(`${problems.length} problems`, { exitCode: EXIT.failure, isReported: true });
91
- };
26
+ import { newStoriesFile } from "./newStoriesFile.js";
27
+ import { runStoryCheck, runStoryShot } from "./storyCheckRun.js";
92
28
  await defineCommands({
93
29
  name: "forgebook",
94
30
  command: COMMAND,
95
31
  summary: "Run a catalogue of stories from its forgebook.config.ts, build it, or answer tools and agents about it.",
96
32
  icon: "docs",
97
- options: {
98
- config: {
99
- type: "string",
100
- valueName: "file",
101
- description: "The configuration file; forgebook.config.ts in the current folder by default."
102
- }
103
- },
33
+ options: FORGEBOOK_OPTIONS,
104
34
  commands: (forgebook) => ({
105
35
  dev: forgebook.command({
106
36
  summary: "Run the catalogue's dev server.",
@@ -172,6 +102,10 @@ await defineCommands({
172
102
  valueName: "query",
173
103
  description: "The view the links open in, as the catalogue's address writes it (theme=dark&lang=it)."
174
104
  },
105
+ "used-in": {
106
+ type: "boolean",
107
+ description: "Add each component's \"Used in\": the components whose stories use it (reads the package's import graph)."
108
+ },
175
109
  url: {
176
110
  type: "string",
177
111
  env: "FORGEBOOK_URL",
@@ -181,11 +115,18 @@ await defineCommands({
181
115
  },
182
116
  examples: [
183
117
  { command: `${COMMAND} stories`, description: "Every story." },
118
+ {
119
+ command: `${COMMAND} stories --component select --used-in --json`,
120
+ description: "The selects, with the components whose stories use them."
121
+ },
184
122
  { command: `${COMMAND} stories --component button --json`, description: "The buttons, as JSON." }
185
123
  ],
186
124
  run: async ({ options, io, log, isJson, style }) => {
187
125
  const config = await configOf(options.config);
188
- const params = new URLSearchParams({ view: options.view ?? "" });
126
+ const params = new URLSearchParams({
127
+ view: options.view ?? "",
128
+ usedIn: String(options["used-in"] === true)
129
+ });
189
130
  const body = await askCatalogue(config, options.url, "stories", params, log);
190
131
  if (!isStoriesDocument(body))
191
132
  throw new ScriptError("The catalogue's answer has an unexpected shape");
@@ -193,6 +134,85 @@ await defineCommands({
193
134
  printAnswer(storiesText(document, style), document, document.problems, { io, log, isJson });
194
135
  }
195
136
  }),
137
+ docs: forgebook.command({
138
+ summary: "Write a package's CATALOG.md and llms.txt, for agents writing code with it; --check fails when stale.",
139
+ json: true,
140
+ options: {
141
+ package: {
142
+ type: "string",
143
+ default: ".",
144
+ valueName: "folder",
145
+ description: "The package's folder; the current folder by default."
146
+ },
147
+ framework: {
148
+ type: "string",
149
+ default: "react",
150
+ valueName: "name",
151
+ description: "The framework the stories are written for: its package, @forgebook/<name>, reads the props."
152
+ },
153
+ check: {
154
+ type: "boolean",
155
+ short: "c",
156
+ description: "Change nothing; fail when a file is stale or a file cannot be read (CI)."
157
+ }
158
+ },
159
+ examples: [
160
+ {
161
+ command: `${COMMAND} docs`,
162
+ description: "Rewrite the CATALOG.md and llms.txt of the package you are in."
163
+ },
164
+ { command: `${COMMAND} docs --check`, description: "Check them in CI." }
165
+ ],
166
+ run: ({ options, log }) => catalogueDocs({
167
+ packageDir: resolve(options.package),
168
+ framework: options.framework,
169
+ isCheck: options.check,
170
+ fixCommand: `${COMMAND} docs`
171
+ }, log)
172
+ }),
173
+ new: forgebook.command({
174
+ summary: "Write a component's first stories from its props: the main story, one per choice, the worst case.",
175
+ options: {
176
+ export: {
177
+ type: "string",
178
+ valueName: "name",
179
+ description: "The component to read; the file's only one by default."
180
+ },
181
+ framework: {
182
+ type: "string",
183
+ default: "react",
184
+ valueName: "name",
185
+ description: "The framework the stories are written for: its package, @forgebook/<name>, reads the props."
186
+ },
187
+ print: { type: "boolean", description: "Print the file instead of writing it." },
188
+ force: { type: "boolean", description: "Replace a stories file that exists." }
189
+ },
190
+ positionals: [{ name: "file", description: "The component's file.", required: true }],
191
+ examples: [
192
+ { command: `${COMMAND} new src/Badge.tsx`, description: "Write src/Badge.stories.tsx." },
193
+ {
194
+ command: `${COMMAND} new src/menu.tsx --export Menu --print`,
195
+ description: "One of several, printed."
196
+ }
197
+ ],
198
+ run: async ({ args, options, io, log }) => {
199
+ const written = await newStoriesFile(resolve(args.file), options.export, options.framework);
200
+ if (options.print) {
201
+ io.stdout.write(written.text);
202
+ return;
203
+ }
204
+ const shown = relative(process.cwd(), written.file);
205
+ if (existsSync(written.file) && options.force !== true)
206
+ throw new ScriptError(`${shown} exists`, {
207
+ hint: "Give --force to replace it, or --print to see it"
208
+ });
209
+ writeFileSync(written.file, written.text);
210
+ log.success(`${shown} written`);
211
+ log.info(`${COMMAND} stories --component ${written.text.match(/title: "([^"]*)"/)?.[1] ?? ""} lists them`);
212
+ }
213
+ }),
214
+ ...agentLoopCommands(forgebook),
215
+ ...initCommands(forgebook),
196
216
  mcp: forgebook.command({
197
217
  summary: "Serve the catalogue's stories to an agent over the Model Context Protocol, on stdin and stdout.",
198
218
  header: false,
@@ -218,7 +238,12 @@ await defineCommands({
218
238
  const server = {
219
239
  info: { name: "forgebook", version: readPackageVersion(import.meta.dirname) },
220
240
  instructions: `The stories of the Forgebook catalogue "${config.title}". list_stories finds a story's id, get_story gives its args and its component's props, story_address gives the links a person opens to see it.`,
221
- tools: catalogueTools(client.ask)
241
+ tools: catalogueTools({
242
+ ask: client.ask,
243
+ writeNew: (file, exportName) => newStoriesFile(resolve(config.dir, file), exportName, config.framework.name),
244
+ check: (input) => runStoryCheck(config, options.url, input),
245
+ shot: (input, outDir) => runStoryShot(config, options.url, input, outDir)
246
+ })
222
247
  };
223
248
  let session = NEW_SESSION;
224
249
  // stdout carries only the protocol's messages, one per line, answered in the order they came