forgebook 0.1.2 → 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 (345) hide show
  1. package/README.md +94 -5
  2. package/dist/bin/forgebook/agentClient.d.ts +39 -0
  3. package/dist/bin/forgebook/agentClient.d.ts.map +1 -0
  4. package/dist/bin/forgebook/agentClient.js +91 -0
  5. package/dist/bin/forgebook/agentClient.js.map +1 -0
  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 +54 -0
  11. package/dist/bin/forgebook/agentText.d.ts.map +1 -0
  12. package/dist/bin/forgebook/agentText.js +91 -0
  13. package/dist/bin/forgebook/agentText.js.map +1 -0
  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 +283 -79
  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 +38 -0
  42. package/dist/bin/forgebook/mcpTools.d.ts.map +1 -0
  43. package/dist/bin/forgebook/mcpTools.js +212 -0
  44. package/dist/bin/forgebook/mcpTools.js.map +1 -0
  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 +15 -10
  277. package/dist/src/viewState.d.ts.map +1 -1
  278. package/dist/src/viewState.js +35 -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 +120 -0
  289. package/dist/src/vite/agent.types.d.ts.map +1 -0
  290. package/dist/src/vite/agent.types.js +1 -0
  291. package/dist/src/vite/agent.types.js.map +1 -0
  292. package/dist/src/vite/agentApi.d.ts +106 -0
  293. package/dist/src/vite/agentApi.d.ts.map +1 -0
  294. package/dist/src/vite/agentApi.js +216 -0
  295. package/dist/src/vite/agentApi.js.map +1 -0
  296. package/dist/src/vite/agentRoutes.d.ts +50 -0
  297. package/dist/src/vite/agentRoutes.d.ts.map +1 -0
  298. package/dist/src/vite/agentRoutes.js +155 -0
  299. package/dist/src/vite/agentRoutes.js.map +1 -0
  300. package/dist/src/vite/configFile.d.ts +2 -1
  301. package/dist/src/vite/configFile.d.ts.map +1 -1
  302. package/dist/src/vite/configFile.js +29 -11
  303. package/dist/src/vite/configFile.js.map +1 -1
  304. package/dist/src/vite/docsExtractor.d.ts +26 -2
  305. package/dist/src/vite/docsExtractor.d.ts.map +1 -1
  306. package/dist/src/vite/docsExtractor.js +12 -9
  307. package/dist/src/vite/docsExtractor.js.map +1 -1
  308. package/dist/src/vite/docsWorker.js +18 -2
  309. package/dist/src/vite/docsWorker.js.map +1 -1
  310. package/dist/src/vite/forgebookPlugin.d.ts.map +1 -1
  311. package/dist/src/vite/forgebookPlugin.js +116 -16
  312. package/dist/src/vite/forgebookPlugin.js.map +1 -1
  313. package/dist/src/vite/indexStoryFile.d.ts +14 -0
  314. package/dist/src/vite/indexStoryFile.d.ts.map +1 -1
  315. package/dist/src/vite/indexStoryFile.js +13 -4
  316. package/dist/src/vite/indexStoryFile.js.map +1 -1
  317. package/dist/src/vite/mcpProtocol.d.ts +82 -0
  318. package/dist/src/vite/mcpProtocol.d.ts.map +1 -0
  319. package/dist/src/vite/mcpProtocol.js +184 -0
  320. package/dist/src/vite/mcpProtocol.js.map +1 -0
  321. package/dist/src/vite/pages.d.ts +12 -0
  322. package/dist/src/vite/pages.d.ts.map +1 -1
  323. package/dist/src/vite/pages.js +21 -0
  324. package/dist/src/vite/pages.js.map +1 -1
  325. package/dist/src/vite/storyFilesModule.d.ts +28 -1
  326. package/dist/src/vite/storyFilesModule.d.ts.map +1 -1
  327. package/dist/src/vite/storyFilesModule.js +34 -14
  328. package/dist/src/vite/storyFilesModule.js.map +1 -1
  329. package/dist/src/vite/usageGraph.d.ts +45 -0
  330. package/dist/src/vite/usageGraph.d.ts.map +1 -0
  331. package/dist/src/vite/usageGraph.js +246 -0
  332. package/dist/src/vite/usageGraph.js.map +1 -0
  333. package/dist/src/vite/usageModule.d.ts +33 -0
  334. package/dist/src/vite/usageModule.d.ts.map +1 -0
  335. package/dist/src/vite/usageModule.js +135 -0
  336. package/dist/src/vite/usageModule.js.map +1 -0
  337. package/dist/src/worstCase.d.ts +16 -0
  338. package/dist/src/worstCase.d.ts.map +1 -0
  339. package/dist/src/worstCase.js +16 -0
  340. package/dist/src/worstCase.js.map +1 -0
  341. package/package.json +18 -2
  342. package/dist/src/shell/SchemeSwitches.d.ts +0 -24
  343. package/dist/src/shell/SchemeSwitches.d.ts.map +0 -1
  344. package/dist/src/shell/SchemeSwitches.js +0 -36
  345. package/dist/src/shell/SchemeSwitches.js.map +0 -1
@@ -0,0 +1,91 @@
1
+ /**
2
+ * The answers of `forgebook stories`, `forgebook story`, `forgebook check` and `forgebook errors` as text for a
3
+ * terminal: a table of the stories, one story's facts, a check's problems, the frames' errors, the pictures taken. Pure: documents in, text out, laid out with cli-kit's helpers.
4
+ *
5
+ * @remarks
6
+ * Nothing is cut to the terminal's width: ids and links are what a reader copies, so a long line wraps instead.
7
+ *
8
+ * @module
9
+ */
10
+ import { formatJson } from "@ensiria/cli-kit/files";
11
+ import { keyValue, table } from "@ensiria/cli-kit/layout";
12
+ /** The style with no width to fit, so no cell is cut. */
13
+ const uncut = (style) => ({ ...style, width: Number.POSITIVE_INFINITY });
14
+ /**
15
+ * The stories as a table: one row per story, its id first (what `forgebook story` takes, never cut), then its
16
+ * component's title and its name.
17
+ *
18
+ * @param document - the stories document.
19
+ * @param style - colours, glyphs and width.
20
+ */
21
+ export const storiesText = (document, style) => table(document.components.flatMap((component) => component.stories.map((story) => [
22
+ story.id,
23
+ `${component.title} › ${story.name}${story.isUnlisted ? " (unlisted)" : ""}`
24
+ ])), { columns: [{ header: "Id" }, { header: "Story", tone: "muted" }] }, uncut(style));
25
+ /**
26
+ * One story's facts: where it is, where it opens, its args and its component's props.
27
+ *
28
+ * @param document - the story document.
29
+ * @param style - colours, glyphs and width.
30
+ */
31
+ export const storyText = (document, style) => {
32
+ const entries = [
33
+ ["Story", `${document.component.title} › ${document.story.name}`],
34
+ ["Id", document.story.id],
35
+ ["File", document.component.file],
36
+ ["Opens at", document.story.links.address],
37
+ ["Frame", document.story.links.frame],
38
+ ["Args", JSON.stringify(document.args)],
39
+ ["Props", document.docs === undefined ? "none" : document.docs.props.map((prop) => prop.name).join(", ")]
40
+ ];
41
+ if (document.story.description !== undefined)
42
+ entries.push(["About", document.story.description]);
43
+ return keyValue(entries, uncut(style));
44
+ };
45
+ /**
46
+ * A check's report as a table: one row per problem, its story, its view and its kind; a story that passes in a view gets
47
+ * one row saying so.
48
+ *
49
+ * @param report - the check's report.
50
+ * @param style - colours, glyphs and width.
51
+ */
52
+ export const checkText = (report, style) => table(report.results.flatMap((result) => result.problems.length === 0
53
+ ? [[result.storyId, result.view || "default", "passes"]]
54
+ : result.problems.map((problem) => [
55
+ result.storyId,
56
+ result.view || "default",
57
+ `${problem.kind}: ${problem.message}`
58
+ ])), { columns: [{ header: "Story" }, { header: "View", tone: "muted" }, { header: "Result" }] }, uncut(style));
59
+ /**
60
+ * The frames' errors as a table: their number, the story, what went wrong; nothing when there are none.
61
+ *
62
+ * @param document - the errors document.
63
+ * @param style - colours, glyphs and width.
64
+ */
65
+ export const errorsText = (document, style) => document.errors.length === 0
66
+ ? ""
67
+ : table(document.errors.map((error) => [String(error.n), error.storyId, `${error.kind}: ${error.message}`]), { columns: [{ header: "#", tone: "muted" }, { header: "Story" }, { header: "Error" }] }, uncut(style));
68
+ /**
69
+ * What `forgebook errors` prints of an answer: its JSON (one line per error while following, so each can be read as it
70
+ * comes), or its table.
71
+ *
72
+ * @param document - the errors document.
73
+ * @param mode - whether as JSON, and whether following.
74
+ * @param style - colours, glyphs and width.
75
+ */
76
+ export const errorsOutput = (document, mode, style) => {
77
+ if (!mode.isJson)
78
+ return `${errorsText(document, style)}\n`;
79
+ if (mode.isFollowing)
80
+ return document.errors.map((error) => `${JSON.stringify(error)}\n`).join("");
81
+ return formatJson(document);
82
+ };
83
+ /**
84
+ * The pictures taken as a table: the story, the view, the file.
85
+ *
86
+ * @param report - the picture run's report.
87
+ * @param shownFile - how a file is written for the reader (relative to where the command runs).
88
+ * @param style - colours, glyphs and width.
89
+ */
90
+ export const shotText = (report, shownFile, style) => table(report.shots.map((shot) => [shot.storyId, shot.view || "default", shownFile(shot.file)]), { columns: [{ header: "Story" }, { header: "View", tone: "muted" }, { header: "Picture" }] }, uncut(style));
91
+ //# sourceMappingURL=agentText.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"agentText.js","sourceRoot":"","sources":["../../../bin/forgebook/agentText.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,OAAO,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AACpD,OAAO,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,yBAAyB,CAAC;AAM1D,yDAAyD;AACzD,MAAM,KAAK,GAAG,CAAC,KAAkB,EAAe,EAAE,CAAC,CAAC,EAAE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AAM,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC,IAAI,CAAC,OAAO,EAAE,IAAI,CAAC,IAAI,IAAI,SAAS,EAAE,SAAS,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,EACxF,EAAE,OAAO,EAAE,CAAC,EAAE,MAAM,EAAE,OAAO,EAAE,EAAE,EAAE,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,OAAO,EAAE,EAAE,EAAE,MAAM,EAAE,SAAS,EAAE,CAAC,EAAE,EAC5F,KAAK,CAAC,KAAK,CAAC,CACb,CAAC"}
@@ -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":"AAAA;;;;;GAKG;AACH,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAEpC,OAAO,EAAE,IAAI,EAAE,MAAM,4BAA4B,CAAC;AAClD,OAAO,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AAGpD,OAAO,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;AAItD,OAAO,EACL,YAAY,EACZ,cAAc,EACd,cAAc,EAEf,MAAM,8BAA8B,CAAC;AACtC,OAAO,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AAQnD,mDAAmD;AACnD,MAAM,CAAC,MAAM,iBAAiB,GAAqB;IACjD,MAAM,EAAE;QACN,IAAI,EAAE,QAAQ;QACd,SAAS,EAAE,MAAM;QACjB,WAAW,EAAE,+EAA+E;KAC7F;CACF,CAAC;AAEF,0CAA0C;AAC1C,MAAM,CAAC,MAAM,OAAO,GAAG,WAAW,CAAC;AAEnC;;;;;GAKG;AACH,MAAM,CAAC,MAAM,QAAQ,GAAG,KAAK,EAAE,IAAwB,EAA2B,EAAE;IAClF,MAAM,KAAK,GAAG,IAAI,KAAK,SAAS,CAAC,CAAC,CAAC,cAAc,CAAC,OAAO,CAAC,GAAG,EAAE,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;IACjF,IAAI,KAAK,KAAK,SAAS;QACrB,MAAM,IAAI,WAAW,CAAC,MAAM,YAAY,CAAC,CAAC,CAAC,OAAO,EAAE;YAClD,IAAI,EAAE,OAAO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AC,CAAC;IACjC,CAAC;IACD,OAAO,MAAM,CAAC,IAAI,CAAC;AACrB,CAAC,CAAC;AAEF;;;;;;;;;GASG;AACH,MAAM,CAAC,MAAM,WAAW,GAAG,CACzB,IAAY,EACZ,QAAyC,EACzC,QAA2B,EAC3B,OAAkF,EAC5E,EAAE;IACR,OAAO,CAAC,EAAE,CAAC,MAAM,CAAC,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,UAAU,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,GAAG,IAAI,IAAI,CAAC,CAAC;IAC7E,KAAK,MAAM,OAAO,IAAI,QAAQ;QAAE,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;IAC1D,IAAI,QAAQ,CAAC,MAAM,GAAG,CAAC;QACrB,MAAM,IAAI,WAAW,CAAC,GAAG,QAAQ,CAAC,MAAM,WAAW,EAAE,EAAE,QAAQ,EAAE,IAAI,CAAC,OAAO,EAAE,UAAU,EAAE,IAAI,EAAE,CAAC,CAAC;AACvG,CAAC,CAAC"}
@@ -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,E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