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,76 @@
1
+ /**
2
+ * How a package sets its `CATALOG.md`: the `forgebook.catalog` key of its `package.json`, checked. A library has no
3
+ * catalogue configuration of its own, and the key travels with the package.
4
+ *
5
+ * @module
6
+ */
7
+ /** The kinds of entries the file lists, in the order they are written by default. */
8
+ export const CATALOGUE_SECTIONS = ["components", "modules", "sassModules", "styleSheets"];
9
+ /** The options of a package that sets none. */
10
+ export const DEFAULT_CATALOGUE_OPTIONS = {
11
+ file: "CATALOG.md",
12
+ sections: CATALOGUE_SECTIONS,
13
+ exclude: []
14
+ };
15
+ /** Whether a value is a plain object. */
16
+ const isRecord = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
17
+ /** Whether a value is a list of strings. */
18
+ const isStringList = (value) => Array.isArray(value) && value.every((item) => typeof item === "string");
19
+ /** Whether a text names a kind of entries. */
20
+ const isSection = (value) => CATALOGUE_SECTIONS.some((section) => section === value);
21
+ /** The file's name, or the default with a problem when it is set wrongly. */
22
+ const fileOf = (value, problems) => {
23
+ if (value === undefined)
24
+ return DEFAULT_CATALOGUE_OPTIONS.file;
25
+ if (typeof value === "string" && value !== "" && !value.includes("/"))
26
+ return value;
27
+ problems.push("forgebook.catalog.file must be a file name in the package's folder");
28
+ return DEFAULT_CATALOGUE_OPTIONS.file;
29
+ };
30
+ /** The sections, or the default with a problem when they are set wrongly. */
31
+ const sectionsOf = (value, problems) => {
32
+ if (value === undefined)
33
+ return DEFAULT_CATALOGUE_OPTIONS.sections;
34
+ if (isStringList(value) && value.every(isSection))
35
+ return value.filter(isSection);
36
+ problems.push(`forgebook.catalog.sections must list some of: ${CATALOGUE_SECTIONS.join(", ")}`);
37
+ return DEFAULT_CATALOGUE_OPTIONS.sections;
38
+ };
39
+ /** The exclusions, or none with a problem when they are set wrongly. */
40
+ const excludeOf = (value, problems) => {
41
+ if (value === undefined)
42
+ return [];
43
+ if (isStringList(value))
44
+ return value;
45
+ problems.push("forgebook.catalog.exclude must list export subpaths");
46
+ return [];
47
+ };
48
+ /**
49
+ * A package's catalogue options, from its manifest, with what is wrong in them.
50
+ *
51
+ * @param manifest - the package's `package.json`, parsed.
52
+ * @returns the options (the defaults where it sets none or sets them wrongly) and one message per mistake.
53
+ */
54
+ export const catalogueOptionsOf = (manifest) => {
55
+ const forgebook = isRecord(manifest) ? manifest["forgebook"] : undefined;
56
+ const catalog = isRecord(forgebook) ? forgebook["catalog"] : undefined;
57
+ if (catalog === undefined)
58
+ return { options: DEFAULT_CATALOGUE_OPTIONS, problems: [] };
59
+ if (!isRecord(catalog))
60
+ return { options: DEFAULT_CATALOGUE_OPTIONS, problems: ["forgebook.catalog is not an object"] };
61
+ const problems = [];
62
+ const options = {
63
+ file: fileOf(catalog["file"], problems),
64
+ sections: sectionsOf(catalog["sections"], problems),
65
+ exclude: excludeOf(catalog["exclude"], problems)
66
+ };
67
+ return { options, problems };
68
+ };
69
+ /**
70
+ * Whether an export subpath is left out by the options.
71
+ *
72
+ * @param subpath - the subpath (`./internal/tokens`).
73
+ * @param exclude - the options' `exclude`.
74
+ */
75
+ export const isExcluded = (subpath, exclude) => exclude.some((pattern) => pattern.endsWith("*") ? subpath.startsWith(pattern.slice(0, -1)) : subpath === pattern);
76
+ //# sourceMappingURL=catalogueOptions.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"catalogueOptions.js","sourceRoot":"","sources":["../../../bin/forgebook-docs/catalogueOptions.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,qFAAqF;AACrF,MAAM,CAAC,MAAM,kBAAkB,GAAG,CAAC,YAAY,EAAE,SAAS,EAAE,aAAa,EAAE,aAAa,CAAU,CAAC;AAenG,+CAA+C;AAC/C,MAAM,CAAC,MAAM,yBAAyB,GAAqB;IACzD,IAAI,EAAE,YAAY;IAClB,QAAQ,EAAE,kBAAkB;IAC5B,OAAO,EAAE,EAAE;CACZ,CAAC;AAEF,yCAAyC;AACzC,MAAM,QAAQ,GAAG,CAAC,KAAc,EAA8C,EAAE,CAC9E,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;AAEvE,4CAA4C;AAC5C,MAAM,YAAY,GAAG,CAAC,KAAc,EAA8B,EAAE,CAClE,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,IAAI,KAAK,CAAC,KAAK,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,OAAO,IAAI,KAAK,QAAQ,CAAC,CAAC;AAE1E,8CAA8C;AAC9C,MAAM,SAAS,GAAG,CAAC,KAAa,EAA6B,EAAE,CAC7D,kBAAkB,CAA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,5 +1,6 @@
1
1
  import type { ExtractStoryComponent } from "../../src/vite/adapter.ts";
2
2
  import type { CatalogueData } from "./catalogueDocs.types.ts";
3
+ import { type CatalogueOptions } from "./catalogueOptions.ts";
3
4
  /** What was read, and what could not be. */
4
5
  export type CollectedDocs = {
5
6
  /** The catalogue's data. */
@@ -12,6 +13,7 @@ export type CollectedDocs = {
12
13
  *
13
14
  * @param packageDir - the package's folder.
14
15
  * @param extractStoryComponent - the framework's reading of a story file's component (its docs module).
16
+ * @param options - the package's catalogue options: the subpaths it leaves out.
15
17
  */
16
- export declare const collectDocs: (packageDir: string, extractStoryComponent: ExtractStoryComponent) => CollectedDocs;
18
+ export declare const collectDocs: (packageDir: string, extractStoryComponent: ExtractStoryComponent, options: Pick<CatalogueOptions, "exclude">) => CollectedDocs;
17
19
  //# sourceMappingURL=collectDocs.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"collectDocs.d.ts","sourceRoot":"","sources":["../../../bin/forgebook-docs/collectDocs.ts"],"names":[],"mappings":"AAgBA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,2BAA2B,CAAC;AAGvE,OAAO,KAAK,EAEV,aAAa,EAId,MAAM,0BAA0B,CAAC;AAIlC,4CAA4C;AAC5C,MAAM,MAAM,aAAa,GAAG;IAC1B,4BAA4B;IAC5B,QAAQ,CAAC,IAAI,EAAE,aAAa,CAAC;IAC7B,mDAAmD;IACnD,QAAQ,CAAC,QAAQ,EAAE,SAAS,MAAM,EAAE,CAAC;CACtC,CAAC;AA+EF;;;;;GAKG;AACH,eAAO,MAAM,WAAW,GACtB,YAAY,MAAM,EAClB,uBAAuB,qBAAqB,KAC3C,aA8BF,CAAC"}
1
+ {"version":3,"file":"collectDocs.d.ts","sourceRoot":"","sources":["../../../bin/forgebook-docs/collectDocs.ts"],"names":[],"mappings":"AAgBA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,2BAA2B,CAAC;AAGvE,OAAO,KAAK,EAEV,aAAa,EAId,MAAM,0BAA0B,CAAC;AAClC,OAAO,EAAE,KAAK,gBAAgB,EAAc,MAAM,uBAAuB,CAAC;AAK1E,4CAA4C;AAC5C,MAAM,MAAM,aAAa,GAAG;IAC1B,4BAA4B;IAC5B,QAAQ,CAAC,IAAI,EAAE,aAAa,CAAC;IAC7B,mDAAmD;IACnD,QAAQ,CAAC,QAAQ,EAAE,SAAS,MAAM,EAAE,CAAC;CACtC,CAAC;AAoGF;;;;;;GAMG;AACH,eAAO,MAAM,WAAW,GACtB,YAAY,MAAM,EAClB,uBAAuB,qBAAqB,EAC5C,SAAS,IAAI,CAAC,gBAAgB,EAAE,SAAS,CAAC,KACzC,aA+BF,CAAC"}
@@ -13,8 +13,10 @@ import { globSync, readFileSync } from "node:fs";
13
13
  import { join, resolve } from "node:path";
14
14
  import { autoTitle, STORY_FILE } from "../../src/vite/autoTitle.js";
15
15
  import { indexStoryFile } from "../../src/vite/indexStoryFile.js";
16
+ import { isExcluded } from "./catalogueOptions.js";
16
17
  import { moduleDocs } from "./moduleDocs.js";
17
18
  import { sassMembers, styleSheetSummary } from "./sassDocs.js";
19
+ import { sourceIdOf } from "./sourceId.js";
18
20
  /** The subpath that is never published: the package's stories for a catalogue. */
19
21
  const STORIES_SUBPATH = "./stories";
20
22
  /** A package's `exports`, as written: subpath → source. */
@@ -27,7 +29,7 @@ const sourceExports = (manifest) => {
27
29
  return Object.fromEntries(Object.entries(exports).filter((entry) => typeof entry[1] === "string"));
28
30
  };
29
31
  /** The components of the package's story files, read by the framework's extractor. */
30
- const collectComponents = (packageDir, exports, problems, extractStoryComponent) => {
32
+ const collectComponents = (packageDir, exports, problems, extractStoryComponent, exclude) => {
31
33
  const components = [];
32
34
  const componentFiles = new Set();
33
35
  const storyFiles = globSync("**/*.stories.*", { cwd: packageDir })
@@ -49,14 +51,15 @@ const collectComponents = (packageDir, exports, problems, extractStoryComponent)
49
51
  continue;
50
52
  const subpath = Object.entries(exports).find(([, source]) => resolve(packageDir, source) === component.file)?.[0];
51
53
  // a component no subpath exports is a story's own (a foundations page), not part of the package
52
- if (subpath === undefined)
54
+ if (subpath === undefined || isExcluded(subpath, exclude))
53
55
  continue;
54
56
  componentFiles.add(component.file);
55
57
  components.push({
56
58
  title: index.title,
57
59
  subpath,
58
60
  docs: component.docs,
59
- stories: index.stories.map((story) => story.name ?? story.exportName)
61
+ stories: index.stories.map((story) => story.name ?? story.exportName),
62
+ mainStory: (index.stories.find((story) => story.isMain === true) ?? index.stories[0])?.exportName
60
63
  });
61
64
  }
62
65
  return { components, componentFiles };
@@ -76,29 +79,45 @@ const readExport = (subpath, source, file) => {
76
79
  ? { kind: "problem", message: docs }
77
80
  : { kind: "module", docs: { subpath, exports: docs } };
78
81
  };
82
+ /** A text field of the package's manifest (`name`, `description`), or none. */
83
+ const manifestText = (manifest, key) => {
84
+ if (typeof manifest !== "object" || manifest === null || !(key in manifest))
85
+ return undefined;
86
+ const value = Reflect.get(manifest, key);
87
+ return typeof value === "string" ? value : undefined;
88
+ };
89
+ /** The id the package's stories carry, from its `./stories` export's module, when it writes it plainly. */
90
+ const sourceIdIn = (packageDir, exports) => {
91
+ const source = exports[STORIES_SUBPATH];
92
+ if (source === undefined)
93
+ return undefined;
94
+ const file = resolve(packageDir, source);
95
+ try {
96
+ return sourceIdOf(file, readFileSync(file, "utf8"));
97
+ }
98
+ catch {
99
+ return undefined;
100
+ }
101
+ };
79
102
  /**
80
103
  * Reads a package for its catalogue.
81
104
  *
82
105
  * @param packageDir - the package's folder.
83
106
  * @param extractStoryComponent - the framework's reading of a story file's component (its docs module).
107
+ * @param options - the package's catalogue options: the subpaths it leaves out.
84
108
  */
85
- export const collectDocs = (packageDir, extractStoryComponent) => {
109
+ export const collectDocs = (packageDir, extractStoryComponent, options) => {
86
110
  const manifest = JSON.parse(readFileSync(join(packageDir, "package.json"), "utf8"));
87
- const packageName = typeof manifest === "object" &&
88
- manifest !== null &&
89
- "name" in manifest &&
90
- typeof manifest.name === "string"
91
- ? manifest.name
92
- : packageDir;
111
+ const packageName = manifestText(manifest, "name") ?? packageDir;
93
112
  const exports = sourceExports(manifest);
94
113
  const problems = [];
95
- const { components, componentFiles } = collectComponents(packageDir, exports, problems, extractStoryComponent);
114
+ const { components, componentFiles } = collectComponents(packageDir, exports, problems, extractStoryComponent, options.exclude);
96
115
  const modules = [];
97
116
  const sassModules = [];
98
117
  const styleSheets = [];
99
118
  for (const [subpath, source] of Object.entries(exports)) {
100
119
  const file = resolve(packageDir, source);
101
- if (subpath === STORIES_SUBPATH || componentFiles.has(file))
120
+ if (subpath === STORIES_SUBPATH || componentFiles.has(file) || isExcluded(subpath, options.exclude))
102
121
  continue;
103
122
  const entry = readExport(subpath, source, file);
104
123
  if (entry.kind === "sass")
@@ -110,6 +129,11 @@ export const collectDocs = (packageDir, extractStoryComponent) => {
110
129
  if (entry.kind === "problem")
111
130
  problems.push(entry.message);
112
131
  }
113
- return { data: { packageName, components, modules, sassModules, styleSheets }, problems };
132
+ const description = manifestText(manifest, "description");
133
+ const sourceId = sourceIdIn(packageDir, exports);
134
+ return {
135
+ data: { packageName, description, sourceId, components, modules, sassModules, styleSheets },
136
+ problems
137
+ };
114
138
  };
115
139
  //# sourceMappingURL=collectDocs.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"collectDocs.js","sourceRoot":"","sources":["../../../bin/forgebook-docs/collectDocs.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AACH,OAAO,EAAE,QAAQ,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACjD,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAK1C,OAAO,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,6BAA6B,CAAC;AACpE,OAAO,EAAE,cAAc,EAAE,MAAM,kCAAkC,CAAC;AAQlE,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAC7C,OAAO,EAAE,WAAW,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAC;AAU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
  #!/usr/bin/env node
2
- var __rewriteRelativeImportExtension = (this && this.__rewriteRelativeImportExtension) || function (path, preserveJsx) {
3
- if (typeof path === "string" && /^\.\.?\//.test(path)) {
4
- return path.replace(/\.(tsx)$|((?:\.d)?)((?:\.[^./]+?)?)\.([cm]?)ts$/i, function (m, tsx, d, ext, cm) {
5
- return tsx ? preserveJsx ? ".jsx" : ".js" : d && (!ext || !cm) ? m : (d + ext + "." + cm.toLowerCase() + "js");
6
- });
7
- }
8
- return path;
9
- };
10
2
  /**
11
- * The `forgebook-docs` command: writes a package's `CATALOG.md` from its exports, their TSDoc and its stories, or
12
- * checks that it is up to date.
13
- *
14
- * @remarks
15
- * Usage: `forgebook-docs --help` (generated by `@ensiria/cli-kit`). A package with stories declares
16
- * `forgebook` as a development dependency and runs it on itself (`"catalog": "forgebook-docs --package ."`).
3
+ * The `forgebook-docs` command, the former name of `forgebook docs`: writes a package's `CATALOG.md` and `llms.txt`, or
4
+ * checks them, and says where the command moved. Kept for one release so a package's `catalog` script keeps working
5
+ * after an update.
17
6
  *
18
7
  * @module
19
8
  */
20
- import { createRequire } from "node:module";
21
- import { join, relative, resolve } from "node:path";
22
- import { pathToFileURL } from "node:url";
23
- import { readFileSafe, writeIfChanged } from "@ensiria/cli-kit/files";
24
- import { plural } from "@ensiria/cli-kit/format";
25
- import { defineScript, ScriptError } from "@ensiria/cli-kit/script";
26
- import { isDocsModule } from "../../src/vite/adapter.js";
27
- import { catalogueMarkdown } from "./catalogueMarkdown.js";
28
- import { collectDocs } from "./collectDocs.js";
9
+ import { resolve } from "node:path";
10
+ import { defineScript } from "@ensiria/cli-kit/script";
11
+ import { catalogueDocs } from "./catalogueDocs.js";
29
12
  /** The command, as the hints print it. */
30
13
  const COMMAND = "forgebook-docs";
31
- /**
32
- * The framework's reading of a story file's component: the docs module of `@forgebook/<framework>`, resolved from the
33
- * package, which declares that framework package.
34
- *
35
- * @param packageDir - the package's folder.
36
- * @param framework - the framework's name (`react`).
37
- * @throws a `ScriptError` when the package cannot resolve it or the module is not a docs module.
38
- */
39
- const extractorOf = async (packageDir, framework) => {
40
- const specifier = `@forgebook/${framework}/docs`;
41
- let file;
42
- try {
43
- file = createRequire(join(packageDir, "package.json")).resolve(specifier);
44
- }
45
- catch {
46
- throw new ScriptError(`${specifier} is not installed in this package`, {
47
- hint: `Add @forgebook/${framework} to its devDependencies`
48
- });
49
- }
50
- const module = await import(__rewriteRelativeImportExtension(pathToFileURL(file).href));
51
- if (!isDocsModule(module))
52
- throw new ScriptError(`${specifier} exports no extractStoryComponent`);
53
- return module.extractStoryComponent;
54
- };
55
14
  await defineScript({
56
15
  name: "forgebook-docs",
57
16
  command: COMMAND,
58
- summary: "Write a package's CATALOG.md from its exports, their TSDoc and its stories.",
17
+ summary: "Write a package's CATALOG.md and llms.txt (moved to forgebook docs).",
59
18
  icon: "docs",
60
19
  json: true,
61
- description: "Reads the package's exports (components from its stories, modules with TypeScript 6, Sass modules and style sheets from their text) and writes CATALOG.md in its folder: one dense line per entry, for agents to read before writing a component, hook or helper.",
20
+ description: "The former name of forgebook docs, kept for one release: reads the package's exports, their TSDoc and its stories, and writes CATALOG.md and llms.txt in its folder.",
62
21
  options: {
63
22
  package: {
64
23
  type: "string",
@@ -75,40 +34,18 @@ await defineScript({
75
34
  check: {
76
35
  type: "boolean",
77
36
  short: "c",
78
- description: "Change nothing; fail when CATALOG.md is stale or a file cannot be read (CI)."
37
+ description: "Change nothing; fail when a file is stale or a file cannot be read (CI)."
79
38
  }
80
39
  },
81
- examples: [
82
- { command: `${COMMAND} --package .`, description: "Rewrite the CATALOG.md of the package you are in." },
83
- { command: `${COMMAND} --package . --check`, description: "Check it in CI." }
84
- ],
40
+ examples: [{ command: `${COMMAND} --package .`, description: "Now: forgebook docs." }],
85
41
  run: async ({ options, log }) => {
86
- const packageDir = resolve(options.package);
87
- const file = join(packageDir, "CATALOG.md");
88
- const shownFile = relative(process.cwd(), file);
89
- const { data, problems } = collectDocs(packageDir, await extractorOf(packageDir, options.framework));
90
- for (const problem of problems)
91
- log.error(problem);
92
- const text = catalogueMarkdown(data);
93
- const counts = {
94
- components: data.components.length,
95
- modules: data.modules.length,
96
- sassModules: data.sassModules.length,
97
- styleSheets: data.styleSheets.length
98
- };
99
- if (options.check) {
100
- if (problems.length > 0)
101
- throw new ScriptError(`${plural(problems.length, "file")} could not be read`);
102
- if (readFileSafe(file) !== text)
103
- throw new ScriptError(`${shownFile} is stale`, {
104
- hint: `Run ${COMMAND} --package ${relative(process.cwd(), packageDir)}`
105
- });
106
- log.success(`${shownFile} is up to date`);
107
- return { status: "valid", file: shownFile, counts, problems };
108
- }
109
- const isWritten = writeIfChanged(file, text);
110
- log.success(`${shownFile} ${isWritten ? "written" : "already up to date"}`);
111
- return { status: isWritten ? "written" : "up-to-date", file: shownFile, counts, problems };
42
+ log.warn("forgebook-docs is now forgebook docs: change the package's script, this name goes in the next release");
43
+ return catalogueDocs({
44
+ packageDir: resolve(options.package),
45
+ framework: options.framework,
46
+ isCheck: options.check,
47
+ fixCommand: "forgebook docs"
48
+ }, log);
112
49
  }
113
50
  }).run();
114
51
  //# sourceMappingURL=forgebook-docs.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"forgebook-docs.mjs","sourceRoot":"","sources":["../../../bin/forgebook-docs/forgebook-docs.mts"],"names":[],"mappings":";;;;;;;;;AACA;;;;;;;;;GASG;AACH,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC5C,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpD,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAEzC,OAAO,EAAE,YAAY,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AACtE,OAAO,EAAE,MAAM,EAAE,MAAM,yBAAyB,CAAC;AACjD,OAAO,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;AAEpE,OAAO,EAA8B,YAAY,EAAE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AAY,CAAC;IACjB,IAAI,EAAE,gBAAgB;IACtB,OAAO,EAAE,OAAO;IAChB,OAAO,EAAE,sEAAsE;IAC/E,IAAI,EAAE,MAAM;IACZ,IAAI,EAAE,IAAI;IACV,WAAW,EACT,sKAAsK;IACxK,OAAO,EAAE;QACP,OAAO,EAAE;YACP,IAAI,EAAE,QAAQ;YACd,QAAQ,EAAE,IAAI;YACd,SAAS,EAAE,QAAQ;YACnB,WAAW,EAAE,gDAAgD;SAC9D;QACD,SAAS,EAAE;YACT,IAAI,EAAE,QAAQ;YACd,OAAO,EAAE,OAAO;YAChB,SAAS,EAAE,MAAM;YACjB,WAAW,EACT,yGAAyG;SAC5G;QACD,KAAK,EAAE;YACL,IAAI,EAAE,SAAS;YACf,KAAK,EAAE,GAAG;YACV,WAAW,EAAE,0EAA0E;SACxF;KACF;IACD,QAAQ,EAAE,CAAC,EAAE,OAAO,EAAE,GAAG,OAAO,cAAc,EAAE,WAAW,EAAE,sBAAsB,EAAE,CAAC;IACtF,GAAG,EAAE,KAAK,EAAE,EAAE,OAAO,EAAE,GAAG,EAAE,EAAgC,EAAE;QAC5D,GAAG,CAAC,IAAI,CACN,uGAAuG,CACxG,CAAC;QACF,OAAO,aAAa,CAClB;YACE,UAAU,EAAE,OAAO,CAAC,OAAO,CAAC,OAAO,CAAC;YACpC,SAAS,EAAE,OAAO,CAAC,SAAS;YAC5B,OAAO,EAAE,OAAO,CAAC,KAAK;YACtB,UAAU,EAAE,gBAAgB;SAC7B,EACD,GAAG,CACJ,CAAC;IACJ,CAAC;CACF,CAAC,CAAC,GAAG,EAAE,CAAC"}
@@ -0,0 +1,24 @@
1
+ /**
2
+ * A package's `llms.txt`, beside its `CATALOG.md`, in the llms.txt format (a title, a one-paragraph summary, sections of
3
+ * links): what an agent that lands on the package reads first, pointing it to the catalogue and to the commands that
4
+ * show a real use of each component. Pure: values in, text out.
5
+ *
6
+ * @module
7
+ */
8
+ /** What the file says. */
9
+ export type LlmsTextInput = {
10
+ /** The package's name. */
11
+ readonly packageName: string;
12
+ /** The package's description; none leaves the summary to the catalogue. */
13
+ readonly description: string | undefined;
14
+ /** The catalogue's file name (`CATALOG.md`). */
15
+ readonly catalogueFile: string;
16
+ };
17
+ /**
18
+ * The text of `llms.txt`.
19
+ *
20
+ * @param input - the package's name and description, and the catalogue's file name.
21
+ * @returns the text, ending with a newline.
22
+ */
23
+ export declare const llmsText: (input: LlmsTextInput) => string;
24
+ //# sourceMappingURL=llmsText.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"llmsText.d.ts","sourceRoot":"","sources":["../../../bin/forgebook-docs/llmsText.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,0BAA0B;AAC1B,MAAM,MAAM,aAAa,GAAG;IAC1B,0BAA0B;IAC1B,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAC7B,2EAA2E;IAC3E,QAAQ,CAAC,WAAW,EAAE,MAAM,GAAG,SAAS,CAAC;IACzC,gDAAgD;IAChD,QAAQ,CAAC,aAAa,EAAE,MAAM,CAAC;CAChC,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,QAAQ,GAAI,OAAO,aAAa,KAAG,MAmBlC,CAAC"}
@@ -0,0 +1,33 @@
1
+ /**
2
+ * A package's `llms.txt`, beside its `CATALOG.md`, in the llms.txt format (a title, a one-paragraph summary, sections of
3
+ * links): what an agent that lands on the package reads first, pointing it to the catalogue and to the commands that
4
+ * show a real use of each component. Pure: values in, text out.
5
+ *
6
+ * @module
7
+ */
8
+ /**
9
+ * The text of `llms.txt`.
10
+ *
11
+ * @param input - the package's name and description, and the catalogue's file name.
12
+ * @returns the text, ending with a newline.
13
+ */
14
+ export const llmsText = (input) => [
15
+ `# ${input.packageName}`,
16
+ "",
17
+ `> ${input.description ?? `The components, hooks, helpers and style modules of ${input.packageName}.`}`,
18
+ "",
19
+ "<!-- GENERATED by forgebook docs: do not edit. -->",
20
+ "",
21
+ "## Docs",
22
+ "",
23
+ `- [${input.catalogueFile}](${input.catalogueFile}): every component, hook, helper and style module, one line each: what it is, how to import it, its props, and the id of a story that shows it`,
24
+ "",
25
+ "## Optional",
26
+ "",
27
+ "Where the package's own catalogue runs (its repository, with Forgebook):",
28
+ "",
29
+ "- `npx forgebook story <id> --json`: a story's args and its component's props",
30
+ "- `npx forgebook mcp`: the same for an agent, over the Model Context Protocol (`list_stories`, `get_story`)",
31
+ ""
32
+ ].join("\n");
33
+ //# sourceMappingURL=llmsText.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"llmsText.js","sourceRoot":"","sources":["../../../bin/forgebook-docs/llmsText.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAYH;;;;;GAKG;AACH,MAAM,CAAC,MAAM,QAAQ,GAAG,CAAC,KAAoB,EAAU,EAAE,CACvD;IACE,KAAK,KAAK,CAAC,WAAW,EAAE;IACxB,EAAE;IACF,KAAK,KAAK,CAAC,WAAW,IAAI,uDAAuD,KAAK,CAAC,WAAW,GAAG,EAAE;IACvG,EAAE;IACF,oDAAoD;IACpD,EAAE;IACF,SAAS;IACT,EAAE;IACF,MAAM,KAAK,CAAC,aAAa,KAAK,KAAK,CAAC,aAAa,gJAAgJ;IACjM,EAAE;IACF,aAAa;IACb,EAAE;IACF,0EAA0E;IAC1E,EAAE;IACF,+EAA+E;IAC/E,6GAA6G;IAC7G,EAAE;CACH,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC"}
@@ -0,0 +1,9 @@
1
+ /**
2
+ * The source's id, from the declaring module's text.
3
+ *
4
+ * @param file - the module's path, for the parser (its extension says TypeScript or JSX).
5
+ * @param text - the module's text.
6
+ * @returns the id, or none when the module does not write it plainly.
7
+ */
8
+ export declare const sourceIdOf: (file: string, text: string) => string | undefined;
9
+ //# sourceMappingURL=sourceId.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sourceId.d.ts","sourceRoot":"","sources":["../../../bin/forgebook-docs/sourceId.ts"],"names":[],"mappings":"AA6BA;;;;;;GAMG;AACH,eAAO,MAAM,UAAU,GAAI,MAAM,MAAM,EAAE,MAAM,MAAM,KAAG,MAAM,GAAG,SAShE,CAAC"}
@@ -0,0 +1,45 @@
1
+ /**
2
+ * The id a package's stories carry in a catalogue, read from the module that declares its source (its `./stories`
3
+ * export) without running it: the `id` of the exported `source`, when written plainly.
4
+ *
5
+ * @remarks
6
+ * A story's id starts with its source's id (`kit:inputs-select--overview`), so `CATALOG.md` can name a component's
7
+ * main story only when it knows it. A source built by code gives none, and the lines then name no story.
8
+ *
9
+ * @module
10
+ */
11
+ import { parseSync } from "vite";
12
+ import { propertyValue, unwrapped } from "../../src/vite/indexStoryFile.js";
13
+ /** The object a top-level `export const source = …` holds, if it is written as one. */
14
+ const sourceObject = (statement) => {
15
+ if (statement.type !== "ExportNamedDeclaration" || statement.declaration?.type !== "VariableDeclaration")
16
+ return undefined;
17
+ for (const declarator of statement.declaration.declarations) {
18
+ if (declarator.id.type !== "Identifier" || declarator.id.name !== "source" || declarator.init === null)
19
+ continue;
20
+ const init = unwrapped(declarator.init);
21
+ if (init.type === "ObjectExpression")
22
+ return init;
23
+ }
24
+ return undefined;
25
+ };
26
+ /**
27
+ * The source's id, from the declaring module's text.
28
+ *
29
+ * @param file - the module's path, for the parser (its extension says TypeScript or JSX).
30
+ * @param text - the module's text.
31
+ * @returns the id, or none when the module does not write it plainly.
32
+ */
33
+ export const sourceIdOf = (file, text) => {
34
+ const { program, errors } = parseSync(file, text);
35
+ if (errors.length > 0)
36
+ return undefined;
37
+ for (const statement of program.body) {
38
+ const object = sourceObject(statement);
39
+ const id = object === undefined ? undefined : propertyValue(object, "id");
40
+ if (id?.type === "Literal" && typeof id.value === "string")
41
+ return id.value;
42
+ }
43
+ return undefined;
44
+ };
45
+ //# sourceMappingURL=sourceId.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sourceId.js","sourceRoot":"","sources":["../../../bin/forgebook-docs/sourceId.ts"],"names":[],"mappings":"AAAA;;;;;;;;;G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AK,SAAS,IAAI,OAAO,EAAE,CAAC,KAAK,KAAK,QAAQ;YAAE,OAAO,EAAE,CAAC,KAAK,CAAC;IAC9E,CAAC;IACD,OAAO,SAAS,CAAC;AACnB,CAAC,CAAC"}
@@ -0,0 +1,10 @@
1
+ import { type DocsModule } from "../src/vite/adapter.ts";
2
+ /**
3
+ * The framework's docs module, from the package that declares the framework package.
4
+ *
5
+ * @param packageDir - the package's folder.
6
+ * @param framework - the framework's name (`react`).
7
+ * @throws a `ScriptError` when the package cannot resolve it or the module is not a docs module.
8
+ */
9
+ export declare const frameworkDocsModule: (packageDir: string, framework: string) => Promise<DocsModule>;
10
+ //# sourceMappingURL=frameworkDocs.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"frameworkDocs.d.ts","sourceRoot":"","sources":["../../bin/frameworkDocs.ts"],"names":[],"mappings":"AAYA,OAAO,EAAE,KAAK,UAAU,EAAgB,MAAM,wBAAwB,CAAC;AAEvE;;;;;;GAMG;AACH,eAAO,MAAM,mBAAmB,GAAU,YAAY,MAAM,EAAE,WAAW,MAAM,KAAG,OAAO,CAAC,UAAU,CAanG,CAAC"}
@@ -0,0 +1,43 @@
1
+ var __rewriteRelativeImportExtension = (this && this.__rewriteRelativeImportExtension) || function (path, preserveJsx) {
2
+ if (typeof path === "string" && /^\.\.?\//.test(path)) {
3
+ return path.replace(/\.(tsx)$|((?:\.d)?)((?:\.[^./]+?)?)\.([cm]?)ts$/i, function (m, tsx, d, ext, cm) {
4
+ return tsx ? preserveJsx ? ".jsx" : ".js" : d && (!ext || !cm) ? m : (d + ext + "." + cm.toLowerCase() + "js");
5
+ });
6
+ }
7
+ return path;
8
+ };
9
+ /**
10
+ * The framework's docs module (`@forgebook/<framework>/docs`), resolved from a package as that package resolves it:
11
+ * what `forgebook docs` and `forgebook new` read components with, in a library that has no catalogue configuration.
12
+ *
13
+ * @module
14
+ */
15
+ import { createRequire } from "node:module";
16
+ import { join } from "node:path";
17
+ import { pathToFileURL } from "node:url";
18
+ import { ScriptError } from "@ensiria/cli-kit/script";
19
+ import { isDocsModule } from "../src/vite/adapter.js";
20
+ /**
21
+ * The framework's docs module, from the package that declares the framework package.
22
+ *
23
+ * @param packageDir - the package's folder.
24
+ * @param framework - the framework's name (`react`).
25
+ * @throws a `ScriptError` when the package cannot resolve it or the module is not a docs module.
26
+ */
27
+ export const frameworkDocsModule = async (packageDir, framework) => {
28
+ const specifier = `@forgebook/${framework}/docs`;
29
+ let file;
30
+ try {
31
+ file = createRequire(join(packageDir, "package.json")).resolve(specifier);
32
+ }
33
+ catch {
34
+ throw new ScriptError(`${specifier} is not installed in this package`, {
35
+ hint: `Add @forgebook/${framework} to its devDependencies`
36
+ });
37
+ }
38
+ const module = await import(__rewriteRelativeImportExtension(pathToFileURL(file).href));
39
+ if (!isDocsModule(module))
40
+ throw new ScriptError(`${specifier} exports no extractStoryComponent`);
41
+ return module;
42
+ };
43
+ //# sourceMappingURL=frameworkDocs.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"frameworkDocs.js","sourceRoot":"","sources":["../../bin/frameworkDocs.ts"],"names":[],"mappings":";;;;;;;;AAAA;;;;;GAKG;AACH,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC5C,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAEzC,OAAO,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;AAEtD,OAAO,EAAmB,YAAY,EAAE,MAAM,wBAAwB,CAAC;AAEvE;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,mBAAmB,GAAG,KAAK,EAAE,UAAkB,EAAE,SAAiB,EAAuB,EAAE;IACtG,MAAM,SAAS,GAAG,cAAc,SAAS,OAAO,CAAC;IACjD,IAAI,IAAY,CAAC;IACjB,IAAI,CAAC;QACH,IAAI,GAAG,aAAa,CAAC,IAAI,CAAC,UAAU,EAAE,cAAc,CAAC,CAAC,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC;IAC5E,CAAC;IAAC,MAAM,CAAC;QACP,MAAM,IAAI,WAAW,CAAC,GAAG,SAAS,mCAAmC,EAAE;YACrE,IAAI,EAAE,kBAAkB,SAAS,yBAAyB;SAC3D,CAAC,CAAC;IACL,CAAC;IACD,MAAM,MAAM,GAAY,MAAM,MAAM,kCAAC,aAAa,CAAC,IAAI,CAAC,CAAC,IAAI,EAAC,CAAC;IAC/D,IAAI,CAAC,YAAY,CAAC,MAAM,CAAC;QAAE,MAAM,IAAI,WAAW,CAAC,GAAG,SAAS,mCAAmC,CAAC,CAAC;IAClG,OAAO,MAAM,CAAC;AAChB,CAAC,CAAC"}
@@ -14,6 +14,7 @@
14
14
  */
15
15
  import type { StoryControlsSetting } from "@forgebook/story-format/source";
16
16
  import type { PropDocs } from "./componentDocs.ts";
17
+ import type { NamedValues } from "./namedValues.ts";
17
18
  /** A control as the panel draws it; `none` for an arg the panel lists without a control. */
18
19
  export type PanelControl = "select" | "radio" | "check" | "multi-select" | "boolean" | "text" | "number" | "range" | "color" | "date" | "none";
19
20
  /** How the panel shows one arg, from its `argTypes` entry: what crosses from the frame to the shell. */
@@ -54,6 +55,28 @@ export type PanelProp = PropDocs & {
54
55
  /** A range's or a number's step. */
55
56
  readonly step?: number;
56
57
  };
58
+ /**
59
+ * Whether a prop is a colour: named so by its `argTypes`, or by the name convention (`color`, `accentColor`).
60
+ *
61
+ * @param prop - the prop.
62
+ */
63
+ export declare const isColorProp: (prop: PanelProp) => boolean;
64
+ /**
65
+ * Whether a prop is chosen among the values the source names for its type (`IconComponent`).
66
+ *
67
+ * @param prop - the prop.
68
+ * @param namedValues - the source's named values.
69
+ */
70
+ export declare const isNamedProp: (prop: PanelProp, namedValues: NamedValues) => boolean;
71
+ /**
72
+ * The props the panel can set: a prop of a type the source names values for is chosen among them, a node that takes a
73
+ * text is set as one; any other `other` prop, and an event, cannot be set; nor a prop the story's controls leave out.
74
+ *
75
+ * @param props - the component's props, with the story's `argTypes` laid over them.
76
+ * @param controls - the props the story lets the panel set.
77
+ * @param namedValues - the source's named values.
78
+ */
79
+ export declare const settableProps: (props: readonly PanelProp[], controls: StoryControlsSetting, namedValues: NamedValues) => PanelProp[];
57
80
  /**
58
81
  * The `argTypes` of the meta and the story, merged: each arg's entry from both, the story's fields over the meta's.
59
82
  *