@promptbook/cli 0.112.0-32 → 0.112.0-34

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 (323) hide show
  1. package/esm/index.es.js +571 -538
  2. package/esm/index.es.js.map +1 -1
  3. package/esm/scripts/find-fresh-emoji-tags/find-fresh-emoji-tags.d.ts +1 -3
  4. package/esm/scripts/find-refactor-candidates/analyzeSourceFileForRefactorCandidate.d.ts +27 -0
  5. package/esm/scripts/find-refactor-candidates/buildPromptContent.d.ts +8 -0
  6. package/esm/scripts/find-refactor-candidates/find-refactor-candidates.d.ts +1 -3
  7. package/esm/scripts/find-refactor-candidates/findRefactorCandidatesInProject.d.ts +8 -0
  8. package/esm/scripts/find-refactor-candidates/loadExistingPromptTargets.d.ts +7 -0
  9. package/esm/scripts/find-refactor-candidates/normalizeRefactorCandidatePath.d.ts +7 -0
  10. package/esm/scripts/find-refactor-candidates/writeRefactorCandidatePrompts.d.ts +27 -0
  11. package/esm/scripts/utils/autocommit/isWorkingTreeClean.d.ts +1 -3
  12. package/esm/src/_packages/types.index.d.ts +49 -49
  13. package/esm/src/book-components/Chat/Chat/ChatInputAreaDictationPanel.d.ts +42 -0
  14. package/esm/src/book-components/Chat/Chat/ChatMessageItem.d.ts +1 -14
  15. package/esm/src/book-components/Chat/Chat/ChatMessageRichContent.d.ts +32 -0
  16. package/esm/src/book-components/Chat/Chat/ChatMessageToolCallChips.d.ts +22 -0
  17. package/esm/src/book-components/Chat/Chat/StreamingFeaturePlaceholder.d.ts +33 -0
  18. package/esm/src/book-components/Chat/Chat/createChatMessageToolCallRenderModel.d.ts +76 -0
  19. package/esm/src/book-components/Chat/Chat/createProgressCardChecklistMarkdown.d.ts +16 -0
  20. package/esm/src/book-components/Chat/Chat/renderEmailToolCallDetails.d.ts +26 -0
  21. package/esm/src/book-components/Chat/Chat/renderMemoryToolCallDetails.d.ts +31 -0
  22. package/esm/src/book-components/Chat/Chat/renderPopupToolCallDetails.d.ts +32 -0
  23. package/esm/src/book-components/Chat/Chat/renderRunBrowserToolCallDetails.d.ts +31 -0
  24. package/esm/src/book-components/Chat/Chat/renderSearchToolCallDetails.d.ts +31 -0
  25. package/esm/src/book-components/Chat/Chat/renderSelfLearningToolCallDetails.d.ts +38 -0
  26. package/esm/src/book-components/Chat/Chat/renderTimeToolCallDetails.d.ts +38 -0
  27. package/esm/src/book-components/Chat/Chat/renderTimeoutToolCallDetails.d.ts +46 -0
  28. package/esm/src/book-components/Chat/Chat/renderToolCallClockPanel.d.ts +33 -0
  29. package/esm/src/book-components/Chat/Chat/renderToolCallDetails.d.ts +2 -2
  30. package/esm/src/book-components/Chat/Chat/renderToolCallProgressPlaceholder.d.ts +29 -0
  31. package/esm/src/book-components/Chat/Chat/renderWalletCredentialToolCallDetails.d.ts +26 -0
  32. package/esm/src/book-components/Chat/Chat/resolveToolCallProgressMessage.d.ts +9 -0
  33. package/esm/src/book-components/Chat/Chat/useChatInputAreaAttachments.d.ts +32 -0
  34. package/esm/src/book-components/Chat/Chat/useChatInputAreaDictation.d.ts +76 -0
  35. package/esm/src/book-components/Chat/Chat/useChatMessageAvatarTooltip.d.ts +31 -0
  36. package/esm/src/book-components/Chat/Chat/useChatMessageSpeechPlayback.d.ts +29 -0
  37. package/esm/src/cli/$runPromptbookCli.d.ts +1 -3
  38. package/esm/src/cli/cli-commands/_boilerplate.d.ts +2 -4
  39. package/esm/src/cli/cli-commands/about.d.ts +1 -1
  40. package/esm/src/cli/cli-commands/coder/find-fresh-emoji-tags.d.ts +2 -4
  41. package/esm/src/cli/cli-commands/coder/find-refactor-candidates.d.ts +2 -4
  42. package/esm/src/cli/cli-commands/coder/generate-boilerplates.d.ts +2 -4
  43. package/esm/src/cli/cli-commands/coder/init.d.ts +2 -4
  44. package/esm/src/cli/cli-commands/coder/run.d.ts +2 -4
  45. package/esm/src/cli/cli-commands/coder/verify.d.ts +2 -4
  46. package/esm/src/cli/cli-commands/coder.d.ts +2 -4
  47. package/esm/src/cli/cli-commands/hello.d.ts +1 -1
  48. package/esm/src/cli/cli-commands/list-models.d.ts +2 -4
  49. package/esm/src/cli/cli-commands/list-scrapers.d.ts +2 -4
  50. package/esm/src/cli/cli-commands/login.d.ts +1 -1
  51. package/esm/src/cli/cli-commands/make.d.ts +1 -1
  52. package/esm/src/cli/cli-commands/prettify.d.ts +1 -1
  53. package/esm/src/cli/cli-commands/run.d.ts +1 -1
  54. package/esm/src/cli/cli-commands/runInteractiveChatbot.d.ts +1 -1
  55. package/esm/src/cli/cli-commands/start-agents-server.d.ts +2 -4
  56. package/esm/src/cli/cli-commands/start-pipelines-server.d.ts +1 -1
  57. package/esm/src/cli/cli-commands/test-command.d.ts +1 -1
  58. package/esm/src/cli/main.d.ts +2 -4
  59. package/esm/src/cli/promptbookCli.d.ts +1 -1
  60. package/esm/src/commitments/USE_BROWSER/fetchUrlContent.d.ts +1 -3
  61. package/esm/src/conversion/archive/loadArchive.d.ts +1 -3
  62. package/esm/src/conversion/archive/saveArchive.d.ts +1 -1
  63. package/esm/src/conversion/validation/_importPipeline.d.ts +2 -4
  64. package/esm/src/dialogs/simple-prompt/SimplePromptInterfaceTools.d.ts +1 -3
  65. package/esm/src/executables/$provideExecutablesForNode.d.ts +1 -1
  66. package/esm/src/executables/apps/locateLibreoffice.d.ts +2 -4
  67. package/esm/src/executables/apps/locatePandoc.d.ts +2 -4
  68. package/esm/src/executables/locateApp.d.ts +2 -4
  69. package/esm/src/executables/platforms/locateAppOnLinux.d.ts +2 -4
  70. package/esm/src/executables/platforms/locateAppOnMacOs.d.ts +2 -4
  71. package/esm/src/executables/platforms/locateAppOnWindows.d.ts +2 -4
  72. package/esm/src/execution/translation/automatic-translate/translateMessages.d.ts +2 -4
  73. package/esm/src/execution/utils/$provideExecutionToolsForNode.d.ts +2 -4
  74. package/esm/src/llm-providers/_common/register/$provideEnvFilename.d.ts +1 -3
  75. package/esm/src/llm-providers/_common/register/$provideLlmToolsConfigurationFromEnv.d.ts +1 -3
  76. package/esm/src/llm-providers/_common/register/$provideLlmToolsForWizardOrCli.d.ts +1 -1
  77. package/esm/src/llm-providers/_common/register/$provideLlmToolsFromEnv.d.ts +1 -3
  78. package/esm/src/llm-providers/_multiple/playground/playground.d.ts +1 -3
  79. package/esm/src/llm-providers/agent/playground/playground.d.ts +1 -1
  80. package/esm/src/llm-providers/anthropic-claude/playground/playground.d.ts +1 -1
  81. package/esm/src/llm-providers/azure-openai/playground/playground.d.ts +2 -4
  82. package/esm/src/llm-providers/ollama/playground/playground.d.ts +2 -4
  83. package/esm/src/llm-providers/openai/playground/playground.d.ts +2 -4
  84. package/esm/src/llm-providers/remote/playground/playground.d.ts +1 -3
  85. package/esm/src/llm-providers/vercel/playground/playground.d.ts +2 -4
  86. package/esm/src/playground/permanent/_boilerplate.d.ts +1 -3
  87. package/esm/src/playground/permanent/agent-with-browser-playground.d.ts +1 -3
  88. package/esm/src/playground/permanent/error-handling-playground.d.ts +1 -3
  89. package/esm/src/playground/playground.d.ts +2 -4
  90. package/esm/src/remote-server/startAgentServer.d.ts +1 -3
  91. package/esm/src/remote-server/startRemoteServer.d.ts +1 -2
  92. package/esm/src/scrapers/_boilerplate/BoilerplateScraper.d.ts +4 -6
  93. package/esm/src/scrapers/_boilerplate/playground/boilerplate-scraper-playground.d.ts +1 -3
  94. package/esm/src/scrapers/_common/register/$provideFilesystemForNode.d.ts +2 -4
  95. package/esm/src/scrapers/_common/register/$provideScrapersForNode.d.ts +2 -4
  96. package/esm/src/scrapers/_common/register/$provideScriptingForNode.d.ts +2 -4
  97. package/esm/src/scrapers/_common/utils/getScraperIntermediateSource.d.ts +1 -1
  98. package/esm/src/scrapers/document/DocumentScraper.d.ts +1 -1
  99. package/esm/src/scrapers/document/playground/document-scraper-playground.d.ts +1 -3
  100. package/esm/src/scrapers/document-legacy/LegacyDocumentScraper.d.ts +1 -1
  101. package/esm/src/scrapers/document-legacy/playground/legacy-document-scraper-playground.d.ts +1 -3
  102. package/esm/src/scrapers/markdown/playground/markdown-scraper-playground.d.ts +1 -3
  103. package/esm/src/scrapers/markitdown/MarkitdownScraper.d.ts +1 -1
  104. package/esm/src/scrapers/markitdown/playground/markitdown-scraper-playground.d.ts +1 -3
  105. package/esm/src/scrapers/pdf/PdfScraper.d.ts +1 -1
  106. package/esm/src/scrapers/pdf/playground/pdf-scraper-playground.d.ts +1 -3
  107. package/esm/src/scrapers/website/WebsiteScraper.d.ts +1 -1
  108. package/esm/src/scrapers/website/playground/website-scraper-playground.d.ts +1 -3
  109. package/esm/src/speech-recognition/BrowserSpeechRecognition.d.ts +2 -4
  110. package/esm/src/storage/file-cache-storage/FileCacheStorage.d.ts +2 -4
  111. package/esm/src/storage/local-storage/getIndexedDbStorage.d.ts +1 -3
  112. package/esm/src/storage/local-storage/getLocalStorage.d.ts +1 -3
  113. package/esm/src/storage/local-storage/getSessionStorage.d.ts +1 -3
  114. package/esm/src/transpilers/openai-sdk/playground/playground.d.ts +1 -3
  115. package/esm/src/types/InputParameters_private.d.ts +11 -0
  116. package/esm/src/types/Parameters_private.d.ts +16 -0
  117. package/esm/src/types/ReservedParameters_private.d.ts +10 -0
  118. package/esm/src/types/number_bytes.d.ts +21 -0
  119. package/esm/src/types/number_id.d.ts +13 -0
  120. package/esm/src/types/number_likeness.d.ts +8 -0
  121. package/esm/src/types/number_milliseconds.d.ts +33 -0
  122. package/esm/src/types/number_percent.d.ts +18 -0
  123. package/esm/src/types/number_positive.d.ts +16 -0
  124. package/esm/src/types/number_usd.d.ts +6 -106
  125. package/esm/src/types/string_agent_hash_private.d.ts +9 -0
  126. package/esm/src/types/string_agent_name_in_book_private.d.ts +8 -0
  127. package/esm/src/types/string_agent_name_private.d.ts +9 -0
  128. package/esm/src/types/string_agent_permanent_id_private.d.ts +10 -0
  129. package/esm/src/types/string_base64_private.d.ts +17 -0
  130. package/esm/src/types/string_business_category_name_private.d.ts +6 -0
  131. package/esm/src/types/string_char_private.d.ts +8 -0
  132. package/esm/src/types/string_chat_prompt_private.d.ts +9 -0
  133. package/esm/src/types/string_completion_prompt_private.d.ts +9 -0
  134. package/esm/src/types/string_email_private.d.ts +16 -0
  135. package/esm/src/types/string_host_private.d.ts +55 -0
  136. package/esm/src/types/string_mime_type_private.d.ts +17 -0
  137. package/esm/src/types/string_model_description_private.d.ts +8 -0
  138. package/esm/src/types/string_model_name_private.d.ts +8 -0
  139. package/esm/src/types/string_name_private.d.ts +9 -0
  140. package/esm/src/types/string_page_private.d.ts +9 -0
  141. package/esm/src/types/string_parameter_name.d.ts +74 -31
  142. package/esm/src/types/string_parameter_value_private.d.ts +9 -0
  143. package/esm/src/types/string_persona_description_private.d.ts +8 -0
  144. package/esm/src/types/string_prompt_image_private.d.ts +8 -0
  145. package/esm/src/types/string_prompt_private.d.ts +8 -0
  146. package/esm/src/types/string_reserved_parameter_name_private.d.ts +11 -0
  147. package/esm/src/types/string_system_message_private.d.ts +9 -0
  148. package/esm/src/types/string_template_private.d.ts +8 -0
  149. package/esm/src/types/string_text_prompt_private.d.ts +9 -0
  150. package/esm/src/types/string_title_private.d.ts +9 -0
  151. package/esm/src/types/string_url.d.ts +50 -46
  152. package/esm/src/types/string_url_private.d.ts +88 -0
  153. package/esm/src/types/typeAliases.d.ts +7 -1
  154. package/esm/src/utils/execCommand/$execCommand.d.ts +1 -3
  155. package/esm/src/utils/execCommand/$execCommands.d.ts +1 -3
  156. package/esm/src/utils/files/$induceBookDownload.d.ts +1 -3
  157. package/esm/src/utils/files/$induceFileDownload.d.ts +1 -3
  158. package/esm/src/utils/files/ObjectUrl.d.ts +1 -3
  159. package/esm/src/version.d.ts +1 -1
  160. package/esm/src/wizard/$getCompiledBook.d.ts +2 -4
  161. package/esm/src/wizard/wizard.d.ts +2 -4
  162. package/package.json +1 -1
  163. package/umd/index.umd.js +571 -538
  164. package/umd/index.umd.js.map +1 -1
  165. package/umd/scripts/find-fresh-emoji-tags/find-fresh-emoji-tags.d.ts +1 -3
  166. package/umd/scripts/find-refactor-candidates/analyzeSourceFileForRefactorCandidate.d.ts +27 -0
  167. package/umd/scripts/find-refactor-candidates/buildPromptContent.d.ts +8 -0
  168. package/umd/scripts/find-refactor-candidates/find-refactor-candidates.d.ts +1 -3
  169. package/umd/scripts/find-refactor-candidates/findRefactorCandidatesInProject.d.ts +8 -0
  170. package/umd/scripts/find-refactor-candidates/loadExistingPromptTargets.d.ts +7 -0
  171. package/umd/scripts/find-refactor-candidates/normalizeRefactorCandidatePath.d.ts +7 -0
  172. package/umd/scripts/find-refactor-candidates/writeRefactorCandidatePrompts.d.ts +27 -0
  173. package/umd/scripts/utils/autocommit/isWorkingTreeClean.d.ts +1 -3
  174. package/umd/src/_packages/types.index.d.ts +49 -49
  175. package/umd/src/book-components/Chat/Chat/ChatInputAreaDictationPanel.d.ts +42 -0
  176. package/umd/src/book-components/Chat/Chat/ChatMessageItem.d.ts +1 -14
  177. package/umd/src/book-components/Chat/Chat/ChatMessageRichContent.d.ts +32 -0
  178. package/umd/src/book-components/Chat/Chat/ChatMessageToolCallChips.d.ts +22 -0
  179. package/umd/src/book-components/Chat/Chat/StreamingFeaturePlaceholder.d.ts +33 -0
  180. package/umd/src/book-components/Chat/Chat/createChatMessageToolCallRenderModel.d.ts +76 -0
  181. package/umd/src/book-components/Chat/Chat/createProgressCardChecklistMarkdown.d.ts +16 -0
  182. package/umd/src/book-components/Chat/Chat/renderEmailToolCallDetails.d.ts +26 -0
  183. package/umd/src/book-components/Chat/Chat/renderMemoryToolCallDetails.d.ts +31 -0
  184. package/umd/src/book-components/Chat/Chat/renderPopupToolCallDetails.d.ts +32 -0
  185. package/umd/src/book-components/Chat/Chat/renderRunBrowserToolCallDetails.d.ts +31 -0
  186. package/umd/src/book-components/Chat/Chat/renderSearchToolCallDetails.d.ts +31 -0
  187. package/umd/src/book-components/Chat/Chat/renderSelfLearningToolCallDetails.d.ts +38 -0
  188. package/umd/src/book-components/Chat/Chat/renderTimeToolCallDetails.d.ts +38 -0
  189. package/umd/src/book-components/Chat/Chat/renderTimeoutToolCallDetails.d.ts +46 -0
  190. package/umd/src/book-components/Chat/Chat/renderToolCallClockPanel.d.ts +33 -0
  191. package/umd/src/book-components/Chat/Chat/renderToolCallDetails.d.ts +2 -2
  192. package/umd/src/book-components/Chat/Chat/renderToolCallProgressPlaceholder.d.ts +29 -0
  193. package/umd/src/book-components/Chat/Chat/renderWalletCredentialToolCallDetails.d.ts +26 -0
  194. package/umd/src/book-components/Chat/Chat/resolveToolCallProgressMessage.d.ts +9 -0
  195. package/umd/src/book-components/Chat/Chat/useChatInputAreaAttachments.d.ts +32 -0
  196. package/umd/src/book-components/Chat/Chat/useChatInputAreaDictation.d.ts +76 -0
  197. package/umd/src/book-components/Chat/Chat/useChatMessageAvatarTooltip.d.ts +31 -0
  198. package/umd/src/book-components/Chat/Chat/useChatMessageSpeechPlayback.d.ts +29 -0
  199. package/umd/src/cli/$runPromptbookCli.d.ts +1 -3
  200. package/umd/src/cli/cli-commands/_boilerplate.d.ts +2 -4
  201. package/umd/src/cli/cli-commands/about.d.ts +1 -1
  202. package/umd/src/cli/cli-commands/coder/find-fresh-emoji-tags.d.ts +2 -4
  203. package/umd/src/cli/cli-commands/coder/find-refactor-candidates.d.ts +2 -4
  204. package/umd/src/cli/cli-commands/coder/generate-boilerplates.d.ts +2 -4
  205. package/umd/src/cli/cli-commands/coder/init.d.ts +2 -4
  206. package/umd/src/cli/cli-commands/coder/run.d.ts +2 -4
  207. package/umd/src/cli/cli-commands/coder/verify.d.ts +2 -4
  208. package/umd/src/cli/cli-commands/coder.d.ts +2 -4
  209. package/umd/src/cli/cli-commands/hello.d.ts +1 -1
  210. package/umd/src/cli/cli-commands/list-models.d.ts +2 -4
  211. package/umd/src/cli/cli-commands/list-scrapers.d.ts +2 -4
  212. package/umd/src/cli/cli-commands/login.d.ts +1 -1
  213. package/umd/src/cli/cli-commands/make.d.ts +1 -1
  214. package/umd/src/cli/cli-commands/prettify.d.ts +1 -1
  215. package/umd/src/cli/cli-commands/run.d.ts +1 -1
  216. package/umd/src/cli/cli-commands/runInteractiveChatbot.d.ts +1 -1
  217. package/umd/src/cli/cli-commands/start-agents-server.d.ts +2 -4
  218. package/umd/src/cli/cli-commands/start-pipelines-server.d.ts +1 -1
  219. package/umd/src/cli/cli-commands/test-command.d.ts +1 -1
  220. package/umd/src/cli/main.d.ts +2 -4
  221. package/umd/src/cli/promptbookCli.d.ts +1 -1
  222. package/umd/src/commitments/USE_BROWSER/fetchUrlContent.d.ts +1 -3
  223. package/umd/src/conversion/archive/loadArchive.d.ts +1 -3
  224. package/umd/src/conversion/archive/saveArchive.d.ts +1 -1
  225. package/umd/src/conversion/validation/_importPipeline.d.ts +2 -4
  226. package/umd/src/dialogs/simple-prompt/SimplePromptInterfaceTools.d.ts +1 -3
  227. package/umd/src/executables/$provideExecutablesForNode.d.ts +1 -1
  228. package/umd/src/executables/apps/locateLibreoffice.d.ts +2 -4
  229. package/umd/src/executables/apps/locatePandoc.d.ts +2 -4
  230. package/umd/src/executables/locateApp.d.ts +2 -4
  231. package/umd/src/executables/platforms/locateAppOnLinux.d.ts +2 -4
  232. package/umd/src/executables/platforms/locateAppOnMacOs.d.ts +2 -4
  233. package/umd/src/executables/platforms/locateAppOnWindows.d.ts +2 -4
  234. package/umd/src/execution/translation/automatic-translate/translateMessages.d.ts +2 -4
  235. package/umd/src/execution/utils/$provideExecutionToolsForNode.d.ts +2 -4
  236. package/umd/src/llm-providers/_common/register/$provideEnvFilename.d.ts +1 -3
  237. package/umd/src/llm-providers/_common/register/$provideLlmToolsConfigurationFromEnv.d.ts +1 -3
  238. package/umd/src/llm-providers/_common/register/$provideLlmToolsForWizardOrCli.d.ts +1 -1
  239. package/umd/src/llm-providers/_common/register/$provideLlmToolsFromEnv.d.ts +1 -3
  240. package/umd/src/llm-providers/_multiple/playground/playground.d.ts +1 -3
  241. package/umd/src/llm-providers/agent/playground/playground.d.ts +1 -1
  242. package/umd/src/llm-providers/anthropic-claude/playground/playground.d.ts +1 -1
  243. package/umd/src/llm-providers/azure-openai/playground/playground.d.ts +2 -4
  244. package/umd/src/llm-providers/ollama/playground/playground.d.ts +2 -4
  245. package/umd/src/llm-providers/openai/playground/playground.d.ts +2 -4
  246. package/umd/src/llm-providers/remote/playground/playground.d.ts +1 -3
  247. package/umd/src/llm-providers/vercel/playground/playground.d.ts +2 -4
  248. package/umd/src/playground/permanent/_boilerplate.d.ts +1 -3
  249. package/umd/src/playground/permanent/agent-with-browser-playground.d.ts +1 -3
  250. package/umd/src/playground/permanent/error-handling-playground.d.ts +1 -3
  251. package/umd/src/playground/playground.d.ts +2 -4
  252. package/umd/src/remote-server/startAgentServer.d.ts +1 -3
  253. package/umd/src/remote-server/startRemoteServer.d.ts +1 -2
  254. package/umd/src/scrapers/_boilerplate/BoilerplateScraper.d.ts +4 -6
  255. package/umd/src/scrapers/_boilerplate/playground/boilerplate-scraper-playground.d.ts +1 -3
  256. package/umd/src/scrapers/_common/register/$provideFilesystemForNode.d.ts +2 -4
  257. package/umd/src/scrapers/_common/register/$provideScrapersForNode.d.ts +2 -4
  258. package/umd/src/scrapers/_common/register/$provideScriptingForNode.d.ts +2 -4
  259. package/umd/src/scrapers/_common/utils/getScraperIntermediateSource.d.ts +1 -1
  260. package/umd/src/scrapers/document/DocumentScraper.d.ts +1 -1
  261. package/umd/src/scrapers/document/playground/document-scraper-playground.d.ts +1 -3
  262. package/umd/src/scrapers/document-legacy/LegacyDocumentScraper.d.ts +1 -1
  263. package/umd/src/scrapers/document-legacy/playground/legacy-document-scraper-playground.d.ts +1 -3
  264. package/umd/src/scrapers/markdown/playground/markdown-scraper-playground.d.ts +1 -3
  265. package/umd/src/scrapers/markitdown/MarkitdownScraper.d.ts +1 -1
  266. package/umd/src/scrapers/markitdown/playground/markitdown-scraper-playground.d.ts +1 -3
  267. package/umd/src/scrapers/pdf/PdfScraper.d.ts +1 -1
  268. package/umd/src/scrapers/pdf/playground/pdf-scraper-playground.d.ts +1 -3
  269. package/umd/src/scrapers/website/WebsiteScraper.d.ts +1 -1
  270. package/umd/src/scrapers/website/playground/website-scraper-playground.d.ts +1 -3
  271. package/umd/src/speech-recognition/BrowserSpeechRecognition.d.ts +2 -4
  272. package/umd/src/storage/file-cache-storage/FileCacheStorage.d.ts +2 -4
  273. package/umd/src/storage/local-storage/getIndexedDbStorage.d.ts +1 -3
  274. package/umd/src/storage/local-storage/getLocalStorage.d.ts +1 -3
  275. package/umd/src/storage/local-storage/getSessionStorage.d.ts +1 -3
  276. package/umd/src/transpilers/openai-sdk/playground/playground.d.ts +1 -3
  277. package/umd/src/types/InputParameters_private.d.ts +11 -0
  278. package/umd/src/types/Parameters_private.d.ts +16 -0
  279. package/umd/src/types/ReservedParameters_private.d.ts +10 -0
  280. package/umd/src/types/number_bytes.d.ts +21 -0
  281. package/umd/src/types/number_id.d.ts +13 -0
  282. package/umd/src/types/number_likeness.d.ts +8 -0
  283. package/umd/src/types/number_milliseconds.d.ts +33 -0
  284. package/umd/src/types/number_percent.d.ts +18 -0
  285. package/umd/src/types/number_positive.d.ts +16 -0
  286. package/umd/src/types/number_usd.d.ts +6 -106
  287. package/umd/src/types/string_agent_hash_private.d.ts +9 -0
  288. package/umd/src/types/string_agent_name_in_book_private.d.ts +8 -0
  289. package/umd/src/types/string_agent_name_private.d.ts +9 -0
  290. package/umd/src/types/string_agent_permanent_id_private.d.ts +10 -0
  291. package/umd/src/types/string_base64_private.d.ts +17 -0
  292. package/umd/src/types/string_business_category_name_private.d.ts +6 -0
  293. package/umd/src/types/string_char_private.d.ts +8 -0
  294. package/umd/src/types/string_chat_prompt_private.d.ts +9 -0
  295. package/umd/src/types/string_completion_prompt_private.d.ts +9 -0
  296. package/umd/src/types/string_email_private.d.ts +16 -0
  297. package/umd/src/types/string_host_private.d.ts +55 -0
  298. package/umd/src/types/string_mime_type_private.d.ts +17 -0
  299. package/umd/src/types/string_model_description_private.d.ts +8 -0
  300. package/umd/src/types/string_model_name_private.d.ts +8 -0
  301. package/umd/src/types/string_name_private.d.ts +9 -0
  302. package/umd/src/types/string_page_private.d.ts +9 -0
  303. package/umd/src/types/string_parameter_name.d.ts +74 -31
  304. package/umd/src/types/string_parameter_value_private.d.ts +9 -0
  305. package/umd/src/types/string_persona_description_private.d.ts +8 -0
  306. package/umd/src/types/string_prompt_image_private.d.ts +8 -0
  307. package/umd/src/types/string_prompt_private.d.ts +8 -0
  308. package/umd/src/types/string_reserved_parameter_name_private.d.ts +11 -0
  309. package/umd/src/types/string_system_message_private.d.ts +9 -0
  310. package/umd/src/types/string_template_private.d.ts +8 -0
  311. package/umd/src/types/string_text_prompt_private.d.ts +9 -0
  312. package/umd/src/types/string_title_private.d.ts +9 -0
  313. package/umd/src/types/string_url.d.ts +50 -46
  314. package/umd/src/types/string_url_private.d.ts +88 -0
  315. package/umd/src/types/typeAliases.d.ts +7 -1
  316. package/umd/src/utils/execCommand/$execCommand.d.ts +1 -3
  317. package/umd/src/utils/execCommand/$execCommands.d.ts +1 -3
  318. package/umd/src/utils/files/$induceBookDownload.d.ts +1 -3
  319. package/umd/src/utils/files/$induceFileDownload.d.ts +1 -3
  320. package/umd/src/utils/files/ObjectUrl.d.ts +1 -3
  321. package/umd/src/version.d.ts +1 -1
  322. package/umd/src/wizard/$getCompiledBook.d.ts +2 -4
  323. package/umd/src/wizard/wizard.d.ts +2 -4
package/esm/index.es.js CHANGED
@@ -57,7 +57,7 @@ const BOOK_LANGUAGE_VERSION = '2.0.0';
57
57
  * @generated
58
58
  * @see https://github.com/webgptorg/promptbook
59
59
  */
60
- const PROMPTBOOK_ENGINE_VERSION = '0.112.0-32';
60
+ const PROMPTBOOK_ENGINE_VERSION = '0.112.0-34';
61
61
  /**
62
62
  * TODO: string_promptbook_version should be constrained to the all versions of Promptbook engine
63
63
  * Note: [💞] Ignore a discrepancy between file name and entity name
@@ -1596,11 +1596,11 @@ function $initializeAboutCommand(program) {
1596
1596
  return process.exit(0);
1597
1597
  }));
1598
1598
  }
1599
+ /** Note: [🟡] Code for CLI command [about](src/cli/cli-commands/about.ts) should never be published outside of `@promptbook/cli` */
1599
1600
  /**
1600
1601
  * TODO: [🕋] Use here `aboutPromptbookInformation`
1601
1602
  * TODO: [🗽] Unite branding and make single place for it
1602
1603
  * Note: [💞] Ignore a discrepancy between file name and entity name
1603
- * Note: [🟡] Code in this file should never be published outside of `@promptbook/cli`
1604
1604
  */
1605
1605
 
1606
1606
  /**
@@ -1632,10 +1632,8 @@ function $initializeCoderFindFreshEmojiTagCommand(program) {
1632
1632
  return process.exit(0);
1633
1633
  }));
1634
1634
  }
1635
- /**
1636
- * Note: [💞] Ignore a discrepancy between file name and entity name
1637
- * Note: [🟡] Code in this file should never be published outside of `@promptbook/cli`
1638
- */
1635
+ /** Note: [🟡] Code for CLI command [find-fresh-emoji-tags](src/cli/cli-commands/coder/find-fresh-emoji-tags.ts) should never be published outside of `@promptbook/cli` */
1636
+ /** Note: [💞] Ignore a discrepancy between file name and entity name */
1639
1637
 
1640
1638
  /**
1641
1639
  * Initializes `coder find-refactor-candidates` command for Promptbook CLI utilities
@@ -1670,10 +1668,8 @@ function $initializeCoderFindRefactorCandidatesCommand(program) {
1670
1668
  return process.exit(0);
1671
1669
  }));
1672
1670
  }
1673
- /**
1674
- * Note: [💞] Ignore a discrepancy between file name and entity name
1675
- * Note: [🟡] Code in this file should never be published outside of `@promptbook/cli`
1676
- */
1671
+ /** Note: [🟡] Code for CLI command [find-refactor-candidates](src/cli/cli-commands/coder/find-refactor-candidates.ts) should never be published outside of `@promptbook/cli` */
1672
+ /** Note: [💞] Ignore a discrepancy between file name and entity name */
1677
1673
 
1678
1674
  /**
1679
1675
  * Initializes `coder generate-boilerplates` command for Promptbook CLI utilities
@@ -1822,10 +1818,8 @@ function buildPromptSlug$1(template, title) {
1822
1818
  }
1823
1819
  return `${template}-${title}`;
1824
1820
  }
1825
- /**
1826
- * Note: [💞] Ignore a discrepancy between file name and entity name
1827
- * Note: [🟡] Code in this file should never be published outside of `@promptbook/cli`
1828
- */
1821
+ /** Note: [🟡] Code for CLI command [generate-boilerplates](src/cli/cli-commands/coder/generate-boilerplates.ts) should never be published outside of `@promptbook/cli` */
1822
+ /** Note: [💞] Ignore a discrepancy between file name and entity name */
1829
1823
 
1830
1824
  /**
1831
1825
  * Relative path to the root prompts directory used by Promptbook coder utilities.
@@ -2021,10 +2015,8 @@ async function isExistingDirectory(path) {
2021
2015
  return false;
2022
2016
  }
2023
2017
  }
2024
- /**
2025
- * Note: [💞] Ignore a discrepancy between file name and entity name
2026
- * Note: [🟡] Code in this file should never be published outside of `@promptbook/cli`
2027
- */
2018
+ /** Note: [🟡] Code for CLI command [init](src/cli/cli-commands/coder/init.ts) should never be published outside of `@promptbook/cli` */
2019
+ /** Note: [💞] Ignore a discrepancy between file name and entity name */
2028
2020
 
2029
2021
  /**
2030
2022
  * Initializes `coder run` command for Promptbook CLI utilities
@@ -2129,10 +2121,8 @@ function parseIntOption(value) {
2129
2121
  }
2130
2122
  return parsed;
2131
2123
  }
2132
- /**
2133
- * Note: [💞] Ignore a discrepancy between file name and entity name
2134
- * Note: [🟡] Code in this file should never be published outside of `@promptbook/cli`
2135
- */
2124
+ /** Note: [🟡] Code for CLI command [run](src/cli/cli-commands/coder/run.ts) should never be published outside of `@promptbook/cli` */
2125
+ /** Note: [💞] Ignore a discrepancy between file name and entity name */
2136
2126
 
2137
2127
  /**
2138
2128
  * Initializes `coder verify` command for Promptbook CLI utilities
@@ -2168,10 +2158,8 @@ function $initializeCoderVerifyCommand(program) {
2168
2158
  return process.exit(0);
2169
2159
  }));
2170
2160
  }
2171
- /**
2172
- * Note: [💞] Ignore a discrepancy between file name and entity name
2173
- * Note: [🟡] Code in this file should never be published outside of `@promptbook/cli`
2174
- */
2161
+ /** Note: [🟡] Code for CLI command [verify](src/cli/cli-commands/coder/verify.ts) should never be published outside of `@promptbook/cli` */
2162
+ /** Note: [💞] Ignore a discrepancy between file name and entity name */
2175
2163
 
2176
2164
  /**
2177
2165
  * Initializes `coder` command with subcommands for Promptbook CLI utilities
@@ -2215,10 +2203,8 @@ function $initializeCoderCommand(program) {
2215
2203
  coderCommand.help();
2216
2204
  });
2217
2205
  }
2218
- /**
2219
- * Note: [💞] Ignore a discrepancy between file name and entity name
2220
- * Note: [🟡] Code in this file should never be published outside of `@promptbook/cli`
2221
- */
2206
+ /** Note: [🟡] Code for CLI command [coder](src/cli/cli-commands/coder.ts) should never be published outside of `@promptbook/cli` */
2207
+ /** Note: [💞] Ignore a discrepancy between file name and entity name */
2222
2208
 
2223
2209
  /**
2224
2210
  * Initializes testing `hello` command for Promptbook CLI utilities
@@ -2243,10 +2229,10 @@ function $initializeHelloCommand(program) {
2243
2229
  return process.exit(0);
2244
2230
  }));
2245
2231
  }
2232
+ /** Note: [🟡] Code for CLI command [hello](src/cli/cli-commands/hello.ts) should never be published outside of `@promptbook/cli` */
2246
2233
  /**
2247
2234
  * TODO: [🧠][🐣] Make here some easter egg with generated hello greeting via LLM models
2248
2235
  * Note: [💞] Ignore a discrepancy between file name and entity name
2249
- * Note: [🟡] Code in this file should never be published outside of `@promptbook/cli`
2250
2236
  */
2251
2237
 
2252
2238
  /**
@@ -2687,10 +2673,8 @@ function $provideFilesystemForNode(options) {
2687
2673
  watch,
2688
2674
  };
2689
2675
  }
2690
- /**
2691
- * Note: [🟢] Code in this file should never be never released in packages that could be imported into browser environment
2692
- * TODO: [🏓] Unite `xxxForServer` and `xxxForNode` naming
2693
- */
2676
+ /** Note: [🟢] Code for Node scraper registration helper [$provideFilesystemForNode](src/scrapers/_common/register/$provideFilesystemForNode.ts) should never be published into packages that could be imported into browser environment */
2677
+ /** TODO: [🏓] Unite `xxxForServer` and `xxxForNode` naming */
2694
2678
 
2695
2679
  /**
2696
2680
  * Checks if the file exists
@@ -2776,9 +2760,7 @@ async function $provideEnvFilename() {
2776
2760
  }
2777
2761
  return null;
2778
2762
  }
2779
- /**
2780
- * Note: [🟢] Code in this file should never be never released in packages that could be imported into browser environment
2781
- */
2763
+ /** Note: [🟢] Code for Node environment helper [$provideEnvFilename](src/llm-providers/_common/register/$provideEnvFilename.ts) should never be published into packages that could be imported into browser environment */
2782
2764
 
2783
2765
  /**
2784
2766
  * Stores data in .env variables
@@ -3862,10 +3844,8 @@ class FileCacheStorage {
3862
3844
  // [0] When `setItem` and `removeItem` called, the state of the file system should be the same
3863
3845
  }
3864
3846
  }
3865
- /**
3866
- * TODO: [🌗] Maybe some checkers, not all valid JSONs are desired and valid values
3867
- * Note: [🟢] Code in this file should never be never released in packages that could be imported into browser environment
3868
- */
3847
+ /** Note: [🟢] Code for Node file-cache storage [FileCacheStorage](src/storage/file-cache-storage/FileCacheStorage.ts) should never be published into packages that could be imported into browser environment */
3848
+ /** TODO: [🌗] Maybe some checkers, not all valid JSONs are desired and valid values */
3869
3849
 
3870
3850
  /**
3871
3851
  * This error indicates problems parsing the format value
@@ -8155,9 +8135,7 @@ async function $provideLlmToolsConfigurationFromEnv() {
8155
8135
  .filter((configuration) => configuration !== null);
8156
8136
  return llmToolsConfiguration;
8157
8137
  }
8158
- /**
8159
- * Note: [🟢] Code in this file should never be never released in packages that could be imported into browser environment
8160
- */
8138
+ /** Note: [🟢] Code for Node environment helper [$provideLlmToolsConfigurationFromEnv](src/llm-providers/_common/register/$provideLlmToolsConfigurationFromEnv.ts) should never be published into packages that could be imported into browser environment */
8161
8139
 
8162
8140
  /**
8163
8141
  * Profile for Multiple providers aggregation
@@ -8488,20 +8466,18 @@ async function $provideLlmToolsFromEnv(options = {}) {
8488
8466
  }
8489
8467
  return createLlmToolsFromConfiguration(configuration, options);
8490
8468
  }
8469
+ /** Note: [🟢] Code for Node environment helper [$provideLlmToolsFromEnv](src/llm-providers/_common/register/$provideLlmToolsFromEnv.ts) should never be published into packages that could be imported into browser environment */
8491
8470
  /**
8492
8471
  * TODO: The architecture for LLM tools configuration consists of three key functions:
8493
8472
  * 1. `$provideLlmToolsFromEnv` - High-level function that detects available providers from env vars and returns ready-to-use LLM tools
8494
8473
  * 2. `$provideLlmToolsConfigurationFromEnv` - Middle layer that extracts configuration objects from environment variables
8495
8474
  * 3. `createLlmToolsFromConfiguration` - Low-level function that instantiates LLM tools from explicit configuration
8496
- *
8497
8475
  * This layered approach allows flexibility in how tools are configured:
8498
8476
  * - Use $provideLlmToolsFromEnv for automatic detection and setup in Node.js environments
8499
8477
  * - Use $provideLlmToolsConfigurationFromEnv to extract config objects for modification before instantiation
8500
8478
  * - Use createLlmToolsFromConfiguration for explicit control over tool configurations
8501
- *
8502
8479
  * TODO: [🧠][🍛] Which name is better `$provideLlmToolsFromEnv` or `$provideLlmToolsFromEnvironment`?
8503
8480
  * TODO: [🧠] Is there some meaningfull way how to test this util
8504
- * Note: [🟢] Code in this file should never be never released in packages that could be imported into browser environment
8505
8481
  * TODO: [🥃] Allow `ptbk make` without llm tools
8506
8482
  * TODO: This should be maybe not under `_common` but under `utils`
8507
8483
  * TODO: [®] DRY Register logic
@@ -8564,8 +8540,8 @@ async function $provideLlmToolsForWizardOrCli(options) {
8564
8540
  isCacheReloaded,
8565
8541
  });
8566
8542
  }
8543
+ /** Note: [🟢] Code for Node environment helper [$provideLlmToolsForWizardOrCli](src/llm-providers/_common/register/$provideLlmToolsForWizardOrCli.ts) should never be published into packages that could be imported into browser environment */
8567
8544
  /**
8568
- * Note: [🟢] Code in this file should never be never released in packages that could be imported into browser environment
8569
8545
  * TODO: [👷‍♂️] Write a comprehensive manual about the construction of LLM tools
8570
8546
  * TODO: [🥃] Allow `ptbk make` without llm tools
8571
8547
  * TODO: This should be maybe not under `_common` but under `utils-internal` / `utils/internal`
@@ -8734,10 +8710,8 @@ function $initializeListModelsCommand(program) {
8734
8710
  return process.exit(0);
8735
8711
  }));
8736
8712
  }
8737
- /**
8738
- * Note: [💞] Ignore a discrepancy between file name and entity name
8739
- * Note: [🟡] Code in this file should never be published outside of `@promptbook/cli`
8740
- */
8713
+ /** Note: [🟡] Code for CLI command [list-models](src/cli/cli-commands/list-models.ts) should never be published outside of `@promptbook/cli` */
8714
+ /** Note: [💞] Ignore a discrepancy between file name and entity name */
8741
8715
 
8742
8716
  /**
8743
8717
  * Normalize options for `execCommand` and `execCommands`
@@ -8904,9 +8878,7 @@ function $execCommand(options) {
8904
8878
  }
8905
8879
  });
8906
8880
  }
8907
- /**
8908
- * Note: [🟢] Code in this file should never be never released in packages that could be imported into browser environment
8909
- */
8881
+ /** Note: [🟢] Code for Node command-execution helper [$execCommand](src/utils/execCommand/$execCommand.ts) should never be published into packages that could be imported into browser environment */
8910
8882
 
8911
8883
  /**
8912
8884
  * Attempts to locate the specified application on a Linux system using the 'which' command.
@@ -8924,10 +8896,8 @@ async function locateAppOnLinux({ linuxWhich, }) {
8924
8896
  return null;
8925
8897
  }
8926
8898
  }
8927
- /**
8928
- * TODO: [🧠][♿] Maybe export through `@promptbook/node`
8929
- * Note: [🟢] Code in this file should never be never released in packages that could be imported into browser environment
8930
- */
8899
+ /** Note: [🟢] Code for Node executable locator [locateAppOnLinux](src/executables/platforms/locateAppOnLinux.ts) should never be published into packages that could be imported into browser environment */
8900
+ /** TODO: [🧠][♿] Maybe export through `@promptbook/node` */
8931
8901
 
8932
8902
  /**
8933
8903
  * Checks if the file is executable
@@ -8980,10 +8950,8 @@ async function locateAppOnMacOs({ macOsName, }) {
8980
8950
  return null;
8981
8951
  }
8982
8952
  }
8983
- /**
8984
- * TODO: [🧠][♿] Maybe export through `@promptbook/node`
8985
- * Note: [🟢] Code in this file should never be never released in packages that could be imported into browser environment
8986
- */
8953
+ /** Note: [🟢] Code for Node executable locator [locateAppOnMacOs](src/executables/platforms/locateAppOnMacOs.ts) should never be published into packages that could be imported into browser environment */
8954
+ /** TODO: [🧠][♿] Maybe export through `@promptbook/node` */
8987
8955
 
8988
8956
  /**
8989
8957
  * Attempts to locate the specified application on a Windows system by searching common installation directories.
@@ -9012,10 +8980,8 @@ async function locateAppOnWindows({ appName, windowsSuffix, }) {
9012
8980
  return null;
9013
8981
  }
9014
8982
  }
9015
- /**
9016
- * TODO: [🧠][♿] Maybe export through `@promptbook/node`
9017
- * Note: [🟢] Code in this file should never be never released in packages that could be imported into browser environment
9018
- */
8983
+ /** Note: [🟢] Code for Node executable locator [locateAppOnWindows](src/executables/platforms/locateAppOnWindows.ts) should never be published into packages that could be imported into browser environment */
8984
+ /** TODO: [🧠][♿] Maybe export through `@promptbook/node` */
9019
8985
 
9020
8986
  /**
9021
8987
  * Locates an application on the system
@@ -9052,10 +9018,8 @@ function locateApp(options) {
9052
9018
  }
9053
9019
  }
9054
9020
  }
9055
- /**
9056
- * TODO: [🧠][♿] Maybe export through `@promptbook/node`
9057
- * Note: [🟢] Code in this file should never be never released in packages that could be imported into browser environment
9058
- */
9021
+ /** Note: [🟢] Code for Node executable locator [locateApp](src/executables/locateApp.ts) should never be published into packages that could be imported into browser environment */
9022
+ /** TODO: [🧠][♿] Maybe export through `@promptbook/node` */
9059
9023
 
9060
9024
  /**
9061
9025
  * Locates the LibreOffice executable on the current system by searching platform-specific paths.
@@ -9071,10 +9035,8 @@ function locateLibreoffice() {
9071
9035
  macOsName: 'LibreOffice',
9072
9036
  });
9073
9037
  }
9074
- /**
9075
- * TODO: [🧠][♿] Maybe export through `@promptbook/node` OR `@promptbook/legacy-documents`
9076
- * Note: [🟢] Code in this file should never be never released in packages that could be imported into browser environment
9077
- */
9038
+ /** Note: [🟢] Code for Node executable locator [locateLibreoffice](src/executables/apps/locateLibreoffice.ts) should never be published into packages that could be imported into browser environment */
9039
+ /** TODO: [🧠][♿] Maybe export through `@promptbook/node` OR `@promptbook/legacy-documents` */
9078
9040
 
9079
9041
  /**
9080
9042
  * Locates the Pandoc executable on the current system by searching platform-specific paths.
@@ -9090,10 +9052,8 @@ function locatePandoc() {
9090
9052
  macOsName: 'Pandoc',
9091
9053
  });
9092
9054
  }
9093
- /**
9094
- * TODO: [🧠][♿] Maybe export through `@promptbook/node` OR `@promptbook/documents`
9095
- * Note: [🟢] Code in this file should never be never released in packages that could be imported into browser environment
9096
- */
9055
+ /** Note: [🟢] Code for Node executable locator [locatePandoc](src/executables/apps/locatePandoc.ts) should never be published into packages that could be imported into browser environment */
9056
+ /** TODO: [🧠][♿] Maybe export through `@promptbook/node` OR `@promptbook/documents` */
9097
9057
 
9098
9058
  /**
9099
9059
  * Provides paths to required executables (i.e. as Pandoc and LibreOffice) for Node.js environments.
@@ -9110,9 +9070,9 @@ async function $provideExecutablesForNode(options) {
9110
9070
  // <- TODO: [🧠] `null` vs `undefined`
9111
9071
  };
9112
9072
  }
9073
+ /** Note: [🟢] Code for Node executable locator [$provideExecutablesForNode](src/executables/$provideExecutablesForNode.ts) should never be published into packages that could be imported into browser environment */
9113
9074
  /**
9114
9075
  * TODO: [🧠] Allow to override the executables without need to call `locatePandoc` / `locateLibreoffice` in case of provided
9115
- * Note: [🟢] Code in this file should never be never released in packages that could be imported into browser environment
9116
9076
  * TODO: [🏓] Unite `xxxForServer` and `xxxForNode` naming
9117
9077
  */
9118
9078
 
@@ -9152,10 +9112,8 @@ async function $provideScrapersForNode(tools, options) {
9152
9112
  }
9153
9113
  return scrapers;
9154
9114
  }
9155
- /**
9156
- * Note: [🟢] Code in this file should never be never released in packages that could be imported into browser environment
9157
- * TODO: [🏓] Unite `xxxForServer` and `xxxForNode` naming
9158
- */
9115
+ /** Note: [🟢] Code for Node scraper registration helper [$provideScrapersForNode](src/scrapers/_common/register/$provideScrapersForNode.ts) should never be published into packages that could be imported into browser environment */
9116
+ /** TODO: [🏓] Unite `xxxForServer` and `xxxForNode` naming */
9159
9117
 
9160
9118
  /**
9161
9119
  * Global registry for storing metadata about all available scrapers and converters.
@@ -9289,10 +9247,8 @@ function $initializeListScrapersCommand(program) {
9289
9247
  return process.exit(0);
9290
9248
  }));
9291
9249
  }
9292
- /**
9293
- * Note: [💞] Ignore a discrepancy between file name and entity name
9294
- * Note: [🟡] Code in this file should never be published outside of `@promptbook/cli`
9295
- */
9250
+ /** Note: [🟡] Code for CLI command [list-scrapers](src/cli/cli-commands/list-scrapers.ts) should never be published outside of `@promptbook/cli` */
9251
+ /** Note: [💞] Ignore a discrepancy between file name and entity name */
9296
9252
 
9297
9253
  /**
9298
9254
  * Initializes `login` command for Promptbook CLI utilities
@@ -9319,10 +9275,10 @@ function $initializeLoginCommand(program) {
9319
9275
  return process.exit(0);
9320
9276
  }));
9321
9277
  }
9278
+ /** Note: [🟡] Code for CLI command [login](src/cli/cli-commands/login.ts) should never be published outside of `@promptbook/cli` */
9322
9279
  /**
9323
9280
  * TODO: Implement non-interactive login
9324
9281
  * Note: [💞] Ignore a discrepancy between file name and entity name
9325
- * Note: [🟡] Code in this file should never be published outside of `@promptbook/cli`
9326
9282
  */
9327
9283
 
9328
9284
  /**
@@ -9643,9 +9599,7 @@ async function loadArchive(filePath, fs) {
9643
9599
  }
9644
9600
  return collectionJson;
9645
9601
  }
9646
- /**
9647
- * Note: [🟢] Code in this file should never be never released in packages that could be imported into browser environment
9648
- */
9602
+ /** Note: [🟢] Code for Node archive helper [loadArchive](src/conversion/archive/loadArchive.ts) should never be published into packages that could be imported into browser environment */
9649
9603
 
9650
9604
  var PipelineCollection = [{title:"Prepare Knowledge from Markdown",pipelineUrl:"https://promptbook.studio/promptbook/prepare-knowledge-from-markdown.book",formfactorName:"GENERIC",parameters:[{name:"knowledgeContent",description:"Markdown document content",isInput:true,isOutput:false},{name:"knowledgePieces",description:"The knowledge JSON object",isInput:false,isOutput:true}],tasks:[{taskType:"PROMPT_TASK",name:"knowledge",title:"Knowledge",content:"You are experienced data researcher, extract the important knowledge from the document.\n\n# Rules\n\n- Make pieces of information concise, clear, and easy to understand\n- One piece of information should be approximately 1 paragraph\n- Divide the paragraphs by markdown horizontal lines ---\n- Omit irrelevant information\n- Group redundant information\n- Write just extracted information, nothing else\n\n# The document\n\nTake information from this document:\n\n> {knowledgeContent}",resultingParameterName:"knowledgePieces",dependentParameterNames:["knowledgeContent"]}],personas:[],preparations:[],knowledgeSources:[],knowledgePieces:[],sources:[{type:"BOOK",path:null,content:"# Prepare Knowledge from Markdown\n\n- PIPELINE URL `https://promptbook.studio/promptbook/prepare-knowledge-from-markdown.book`\n- INPUT PARAMETER `{knowledgeContent}` Markdown document content\n- OUTPUT PARAMETER `{knowledgePieces}` The knowledge JSON object\n\n## Knowledge\n\n<!-- TODO: [🍆] -FORMAT JSON -->\n\n```markdown\nYou are experienced data researcher, extract the important knowledge from the document.\n\n# Rules\n\n- Make pieces of information concise, clear, and easy to understand\n- One piece of information should be approximately 1 paragraph\n- Divide the paragraphs by markdown horizontal lines ---\n- Omit irrelevant information\n- Group redundant information\n- Write just extracted information, nothing else\n\n# The document\n\nTake information from this document:\n\n> {knowledgeContent}\n```\n\n`-> {knowledgePieces}`\n"}],sourceFile:"./books/prepare-knowledge-from-markdown.book"},{title:"Prepare Keywords",pipelineUrl:"https://promptbook.studio/promptbook/prepare-knowledge-keywords.book",formfactorName:"GENERIC",parameters:[{name:"knowledgePieceContent",description:"The content",isInput:true,isOutput:false},{name:"keywords",description:"Keywords separated by comma",isInput:false,isOutput:true}],tasks:[{taskType:"PROMPT_TASK",name:"knowledge",title:"Knowledge",content:"You are experienced data researcher, detect the important keywords in the document.\n\n# Rules\n\n- Write just keywords separated by comma\n\n# The document\n\nTake information from this document:\n\n> {knowledgePieceContent}",resultingParameterName:"keywords",dependentParameterNames:["knowledgePieceContent"]}],personas:[],preparations:[],knowledgeSources:[],knowledgePieces:[],sources:[{type:"BOOK",path:null,content:"# Prepare Keywords\n\n- PIPELINE URL `https://promptbook.studio/promptbook/prepare-knowledge-keywords.book`\n- INPUT PARAMETER `{knowledgePieceContent}` The content\n- OUTPUT PARAMETER `{keywords}` Keywords separated by comma\n\n## Knowledge\n\n<!-- TODO: [🍆] -FORMAT JSON -->\n\n```markdown\nYou are experienced data researcher, detect the important keywords in the document.\n\n# Rules\n\n- Write just keywords separated by comma\n\n# The document\n\nTake information from this document:\n\n> {knowledgePieceContent}\n```\n\n`-> {keywords}`\n"}],sourceFile:"./books/prepare-knowledge-keywords.book"},{title:"Prepare Knowledge-piece Title",pipelineUrl:"https://promptbook.studio/promptbook/prepare-knowledge-title.book",formfactorName:"GENERIC",parameters:[{name:"knowledgePieceContent",description:"The content",isInput:true,isOutput:false},{name:"title",description:"The title of the document",isInput:false,isOutput:true}],tasks:[{taskType:"PROMPT_TASK",name:"knowledge",title:"Knowledge",content:"You are experienced content creator, write best title for the document.\n\n# Rules\n\n- Write just title, nothing else\n- Write maximum 5 words for the title\n\n# The document\n\n> {knowledgePieceContent}",resultingParameterName:"title",expectations:{words:{min:1,max:8}},dependentParameterNames:["knowledgePieceContent"]}],personas:[],preparations:[],knowledgeSources:[],knowledgePieces:[],sources:[{type:"BOOK",path:null,content:"# Prepare Knowledge-piece Title\n\n- PIPELINE URL `https://promptbook.studio/promptbook/prepare-knowledge-title.book`\n- INPUT PARAMETER `{knowledgePieceContent}` The content\n- OUTPUT PARAMETER `{title}` The title of the document\n\n## Knowledge\n\n- EXPECT MIN 1 WORD\n- EXPECT MAX 8 WORDS\n\n```markdown\nYou are experienced content creator, write best title for the document.\n\n# Rules\n\n- Write just title, nothing else\n- Write maximum 5 words for the title\n\n# The document\n\n> {knowledgePieceContent}\n```\n\n`-> {title}`\n"}],sourceFile:"./books/prepare-knowledge-title.book"},{title:"Prepare Persona",pipelineUrl:"https://promptbook.studio/promptbook/prepare-persona.book",formfactorName:"GENERIC",parameters:[{name:"availableModels",description:"List of available model names together with their descriptions as JSON",isInput:true,isOutput:false},{name:"personaDescription",description:"Description of the persona",isInput:true,isOutput:false},{name:"modelsRequirements",description:"Specific requirements for the model",isInput:false,isOutput:true}],tasks:[{taskType:"PROMPT_TASK",name:"make-model-requirements",title:"Make modelRequirements",content:"You are an experienced AI engineer, you need to find the best models for virtual assistants:\n\n## Example\n\n```json\n[\n {\n \"modelName\": \"gpt-4o\",\n \"systemMessage\": \"You are experienced AI engineer and helpful assistant.\",\n \"temperature\": 0.7\n },\n {\n \"modelName\": \"claude-3-5-sonnet\",\n \"systemMessage\": \"You are a friendly and knowledgeable chatbot.\",\n \"temperature\": 0.5\n }\n]\n```\n\n## Instructions\n\n- Your output format is JSON array\n- Sort best-fitting models first\n- Omit any models that are not suitable\n- Write just the JSON, no other text should be present\n- Array contain items with following keys:\n - `modelName`: The name of the model to use\n - `systemMessage`: The system message to provide context to the model\n - `temperature`: The sampling temperature to use\n\n### Key `modelName`\n\nHere are the available models:\n\n```json\n{availableModels}\n```\n\n### Key `systemMessage`\n\nThe system message is used to communicate instructions or provide context to the model at the beginning of a conversation. It is displayed in a different format compared to user messages, helping the model understand its role in the conversation. The system message typically guides the model's behavior, sets the tone, or specifies desired output from the model. By utilizing the system message effectively, users can steer the model towards generating more accurate and relevant responses.\n\nFor example:\n\n> You are an experienced AI engineer and helpful assistant.\n\n> You are a friendly and knowledgeable chatbot.\n\n### Key `temperature`\n\nThe sampling temperature, between 0 and 1. Higher values like 0.8 will make the output more random, while lower values like 0.2 will make it more focused and deterministic. If set to 0, the model will use log probability to automatically increase the temperature until certain thresholds are hit.\n\nYou can pick a value between 0 and 2. For example:\n\n- `0.1`: Low temperature, extremely conservative and deterministic\n- `0.5`: Medium temperature, balanced between conservative and creative\n- `1.0`: High temperature, creative and bit random\n- `1.5`: Very high temperature, extremely creative and often chaotic and unpredictable\n- `2.0`: Maximum temperature, completely random and unpredictable, for some extreme creative use cases\n\n# The assistant\n\nTake this description of the persona:\n\n> {personaDescription}",resultingParameterName:"modelsRequirements",format:"JSON",dependentParameterNames:["availableModels","personaDescription"]}],personas:[],preparations:[],knowledgeSources:[],knowledgePieces:[],sources:[{type:"BOOK",path:null,content:"# Prepare Persona\n\n- PIPELINE URL `https://promptbook.studio/promptbook/prepare-persona.book`\n- INPUT PARAMETER `{availableModels}` List of available model names together with their descriptions as JSON\n- INPUT PARAMETER `{personaDescription}` Description of the persona\n- OUTPUT PARAMETER `{modelsRequirements}` Specific requirements for the model\n\n## Make modelRequirements\n\n- FORMAT JSON\n\n```markdown\nYou are an experienced AI engineer, you need to find the best models for virtual assistants:\n\n## Example\n\n\\`\\`\\`json\n[\n {\n \"modelName\": \"gpt-4o\",\n \"systemMessage\": \"You are experienced AI engineer and helpful assistant.\",\n \"temperature\": 0.7\n },\n {\n \"modelName\": \"claude-3-5-sonnet\",\n \"systemMessage\": \"You are a friendly and knowledgeable chatbot.\",\n \"temperature\": 0.5\n }\n]\n\\`\\`\\`\n\n## Instructions\n\n- Your output format is JSON array\n- Sort best-fitting models first\n- Omit any models that are not suitable\n- Write just the JSON, no other text should be present\n- Array contain items with following keys:\n - `modelName`: The name of the model to use\n - `systemMessage`: The system message to provide context to the model\n - `temperature`: The sampling temperature to use\n\n### Key `modelName`\n\nHere are the available models:\n\n\\`\\`\\`json\n{availableModels}\n\\`\\`\\`\n\n### Key `systemMessage`\n\nThe system message is used to communicate instructions or provide context to the model at the beginning of a conversation. It is displayed in a different format compared to user messages, helping the model understand its role in the conversation. The system message typically guides the model's behavior, sets the tone, or specifies desired output from the model. By utilizing the system message effectively, users can steer the model towards generating more accurate and relevant responses.\n\nFor example:\n\n> You are an experienced AI engineer and helpful assistant.\n\n> You are a friendly and knowledgeable chatbot.\n\n### Key `temperature`\n\nThe sampling temperature, between 0 and 1. Higher values like 0.8 will make the output more random, while lower values like 0.2 will make it more focused and deterministic. If set to 0, the model will use log probability to automatically increase the temperature until certain thresholds are hit.\n\nYou can pick a value between 0 and 2. For example:\n\n- `0.1`: Low temperature, extremely conservative and deterministic\n- `0.5`: Medium temperature, balanced between conservative and creative\n- `1.0`: High temperature, creative and bit random\n- `1.5`: Very high temperature, extremely creative and often chaotic and unpredictable\n- `2.0`: Maximum temperature, completely random and unpredictable, for some extreme creative use cases\n\n# The assistant\n\nTake this description of the persona:\n\n> {personaDescription}\n```\n\n`-> {modelsRequirements}`\n"}],sourceFile:"./books/prepare-persona.book"},{title:"Prepare Title",pipelineUrl:"https://promptbook.studio/promptbook/prepare-title.book",formfactorName:"GENERIC",parameters:[{name:"book",description:"The book to prepare the title for",isInput:true,isOutput:false},{name:"title",description:"Best title for the book",isInput:false,isOutput:true}],tasks:[{taskType:"PROMPT_TASK",name:"make-title",title:"Make title",content:"Make best title for given text which describes the workflow:\n\n## Rules\n\n- Write just title, nothing else\n- Title should be concise and clear - Write maximum ideally 2 words, maximum 5 words\n- Title starts with emoticon\n- Title should not mention the input and output of the workflow but the main purpose of the workflow\n _For example, not \"✍ Convert Knowledge-piece to title\" but \"✍ Title\"_\n\n## The workflow\n\n> {book}",resultingParameterName:"title",expectations:{words:{min:1,max:8},lines:{min:1,max:1}},dependentParameterNames:["book"]}],personas:[],preparations:[],knowledgeSources:[],knowledgePieces:[],sources:[{type:"BOOK",path:null,content:"# Prepare Title\n\n- PIPELINE URL `https://promptbook.studio/promptbook/prepare-title.book`\n- INPUT PARAMETER `{book}` The book to prepare the title for\n- OUTPUT PARAMETER `{title}` Best title for the book\n\n## Make title\n\n- EXPECT MIN 1 Word\n- EXPECT MAX 8 Words\n- EXPECT EXACTLY 1 Line\n\n```markdown\nMake best title for given text which describes the workflow:\n\n## Rules\n\n- Write just title, nothing else\n- Title should be concise and clear - Write maximum ideally 2 words, maximum 5 words\n- Title starts with emoticon\n- Title should not mention the input and output of the workflow but the main purpose of the workflow\n _For example, not \"✍ Convert Knowledge-piece to title\" but \"✍ Title\"_\n\n## The workflow\n\n> {book}\n```\n\n`-> {title}`\n"}],sourceFile:"./books/prepare-title.book"}];
9651
9605
 
@@ -16058,12 +16012,12 @@ async function getScraperIntermediateSource(source, options) {
16058
16012
  };
16059
16013
  return fileHandler;
16060
16014
  }
16015
+ /** Note: [🟢] Code for Node scraper helper [getScraperIntermediateSource](src/scrapers/_common/utils/getScraperIntermediateSource.ts) should never be published into packages that could be imported into browser environment */
16061
16016
  /**
16062
16017
  * Note: Not using `FileCacheStorage` for two reasons:
16063
16018
  * 1) Need to store more than serialized JSONs
16064
16019
  * 2) Need to switch between a `rootDirname` and `cacheDirname` <- TODO: [😡]
16065
16020
  * TODO: [🐱‍🐉][🧠] Make some smart crop
16066
- * Note: [🟢] Code in this file should never be never released in packages that could be imported into browser environment
16067
16021
  */
16068
16022
 
16069
16023
  /**
@@ -16395,11 +16349,11 @@ class WebsiteScraper {
16395
16349
  return knowledge;
16396
16350
  }
16397
16351
  }
16352
+ /** Note: [🟢] Code for Node scraper implementation [WebsiteScraper](src/scrapers/website/WebsiteScraper.ts) should never be published into packages that could be imported into browser environment */
16398
16353
  /**
16399
16354
  * TODO: [👣] Scraped website in .md can act as cache item - there is no need to run conversion each time
16400
16355
  * TODO: [🪂] Do it in parallel 11:11
16401
16356
  * Note: No need to aggregate usage here, it is done by intercepting the llmTools
16402
- * Note: [🟢] Code in this file should never be never released in packages that could be imported into browser environment
16403
16357
  */
16404
16358
 
16405
16359
  /**
@@ -16522,9 +16476,7 @@ async function fetchUrlContent(url) {
16522
16476
  `);
16523
16477
  }
16524
16478
  }
16525
- /**
16526
- * Note: [🟢] Code in this file should never be never released in packages that could be imported into browser environment
16527
- */
16479
+ /** Note: [🟢] Code for Node browser-fetch helper [fetchUrlContent](src/commitments/USE_BROWSER/fetchUrlContent.ts) should never be published into packages that could be imported into browser environment */
16528
16480
 
16529
16481
  /**
16530
16482
  * Cached implementation of `run_browser` when it can be resolved.
@@ -28280,10 +28232,8 @@ async function $provideExecutionToolsForNode(options) {
28280
28232
  };
28281
28233
  return tools;
28282
28234
  }
28283
- /**
28284
- * Note: [🟢] Code in this file should never be never released in packages that could be imported into browser environment
28285
- * TODO: [🏓] Unite `xxxForServer` and `xxxForNode` naming
28286
- */
28235
+ /** Note: [🟢] Code for Node execution helper [$provideExecutionToolsForNode](src/execution/utils/$provideExecutionToolsForNode.ts) should never be published into packages that could be imported into browser environment */
28236
+ /** TODO: [🏓] Unite `xxxForServer` and `xxxForNode` naming */
28287
28237
 
28288
28238
  /**
28289
28239
  * Checks if the directory exists
@@ -28633,10 +28583,10 @@ async function saveArchive(filePath, collectionJson, fs) {
28633
28583
  const data = await archive.generateAsync({ type: 'nodebuffer', streamFiles: true });
28634
28584
  await fs.writeFile(filePath, data);
28635
28585
  }
28586
+ /** Note: [🟢] Code for Node archive helper [saveArchive](src/conversion/archive/saveArchive.ts) should never be published into packages that could be imported into browser environment */
28636
28587
  /**
28637
28588
  * TODO: Add metadata to zip
28638
28589
  * TODO: Compression level and other zip options from config
28639
- * Note: [🟢] Code in this file should never be never released in packages that could be imported into browser environment
28640
28590
  */
28641
28591
 
28642
28592
  /**
@@ -28724,10 +28674,8 @@ async function $provideScriptingForNode(options) {
28724
28674
  // TODO: [🔱] Do here auto-installation
28725
28675
  return [new JavascriptExecutionTools({ ...options, functions: getAllCommitmentsToolFunctionsForNode() })];
28726
28676
  }
28727
- /**
28728
- * Note: [🟢] Code in this file should never be never released in packages that could be imported into browser environment
28729
- * TODO: [🏓] Unite `xxxForServer` and `xxxForNode` naming
28730
- */
28677
+ /** Note: [🟢] Code for Node scraper registration helper [$provideScriptingForNode](src/scrapers/_common/register/$provideScriptingForNode.ts) should never be published into packages that could be imported into browser environment */
28678
+ /** TODO: [🏓] Unite `xxxForServer` and `xxxForNode` naming */
28731
28679
 
28732
28680
  /**
28733
28681
  * Initializes `make` command for Promptbook CLI utilities
@@ -28966,11 +28914,11 @@ function $initializeMakeCommand(program) {
28966
28914
  return process.exit(0);
28967
28915
  }));
28968
28916
  }
28917
+ /** Note: [🟡] Code for CLI command [make](src/cli/cli-commands/make.ts) should never be published outside of `@promptbook/cli` */
28969
28918
  /**
28970
28919
  * TODO: [🥃][main] !!3 Allow `ptbk make` without configuring any llm tools
28971
28920
  * TODO: [0] DRY Javascript and typescript - Maybe make ONLY typescript and for javascript just remove types
28972
28921
  * Note: [💞] Ignore a discrepancy between file name and entity name
28973
- * Note: [🟡] Code in this file should never be published outside of `@promptbook/cli`
28974
28922
  * TODO: [🖇] What about symlinks? Maybe flag --follow-symlinks
28975
28923
  */
28976
28924
 
@@ -29104,10 +29052,10 @@ function $initializePrettifyCommand(program) {
29104
29052
  return process.exit(0);
29105
29053
  }));
29106
29054
  }
29055
+ /** Note: [🟡] Code for CLI command [prettify](src/cli/cli-commands/prettify.ts) should never be published outside of `@promptbook/cli` */
29107
29056
  /**
29108
29057
  * TODO: [😶] Unite folder listing
29109
29058
  * Note: [💞] Ignore a discrepancy between file name and entity name
29110
- * Note: [🟡] Code in this file should never be published outside of `@promptbook/cli`
29111
29059
  * TODO: [🖇] What about symlinks? Maybe flag --follow-symlinks
29112
29060
  */
29113
29061
 
@@ -29562,10 +29510,8 @@ async function $getCompiledBook(tools, pipelineSource, options) {
29562
29510
 
29563
29511
  `));
29564
29512
  }
29565
- /**
29566
- * TODO: Write unit test
29567
- * Note: [🟢] Code in this file should never be never released in packages that could be imported into browser environment
29568
- */
29513
+ /** Note: [🟢] Code for Node wizard helper [$getCompiledBook](src/wizard/$getCompiledBook.ts) should never be published into packages that could be imported into browser environment */
29514
+ /** TODO: Write unit test */
29569
29515
 
29570
29516
  /**
29571
29517
  * Run the interactive chatbot in CLI
@@ -29664,10 +29610,10 @@ async function runInteractiveChatbot(options) {
29664
29610
  }
29665
29611
  }
29666
29612
  }
29613
+ /** Note: [🟡] Code for CLI command [runInteractiveChatbot](src/cli/cli-commands/runInteractiveChatbot.ts) should never be published outside of `@promptbook/cli` */
29667
29614
  /**
29668
29615
  * TODO: Saving reports from the chatbot conversation
29669
29616
  * TODO: [⛲️] This is the right place to start implementing INK
29670
- * Note: [🟡] Code in this file should never be published outside of `@promptbook/cli`
29671
29617
  */
29672
29618
 
29673
29619
  /**
@@ -29922,12 +29868,12 @@ function $initializeRunCommand(program) {
29922
29868
  return process.exit(0);
29923
29869
  }));
29924
29870
  }
29871
+ /** Note: [🟡] Code for CLI command [run](src/cli/cli-commands/run.ts) should never be published outside of `@promptbook/cli` */
29925
29872
  /**
29926
29873
  * TODO: !!5 Catch and wrap all errors from CLI
29927
29874
  * TODO: [🧠] Pass `maxExecutionAttempts`, `csvSettings`
29928
29875
  * TODO: [🥃][main] !!3 Allow `ptbk run` without configuring any llm tools
29929
29876
  * Note: [💞] Ignore a discrepancy between file name and entity name
29930
- * Note: [🟡] Code in this file should never be published outside of `@promptbook/cli`
29931
29877
  * TODO: [🖇] What about symlinks? Maybe flag --follow-symlinks
29932
29878
  */
29933
29879
 
@@ -29956,9 +29902,7 @@ async function startAgentServer(options) {
29956
29902
  isVerbose: true,
29957
29903
  });
29958
29904
  }
29959
- /**
29960
- * Note: [🟢] Code in this file should never be never released in packages that could be imported into browser environment
29961
- */
29905
+ /** Note: [🟢] Code for Node server bootstrap [startAgentServer](src/remote-server/startAgentServer.ts) should never be published into packages that could be imported into browser environment */
29962
29906
 
29963
29907
  /**
29964
29908
  * Initializes `start-agents-server` command for Promptbook CLI utilities
@@ -30042,10 +29986,8 @@ function $initializeStartAgentsServerCommand(program) {
30042
29986
  await startAgentServer({ port });
30043
29987
  }));
30044
29988
  }
30045
- /**
30046
- * Note: [💞] Ignore a discrepancy between file name and entity name
30047
- * Note: [🟡] Code in this file should never be published outside of `@promptbook/cli`
30048
- */
29989
+ /** Note: [🟡] Code for CLI command [start-agents-server](src/cli/cli-commands/start-agents-server.ts) should never be published outside of `@promptbook/cli` */
29990
+ /** Note: [💞] Ignore a discrepancy between file name and entity name */
30049
29991
 
30050
29992
  // TODO: [🥺] List running services from REMOTE_SERVER_URLS
30051
29993
  // TODO: [🥺] Import directly from YML
@@ -31251,8 +31193,8 @@ function startRemoteServer(options) {
31251
31193
  },
31252
31194
  };
31253
31195
  }
31196
+ /** Note: [🟢] Code for Node server bootstrap [startRemoteServer](src/remote-server/startRemoteServer.ts) should never be published into packages that could be imported into browser environment */
31254
31197
  /**
31255
-
31256
31198
  * TODO: [🕋] Use here `aboutPromptbookInformation`
31257
31199
  * TODO: [🌡] Add CORS and security - probably via `helmet`
31258
31200
  * TODO: Split this file into multiple functions - handler for each request
@@ -31265,7 +31207,6 @@ function startRemoteServer(options) {
31265
31207
  * TODO: [🃏] Pass here some security token to prevent malitious usage and/or DDoS
31266
31208
  * TODO: [0] Set unavailable models as undefined in `RemoteLlmExecutionTools` NOT throw error here
31267
31209
  * TODO: Allow to constrain anonymous mode for specific models / providers
31268
- * Note: [🟢] Code in this file should never be never released in packages that could be imported into browser environment
31269
31210
  */
31270
31211
 
31271
31212
  /**
@@ -31367,10 +31308,10 @@ function $initializeStartPipelinesServerCommand(program) {
31367
31308
  return await forEver();
31368
31309
  }));
31369
31310
  }
31311
+ /** Note: [🟡] Code for CLI command [start-pipelines-server](src/cli/cli-commands/start-pipelines-server.ts) should never be published outside of `@promptbook/cli` */
31370
31312
  /**
31371
31313
  * TODO: [🕋] Use here `aboutPromptbookInformation`
31372
31314
  * Note: [💞] Ignore a discrepancy between file name and entity name
31373
- * Note: [🟡] Code in this file should never be published outside of `@promptbook/cli`
31374
31315
  */
31375
31316
 
31376
31317
  /**
@@ -31457,10 +31398,10 @@ function $initializeTestCommand(program) {
31457
31398
  return process.exit(0);
31458
31399
  }));
31459
31400
  }
31401
+ /** Note: [🟡] Code for CLI command [test-command](src/cli/cli-commands/test-command.ts) should never be published outside of `@promptbook/cli` */
31460
31402
  /**
31461
31403
  * TODO: [😶] Unite folder listing
31462
31404
  * Note: [💞] Ignore a discrepancy between file name and entity name
31463
- * Note: [🟡] Code in this file should never be published outside of `@promptbook/cli`
31464
31405
  * TODO: [🖇] What about symlinks? Maybe flag --follow-symlinks
31465
31406
  * Note: This is named "test-command.ts" to avoid name collision with jest unit test files
31466
31407
  */
@@ -31518,12 +31459,12 @@ async function promptbookCli() {
31518
31459
  program.commands.forEach($addGlobalOptionsToCommand);
31519
31460
  program.parse(process.argv);
31520
31461
  }
31462
+ /** Note: [🟡] Code for CLI program [promptbookCli](src/cli/promptbookCli.ts) should never be published outside of `@promptbook/cli` */
31521
31463
  /**
31522
31464
  * TODO: [🧠] Maybe `run` command the default, instead of `ptbk run ./foo.book` -> `ptbk ./foo.book`
31523
31465
  * TODO: [🥠] Do not export, its just for CLI script
31524
31466
  * TODO: [🕌] When more functionalities, rename
31525
31467
  * Note: 11:11
31526
- * Note: [🟡] Code in this file should never be published outside of `@promptbook/cli`
31527
31468
  */
31528
31469
 
31529
31470
  /**
@@ -31544,9 +31485,7 @@ async function $runPromptbookCli() {
31544
31485
  }
31545
31486
  await promptbookCli();
31546
31487
  }
31547
- /**
31548
- * Note: [🟡] Code in this file should never be published outside of `@promptbook/cli`
31549
- */
31488
+ /** Note: [🟡] Code for CLI bootstrap [$runPromptbookCli](src/cli/$runPromptbookCli.ts) should never be published outside of `@promptbook/cli` */
31550
31489
 
31551
31490
  /**
31552
31491
  * Note: [🔺] Purpose of this file is to export CLI for production environment
@@ -31560,10 +31499,8 @@ const _CLI = {
31560
31499
  // Note: [🥠]
31561
31500
  _initialize_promptbookCli: $runPromptbookCli,
31562
31501
  };
31563
- /**
31564
- * Note: [💞] Ignore a discrepancy between file name and entity name
31565
- * Note: [🟡] Code in this file should never be published outside of `@promptbook/cli`
31566
- */
31502
+ /** Note: [🟡] Code for CLI entrypoint [main](src/cli/main.ts) should never be published outside of `@promptbook/cli` */
31503
+ /** Note: [💞] Ignore a discrepancy between file name and entity name */
31567
31504
 
31568
31505
  /**
31569
31506
  * Registration of LLM provider metadata
@@ -37889,12 +37826,10 @@ class BoilerplateScraper {
37889
37826
  return knowledge;
37890
37827
  }
37891
37828
  }
37892
- /**
37893
- * TODO: [👣] Converted documents can act as cached items - there is no need to run conversion each time
37894
- * TODO: [🪂] Do it in parallel
37895
- * Note: No need to aggregate usage here, it is done by intercepting the llmTools
37896
- * @@ Note: [🟢] Code in this file should never be never released in packages that could be imported into browser environment
37897
- */
37829
+ /** TODO: [👣] Converted documents can act as cached items - there is no need to run conversion each time */
37830
+ /** TODO: [🪂] Do it in parallel */
37831
+ /** Note: No need to aggregate usage here, it is done by intercepting the llmTools */
37832
+ /** Note: [🟢] Code for Node scraper boilerplate [BoilerplateScraper](src/scrapers/_boilerplate/BoilerplateScraper.ts) should never be published into packages that could be imported into browser environment */
37898
37833
 
37899
37834
  /**
37900
37835
  * Constructor of `BoilerplateScraper`
@@ -38052,11 +37987,11 @@ class DocumentScraper {
38052
37987
  return knowledge;
38053
37988
  }
38054
37989
  }
37990
+ /** Note: [🟢] Code for Node scraper implementation [DocumentScraper](src/scrapers/document/DocumentScraper.ts) should never be published into packages that could be imported into browser environment */
38055
37991
  /**
38056
37992
  * TODO: [👣] Converted documents can act as cached items - there is no need to run conversion each time
38057
37993
  * TODO: [🪂] Do it in parallel 11:11
38058
37994
  * Note: No need to aggregate usage here, it is done by intercepting the llmTools
38059
- * Note: [🟢] Code in this file should never be never released in packages that could be imported into browser environment
38060
37995
  */
38061
37996
 
38062
37997
  /**
@@ -38219,11 +38154,11 @@ class LegacyDocumentScraper {
38219
38154
  return knowledge;
38220
38155
  }
38221
38156
  }
38157
+ /** Note: [🟢] Code for Node scraper implementation [LegacyDocumentScraper](src/scrapers/document-legacy/LegacyDocumentScraper.ts) should never be published into packages that could be imported into browser environment */
38222
38158
  /**
38223
38159
  * TODO: [👣] Converted documents can act as cached items - there is no need to run conversion each time
38224
38160
  * TODO: [🪂] Do it in parallel 11:11
38225
38161
  * Note: No need to aggregate usage here, it is done by intercepting the llmTools
38226
- * Note: [🟢] Code in this file should never be never released in packages that could be imported into browser environment
38227
38162
  */
38228
38163
 
38229
38164
  /**
@@ -38457,12 +38392,12 @@ class MarkitdownScraper {
38457
38392
  return knowledge;
38458
38393
  }
38459
38394
  }
38395
+ /** Note: [🟢] Code for Node scraper implementation [MarkitdownScraper](src/scrapers/markitdown/MarkitdownScraper.ts) should never be published into packages that could be imported into browser environment */
38460
38396
  /**
38461
38397
  * TODO: [🧠][🌜] Export only from `@promptbook/markitdown` or `@promptbook/pdf` NOT both
38462
38398
  * TODO: [👣] Converted documents can act as cached items - there is no need to run conversion each time
38463
38399
  * TODO: [🪂] Do it in parallel
38464
38400
  * Note: No need to aggregate usage here, it is done by intercepting the llmTools
38465
- * Note: [🟢] Code in this file should never be never released in packages that could be imported into browser environment
38466
38401
  */
38467
38402
 
38468
38403
  /**
@@ -38566,11 +38501,11 @@ class PdfScraper {
38566
38501
  throw new NotYetImplementedError('PDF scraping not yet implemented');
38567
38502
  }
38568
38503
  }
38504
+ /** Note: [🟢] Code for Node scraper implementation [PdfScraper](src/scrapers/pdf/PdfScraper.ts) should never be published into packages that could be imported into browser environment */
38569
38505
  /**
38570
38506
  * TODO: [👣] Converted pdf documents can act as cached items - there is no need to run conversion each time
38571
38507
  * TODO: [🪂] Do it in parallel 11:11
38572
38508
  * Note: No need to aggregate usage here, it is done by intercepting the llmTools
38573
- * Note: [🟢] Code in this file should never be never released in packages that could be imported into browser environment
38574
38509
  */
38575
38510
 
38576
38511
  /**
@@ -40447,15 +40382,357 @@ async function findFreshEmojiTag() {
40447
40382
  //========================================/
40448
40383
  // console.info(`[ Done 🤪 Find fresh emoji tag ]`);
40449
40384
  }
40450
- /**
40451
- * Note: [🟡] Code in this file should never be published outside of `@promptbook/cli`
40452
- */
40385
+ /** Note: [🟡] Code for CLI support script [find-fresh-emoji-tags](scripts/find-fresh-emoji-tags/find-fresh-emoji-tags.ts) should never be published outside of `@promptbook/cli` */
40453
40386
 
40454
40387
  var findFreshEmojiTags = /*#__PURE__*/Object.freeze({
40455
40388
  __proto__: null,
40456
40389
  findFreshEmojiTag: findFreshEmojiTag
40457
40390
  });
40458
40391
 
40392
+ /**
40393
+ * Root folders that contain source-like files for scanning.
40394
+ */
40395
+ const SOURCE_ROOTS = ['src', 'apps', 'scripts', 'examples', 'agents', 'other'];
40396
+ /**
40397
+ * File extensions treated as source code.
40398
+ */
40399
+ const SOURCE_FILE_EXTENSIONS = ['.ts', '.tsx', '.js', '.jsx'];
40400
+ /**
40401
+ * Glob patterns that should be ignored when scanning for source files.
40402
+ */
40403
+ const SOURCE_FILE_IGNORE_GLOBS = [
40404
+ '**/node_modules/**',
40405
+ '**/packages/**',
40406
+ '**/.*/**',
40407
+ '**/.git/**',
40408
+ '**/.idea/**',
40409
+ '**/.vscode/**',
40410
+ '**/.promptbook/**',
40411
+ '**/.next/**',
40412
+ '**/.tmp/**',
40413
+ '**/tmp/**',
40414
+ '**/coverage/**',
40415
+ '**/dist/**',
40416
+ '**/build/**',
40417
+ '**/out/**',
40418
+ '**/prompts/**',
40419
+ '**/changelog/**',
40420
+ ];
40421
+ /**
40422
+ * Default maximum line count for source files.
40423
+ */
40424
+ const DEFAULT_MAX_LINE_COUNT = 2000;
40425
+ /**
40426
+ * Per-extension line count limits.
40427
+ */
40428
+ const LINE_COUNT_LIMITS_BY_EXTENSION = {
40429
+ '.ts': 2000,
40430
+ '.tsx': 2000,
40431
+ '.js': 2000,
40432
+ '.jsx': 2000,
40433
+ };
40434
+ /**
40435
+ * Glob patterns that are exempt from line-count checks.
40436
+ */
40437
+ const LINE_COUNT_EXEMPT_GLOBS = ['other/cspell-dictionaries/**/*.txt'];
40438
+ /**
40439
+ * Maximum number of entities before a file is flagged.
40440
+ */
40441
+ const MAX_ENTITIES_PER_FILE = 20;
40442
+ /**
40443
+ * File extensions eligible for entity counting.
40444
+ */
40445
+ const ENTITY_COUNT_EXTENSIONS = ['.ts', '.tsx', '.js', '.jsx'];
40446
+ /**
40447
+ * Markers that identify generated files which should be skipped.
40448
+ */
40449
+ const GENERATED_CODE_MARKERS = [
40450
+ 'WARNING: This code has been generated',
40451
+ 'This code has been generated so that any manual changes will be overwritten',
40452
+ ];
40453
+ /**
40454
+ * Name of the prompts directory.
40455
+ */
40456
+ const PROMPTS_DIR_NAME = 'prompts';
40457
+ /**
40458
+ * Step size used for prompt numbering.
40459
+ */
40460
+ const PROMPT_NUMBER_STEP = 10;
40461
+ /**
40462
+ * Prefix used for generated prompt slugs.
40463
+ */
40464
+ const PROMPT_SLUG_PREFIX = 'refactor';
40465
+ /**
40466
+ * Label used to mark the target file in generated prompts.
40467
+ */
40468
+ const PROMPT_TARGET_LABEL = 'Target file';
40469
+ /**
40470
+ * Maximum length for generated prompt slugs.
40471
+ */
40472
+ const PROMPT_SLUG_MAX_LENGTH = 80;
40473
+ /**
40474
+ * Note: [?] Code in this file should never be published in any package
40475
+ */
40476
+
40477
+ /**
40478
+ * Normalizes a repo-relative path to use forward slashes.
40479
+ *
40480
+ * @private function of findRefactorCandidates
40481
+ */
40482
+ function normalizeRefactorCandidatePath(pathValue) {
40483
+ const normalized = pathValue.replaceAll('\\', '/');
40484
+ return normalized.replace(/^\.\//, '');
40485
+ }
40486
+ /** Note: [🟡] Code for repository script [normalizeRefactorCandidatePath](scripts/find-refactor-candidates/normalizeRefactorCandidatePath.ts) should never be published outside of `@promptbook/cli`*/
40487
+
40488
+ /**
40489
+ * Resolves whether a source file should produce a refactor candidate entry.
40490
+ *
40491
+ * @private function of findRefactorCandidates
40492
+ */
40493
+ async function analyzeSourceFileForRefactorCandidate(options) {
40494
+ const { filePath, lineCountExemptPaths, rootDir } = options;
40495
+ const normalizedAbsolutePath = normalizeAbsolutePath$1(filePath);
40496
+ const content = await readFile(filePath, 'utf-8');
40497
+ if (isGeneratedFile(content)) {
40498
+ return null;
40499
+ }
40500
+ const extension = extname(filePath).toLowerCase();
40501
+ const relativePath = normalizeRefactorCandidatePath(relative(rootDir, filePath));
40502
+ const reasons = [];
40503
+ if (!lineCountExemptPaths.has(normalizedAbsolutePath)) {
40504
+ const lineCount = countLines(content);
40505
+ const maxLines = getMaxLinesForExtension(extension);
40506
+ if (lineCount > maxLines) {
40507
+ reasons.push(`lines ${lineCount}/${maxLines}`);
40508
+ }
40509
+ }
40510
+ if (ENTITY_COUNT_EXTENSIONS.includes(extension)) {
40511
+ const entityCount = countEntities(content, extension, filePath);
40512
+ if (entityCount > MAX_ENTITIES_PER_FILE) {
40513
+ reasons.push(`entities ${entityCount}/${MAX_ENTITIES_PER_FILE}`);
40514
+ }
40515
+ }
40516
+ if (reasons.length === 0) {
40517
+ return null;
40518
+ }
40519
+ return {
40520
+ absolutePath: filePath,
40521
+ relativePath,
40522
+ reasons,
40523
+ };
40524
+ }
40525
+ /**
40526
+ * Determines whether a file is generated by scanning for known markers.
40527
+ *
40528
+ * @private function of analyzeSourceFileForRefactorCandidate
40529
+ */
40530
+ function isGeneratedFile(content) {
40531
+ return GENERATED_CODE_MARKERS.some((marker) => content.includes(marker));
40532
+ }
40533
+ /**
40534
+ * Gets the maximum allowed lines for a file extension.
40535
+ *
40536
+ * @private function of analyzeSourceFileForRefactorCandidate
40537
+ */
40538
+ function getMaxLinesForExtension(extension) {
40539
+ var _a;
40540
+ return (_a = LINE_COUNT_LIMITS_BY_EXTENSION[extension]) !== null && _a !== void 0 ? _a : DEFAULT_MAX_LINE_COUNT;
40541
+ }
40542
+ /**
40543
+ * Counts lines while ignoring a trailing newline.
40544
+ *
40545
+ * @private function of analyzeSourceFileForRefactorCandidate
40546
+ */
40547
+ function countLines(content) {
40548
+ if (content.length === 0) {
40549
+ return 0;
40550
+ }
40551
+ const lines = content.split(/\r?\n/);
40552
+ return lines[lines.length - 1] === '' ? lines.length - 1 : lines.length;
40553
+ }
40554
+ /**
40555
+ * Counts top-level entities in a source file.
40556
+ *
40557
+ * @private function of analyzeSourceFileForRefactorCandidate
40558
+ */
40559
+ function countEntities(content, extension, filePath) {
40560
+ const scriptKind = getScriptKindForExtension(extension);
40561
+ const sourceFile = ts.createSourceFile(filePath, content, ts.ScriptTarget.Latest, false, scriptKind);
40562
+ return countEntitiesInSourceFile(sourceFile);
40563
+ }
40564
+ /**
40565
+ * Counts top-level entities in a parsed TypeScript source file.
40566
+ *
40567
+ * @private function of analyzeSourceFileForRefactorCandidate
40568
+ */
40569
+ function countEntitiesInSourceFile(sourceFile) {
40570
+ let count = 0;
40571
+ // Only count top-level declarations to avoid inflating with members or nested scopes.
40572
+ for (const statement of sourceFile.statements) {
40573
+ if (ts.isFunctionDeclaration(statement) ||
40574
+ ts.isClassDeclaration(statement) ||
40575
+ ts.isInterfaceDeclaration(statement) ||
40576
+ ts.isTypeAliasDeclaration(statement) ||
40577
+ ts.isEnumDeclaration(statement) ||
40578
+ ts.isModuleDeclaration(statement)) {
40579
+ count += 1;
40580
+ continue;
40581
+ }
40582
+ if (ts.isVariableStatement(statement)) {
40583
+ for (const declaration of statement.declarationList.declarations) {
40584
+ const initializer = declaration.initializer;
40585
+ if (initializer &&
40586
+ (ts.isArrowFunction(initializer) ||
40587
+ ts.isFunctionExpression(initializer) ||
40588
+ ts.isClassExpression(initializer))) {
40589
+ count += 1;
40590
+ }
40591
+ }
40592
+ }
40593
+ }
40594
+ return count;
40595
+ }
40596
+ /**
40597
+ * Resolves the script kind for a source file extension.
40598
+ *
40599
+ * @private function of analyzeSourceFileForRefactorCandidate
40600
+ */
40601
+ function getScriptKindForExtension(extension) {
40602
+ if (extension === '.tsx') {
40603
+ return ts.ScriptKind.TSX;
40604
+ }
40605
+ if (extension === '.jsx') {
40606
+ return ts.ScriptKind.JSX;
40607
+ }
40608
+ if (extension === '.js') {
40609
+ return ts.ScriptKind.JS;
40610
+ }
40611
+ return ts.ScriptKind.TS;
40612
+ }
40613
+ /**
40614
+ * Normalizes an absolute path for consistent comparisons.
40615
+ *
40616
+ * @private function of analyzeSourceFileForRefactorCandidate
40617
+ */
40618
+ function normalizeAbsolutePath$1(pathValue) {
40619
+ const normalized = resolve(pathValue);
40620
+ return process.platform === 'win32' ? normalized.toLowerCase() : normalized;
40621
+ }
40622
+ /** Note: [🟡] Code for repository script [analyzeSourceFileForRefactorCandidate](scripts/find-refactor-candidates/analyzeSourceFileForRefactorCandidate.ts) should never be published outside of `@promptbook/cli` */
40623
+
40624
+ /**
40625
+ * Scans the repository and returns all files that qualify as refactor candidates.
40626
+ *
40627
+ * @private function of findRefactorCandidates
40628
+ */
40629
+ async function findRefactorCandidatesInProject(rootDir) {
40630
+ const lineCountExemptPaths = await buildExemptPathSet(rootDir, LINE_COUNT_EXEMPT_GLOBS);
40631
+ const sourceFiles = await listSourceFiles(rootDir);
40632
+ const candidates = [];
40633
+ for (const filePath of sourceFiles) {
40634
+ const candidate = await analyzeSourceFileForRefactorCandidate({
40635
+ filePath,
40636
+ lineCountExemptPaths,
40637
+ rootDir,
40638
+ });
40639
+ if (candidate) {
40640
+ candidates.push(candidate);
40641
+ }
40642
+ }
40643
+ return candidates;
40644
+ }
40645
+ /**
40646
+ * Lists all source files to scan based on configured roots and extensions.
40647
+ *
40648
+ * @private function of findRefactorCandidatesInProject
40649
+ */
40650
+ async function listSourceFiles(rootDir) {
40651
+ const extensions = SOURCE_FILE_EXTENSIONS.map((extension) => extension.replace(/^\./, '')).join(',');
40652
+ const extensionGlob = `{${extensions}}`;
40653
+ const patterns = [...SOURCE_ROOTS.map((root) => `${root}/**/*.${extensionGlob}`), `*.${extensionGlob}`];
40654
+ const files = new Set();
40655
+ for (const pattern of patterns) {
40656
+ const matches = await glob(pattern, {
40657
+ cwd: rootDir,
40658
+ ignore: SOURCE_FILE_IGNORE_GLOBS,
40659
+ nodir: true,
40660
+ absolute: true,
40661
+ });
40662
+ for (const match of matches) {
40663
+ files.add(match);
40664
+ }
40665
+ }
40666
+ return Array.from(files).sort();
40667
+ }
40668
+ /**
40669
+ * Builds a set of normalized absolute paths exempt from line-count checks.
40670
+ *
40671
+ * @private function of findRefactorCandidatesInProject
40672
+ */
40673
+ async function buildExemptPathSet(rootDir, patterns) {
40674
+ const exemptPaths = new Set();
40675
+ for (const pattern of patterns) {
40676
+ const matches = await glob(pattern, {
40677
+ cwd: rootDir,
40678
+ ignore: SOURCE_FILE_IGNORE_GLOBS,
40679
+ nodir: true,
40680
+ absolute: true,
40681
+ });
40682
+ for (const match of matches) {
40683
+ exemptPaths.add(normalizeAbsolutePath(match));
40684
+ }
40685
+ }
40686
+ return exemptPaths;
40687
+ }
40688
+ /**
40689
+ * Normalizes an absolute path for consistent comparisons.
40690
+ *
40691
+ * @private function of findRefactorCandidatesInProject
40692
+ */
40693
+ function normalizeAbsolutePath(pathValue) {
40694
+ const normalized = resolve(pathValue);
40695
+ return process.platform === 'win32' ? normalized.toLowerCase() : normalized;
40696
+ }
40697
+ /** Note: [🟡] Code for repository script [findRefactorCandidatesInProject](scripts/find-refactor-candidates/findRefactorCandidatesInProject.ts) should never be published outside of `@promptbook/cli` */
40698
+
40699
+ /**
40700
+ * Collects all repo-relative target paths already referenced in prompts.
40701
+ *
40702
+ * @private function of findRefactorCandidates
40703
+ */
40704
+ async function loadExistingPromptTargets(promptsDir) {
40705
+ var _a;
40706
+ if (!existsSync(promptsDir)) {
40707
+ return new Set();
40708
+ }
40709
+ const promptFiles = await glob('**/*.md', {
40710
+ cwd: promptsDir,
40711
+ nodir: true,
40712
+ });
40713
+ const targets = new Set();
40714
+ const targetRegex = new RegExp(`^\\s*-\\s+${escapeRegExp(PROMPT_TARGET_LABEL)}:\\s+\\\`(?<path>[^\\\`]+)\\\``, 'gm');
40715
+ for (const promptFile of promptFiles) {
40716
+ const content = await readFile(join(promptsDir, promptFile), 'utf-8');
40717
+ for (const match of content.matchAll(targetRegex)) {
40718
+ const captured = (_a = match.groups) === null || _a === void 0 ? void 0 : _a.path;
40719
+ if (captured) {
40720
+ targets.add(normalizeRefactorCandidatePath(captured));
40721
+ }
40722
+ }
40723
+ }
40724
+ return targets;
40725
+ }
40726
+ /**
40727
+ * Escapes a string for use in a regular expression literal.
40728
+ *
40729
+ * @private function of loadExistingPromptTargets
40730
+ */
40731
+ function escapeRegExp(value) {
40732
+ return value.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
40733
+ }
40734
+ /** Note: [🟡] Code for repository script [loadExistingPromptTargets](scripts/find-refactor-candidates/loadExistingPromptTargets.ts) should never be published outside of `@promptbook/cli` */
40735
+
40459
40736
  /**
40460
40737
  * Calculates the next available prompt numbering sequence for a month.
40461
40738
  */
@@ -40596,180 +40873,114 @@ var promptEmojiTags = /*#__PURE__*/Object.freeze({
40596
40873
  });
40597
40874
 
40598
40875
  /**
40599
- * Root folders that contain source-like files for scanning.
40600
- */
40601
- const SOURCE_ROOTS = ['src', 'apps', 'scripts', 'examples', 'agents', 'other'];
40602
- /**
40603
- * File extensions treated as source code.
40604
- */
40605
- const SOURCE_FILE_EXTENSIONS = ['.ts', '.tsx', '.js', '.jsx'];
40606
- /**
40607
- * Glob patterns that should be ignored when scanning for source files.
40608
- */
40609
- const SOURCE_FILE_IGNORE_GLOBS = [
40610
- '**/node_modules/**',
40611
- '**/packages/**',
40612
- '**/.*/**',
40613
- '**/.git/**',
40614
- '**/.idea/**',
40615
- '**/.vscode/**',
40616
- '**/.promptbook/**',
40617
- '**/.next/**',
40618
- '**/.tmp/**',
40619
- '**/tmp/**',
40620
- '**/coverage/**',
40621
- '**/dist/**',
40622
- '**/build/**',
40623
- '**/out/**',
40624
- '**/prompts/**',
40625
- '**/changelog/**',
40626
- ];
40627
- /**
40628
- * Default maximum line count for source files.
40629
- */
40630
- const DEFAULT_MAX_LINE_COUNT = 2000;
40631
- /**
40632
- * Per-extension line count limits.
40633
- */
40634
- const LINE_COUNT_LIMITS_BY_EXTENSION = {
40635
- '.ts': 2000,
40636
- '.tsx': 2000,
40637
- '.js': 2000,
40638
- '.jsx': 2000,
40639
- };
40640
- /**
40641
- * Glob patterns that are exempt from line-count checks.
40642
- */
40643
- const LINE_COUNT_EXEMPT_GLOBS = ['other/cspell-dictionaries/**/*.txt'];
40644
- /**
40645
- * Maximum number of entities before a file is flagged.
40646
- */
40647
- const MAX_ENTITIES_PER_FILE = 20;
40648
- /**
40649
- * File extensions eligible for entity counting.
40650
- */
40651
- const ENTITY_COUNT_EXTENSIONS = ['.ts', '.tsx', '.js', '.jsx'];
40652
- /**
40653
- * Markers that identify generated files which should be skipped.
40654
- */
40655
- const GENERATED_CODE_MARKERS = [
40656
- 'WARNING: This code has been generated',
40657
- 'This code has been generated so that any manual changes will be overwritten',
40658
- ];
40659
- /**
40660
- * Name of the prompts directory.
40661
- */
40662
- const PROMPTS_DIR_NAME = 'prompts';
40663
- /**
40664
- * Step size used for prompt numbering.
40665
- */
40666
- const PROMPT_NUMBER_STEP = 10;
40667
- /**
40668
- * Prefix used for generated prompt slugs.
40669
- */
40670
- const PROMPT_SLUG_PREFIX = 'refactor';
40671
- /**
40672
- * Label used to mark the target file in generated prompts.
40673
- */
40674
- const PROMPT_TARGET_LABEL = 'Target file';
40675
- /**
40676
- * Maximum length for generated prompt slugs.
40677
- */
40678
- const PROMPT_SLUG_MAX_LENGTH = 80;
40679
- /**
40680
- * Note: [?] Code in this file should never be published in any package
40876
+ * Builds prompt content for a refactor candidate.
40877
+ *
40878
+ * @private function of findRefactorCandidates
40681
40879
  */
40880
+ function buildPromptContent(candidate, emojiTag) {
40881
+ const fileName = basename(candidate.relativePath);
40882
+ const guidanceLines = buildPromptGuidance(candidate);
40883
+ return spaceTrim$1((block) => `
40682
40884
 
40683
- if (require.main === module) {
40684
- findRefactorCandidates()
40685
- .catch((error) => {
40686
- assertsError(error);
40687
- console.error(colors.bgRed(`${error.name} in ${basename(__filename)}`));
40688
- console.error(colors.red(error.stack || error.message));
40689
- process.exit(1);
40690
- })
40691
- .then(() => {
40692
- process.exit(0);
40693
- });
40885
+ [ ]
40886
+
40887
+ ${emojiTag} Refactor [\`${fileName}\` file](${candidate.relativePath})
40888
+
40889
+ ${block(guidanceLines.join('\n'))}
40890
+ `);
40694
40891
  }
40695
40892
  /**
40696
- * Initializes environment for this script.
40893
+ * Builds the refactor guidance section for a prompt.
40697
40894
  *
40698
- * @private utility for `findRefactorCandidates`
40895
+ * @private function of buildPromptContent
40699
40896
  */
40700
- function initializeFindRefactorCandidatesRun() {
40701
- dotenv.config({ path: '.env' });
40897
+ function buildPromptGuidance(candidate) {
40898
+ const guidance = [
40899
+ /* '- @@@' <- TODO: Should be this here? */
40900
+ ];
40901
+ const counts = extractReasonCounts(candidate.reasons);
40902
+ const densityNote = buildDensityNote(counts);
40903
+ if (densityNote) {
40904
+ guidance.push(`- ${densityNote}`);
40905
+ }
40906
+ if (counts.lineCount !== null && counts.maxLines !== null) {
40907
+ guidance.push(`- The file contains excessive lines of code (${counts.lineCount} lines)`, ` - Keep in mind the Single Responsibility Principle (SRP)`, ` - Consider breaking it down into smaller, focused modules or components.`);
40908
+ }
40909
+ if (counts.entityCount !== null && counts.maxEntities !== null) {
40910
+ guidance.push(`- The file defines too many responsibilities (${counts.entityCount} in single file)`, ` - Keep in mind the Single Responsibility Principle (SRP)`, ` - Consider breaking it down into smaller, focused modules or components.`);
40911
+ }
40912
+ guidance.push('- Purpose of this refactoring is to improve code maintainability and readability.', '- Look at the internal structure, the usage and also surrounding code to understand how to best refactor this file.', '- Consider breaking down large functions into smaller, more manageable ones, removing any redundant code, and ensuring that the file adheres to the project coding standards.', '- After the refactoring, ensure that (1) `npm run test-name-discrepancies` and (2) `npm run test-package-generation` are passing successfully.', ' 1. All the things you have moved to new files should correspond the thing in the file with the file name, for example `MyComponent.tsx` should export `MyComponent`.', ' 2. All the things you have moved to new files but are private things to the outside world should have `@private function of TheMainThing` JSDoc comment.', '- Keep in mind DRY *(Do not repeat yourself)* and SOLID principles while refactoring.', '- **Do not change the external behavior** of the code. Focus solely on improving the internal structure and organization of the code.', '- Before you start refactoring, make sure to read the code carefully and understand its current structure and functionality. Do a analysis of the current functionality before you start.');
40913
+ return guidance;
40702
40914
  }
40703
40915
  /**
40704
- * Orchestrates scanning for refactor candidates and generating prompts.
40916
+ * Extracts line and entity counts from refactor reasons.
40705
40917
  *
40706
- * @public exported from `@promptbook/cli`
40918
+ * @private function of buildPromptContent
40707
40919
  */
40708
- async function findRefactorCandidates() {
40709
- initializeFindRefactorCandidatesRun();
40710
- console.info(colors.cyan('?? Find refactor candidates'));
40711
- const rootDir = process.cwd();
40712
- const promptsDir = join(rootDir, PROMPTS_DIR_NAME);
40713
- const existingTargets = await loadExistingPromptTargets(promptsDir);
40714
- const lineCountExemptPaths = await buildExemptPathSet(rootDir, LINE_COUNT_EXEMPT_GLOBS);
40715
- const sourceFiles = await listSourceFiles(rootDir);
40716
- const candidates = [];
40717
- for (const filePath of sourceFiles) {
40718
- const normalizedPath = normalizeAbsolutePath(filePath);
40719
- const content = await readFile(filePath, 'utf-8');
40720
- if (isGeneratedFile(content)) {
40920
+ function extractReasonCounts(reasons) {
40921
+ let lineCount = null;
40922
+ let maxLines = null;
40923
+ let entityCount = null;
40924
+ let maxEntities = null;
40925
+ for (const reason of reasons) {
40926
+ const lineMatch = reason.match(/lines\s+(?<count>\d+)\/(?<max>\d+)/i);
40927
+ if (lineMatch === null || lineMatch === void 0 ? void 0 : lineMatch.groups) {
40928
+ lineCount = Number(lineMatch.groups.count);
40929
+ maxLines = Number(lineMatch.groups.max);
40721
40930
  continue;
40722
40931
  }
40723
- const extension = extname(filePath).toLowerCase();
40724
- const relativePath = normalizeRelativePath(relative(rootDir, filePath));
40725
- const reasons = [];
40726
- if (!lineCountExemptPaths.has(normalizedPath)) {
40727
- const lineCount = countLines(content);
40728
- const maxLines = getMaxLinesForExtension(extension);
40729
- if (lineCount > maxLines) {
40730
- reasons.push(`lines ${lineCount}/${maxLines}`);
40731
- }
40732
- }
40733
- if (ENTITY_COUNT_EXTENSIONS.includes(extension)) {
40734
- const entityCount = countEntities(content, extension, filePath);
40735
- if (entityCount > MAX_ENTITIES_PER_FILE) {
40736
- reasons.push(`entities ${entityCount}/${MAX_ENTITIES_PER_FILE}`);
40737
- }
40738
- }
40739
- if (reasons.length > 0) {
40740
- candidates.push({
40741
- absolutePath: filePath,
40742
- relativePath,
40743
- reasons,
40744
- });
40932
+ const entityMatch = reason.match(/entities\s+(?<count>\d+)\/(?<max>\d+)/i);
40933
+ if (entityMatch === null || entityMatch === void 0 ? void 0 : entityMatch.groups) {
40934
+ entityCount = Number(entityMatch.groups.count);
40935
+ maxEntities = Number(entityMatch.groups.max);
40745
40936
  }
40746
40937
  }
40747
- if (candidates.length === 0) {
40748
- console.info(colors.green('No refactor candidates found.'));
40749
- return;
40938
+ return {
40939
+ lineCount,
40940
+ maxLines,
40941
+ entityCount,
40942
+ maxEntities,
40943
+ };
40944
+ }
40945
+ /**
40946
+ * Builds a summary note about file density based on counts.
40947
+ *
40948
+ * @private function of buildPromptContent
40949
+ */
40950
+ function buildDensityNote(counts) {
40951
+ if (counts.lineCount !== null && counts.entityCount !== null) {
40952
+ return 'The file mixes multiple concerns, making it harder to follow.';
40750
40953
  }
40751
- for (const candidate of candidates) {
40752
- console.info(colors.yellow(`${candidate.relativePath} <- ${candidate.reasons.join('; ')}`));
40954
+ if (counts.lineCount !== null) {
40955
+ return 'The file is large enough that it is hard to follow.';
40753
40956
  }
40754
- const candidatesToWrite = candidates.filter((candidate) => !existingTargets.has(candidate.relativePath));
40755
- const alreadyTracked = candidates.length - candidatesToWrite.length;
40756
- if (candidatesToWrite.length === 0) {
40757
- console.info(colors.green('All candidates already have prompts.'));
40758
- return;
40957
+ if (counts.entityCount !== null) {
40958
+ return 'The file is dense enough that it is hard to follow.';
40759
40959
  }
40960
+ return null;
40961
+ }
40962
+ /** Note: [🟡] Code for repository script [buildPromptContent](scripts/find-refactor-candidates/buildPromptContent.ts) should never be published outside of `@promptbook/cli` */
40963
+
40964
+ /**
40965
+ * Creates prompt files for each refactor candidate and returns written filenames.
40966
+ *
40967
+ * @private function of findRefactorCandidates
40968
+ */
40969
+ async function writeRefactorCandidatePrompts(options) {
40970
+ const { candidates, promptsDir, rootDir } = options;
40760
40971
  const promptNumbering = await getPromptNumbering({
40761
40972
  promptsDir,
40762
40973
  step: PROMPT_NUMBER_STEP,
40763
40974
  ignoreGlobs: ['**/node_modules/**'],
40764
40975
  });
40765
40976
  const { selectedEmojis } = await getFreshPromptEmojiTags({
40766
- count: candidatesToWrite.length,
40977
+ count: candidates.length,
40767
40978
  rootDir,
40768
40979
  tagPrefix: '🧹',
40769
40980
  });
40770
40981
  await mkdir(promptsDir, { recursive: true });
40771
40982
  const createdPrompts = [];
40772
- for (const [index, candidate] of candidatesToWrite.entries()) {
40983
+ for (const [index, candidate] of candidates.entries()) {
40773
40984
  const slug = buildPromptSlug(candidate.relativePath);
40774
40985
  const number = promptNumbering.startNumber + index * promptNumbering.step;
40775
40986
  const filename = buildPromptFilename(promptNumbering.datePrefix, number, slug);
@@ -40783,96 +40994,12 @@ async function findRefactorCandidates() {
40783
40994
  await writeFile(promptPath, promptContent, 'utf-8');
40784
40995
  createdPrompts.push(filename);
40785
40996
  }
40786
- console.info(colors.green(`Created ${createdPrompts.length} prompt(s) in ${PROMPTS_DIR_NAME}.`));
40787
- if (alreadyTracked > 0) {
40788
- console.info(colors.gray(`Skipped ${alreadyTracked} candidate(s) with existing prompts.`));
40789
- }
40790
- }
40791
- /**
40792
- * Builds prompt content for a refactor candidate.
40793
- *
40794
- * @param candidate - Candidate metadata to include.
40795
- * @param emojiTag - Unique emoji tag for the prompt title.
40796
- */
40797
- function buildPromptContent(candidate, emojiTag) {
40798
- const fileName = basename(candidate.relativePath);
40799
- const guidanceLines = buildPromptGuidance(candidate);
40800
- return spaceTrim$1((block) => `
40801
-
40802
- [ ]
40803
-
40804
- ${emojiTag} Refactor [\`${fileName}\` file](${candidate.relativePath})
40805
-
40806
- ${block(guidanceLines.join('\n'))}
40807
- `);
40808
- }
40809
- /**
40810
- * Builds the refactor guidance section for a prompt.
40811
- */
40812
- function buildPromptGuidance(candidate) {
40813
- const guidance = [
40814
- /* '- @@@' <- TODO: Should be this here? */
40815
- ];
40816
- const counts = extractReasonCounts(candidate.reasons);
40817
- const densityNote = buildDensityNote(counts);
40818
- if (densityNote) {
40819
- guidance.push(`- ${densityNote}`);
40820
- }
40821
- if (counts.lineCount !== null && counts.maxLines !== null) {
40822
- guidance.push(`- The file contains excessive lines of code (${counts.lineCount} lines)`, ` - Keep in mind the Single Responsibility Principle (SRP)`, ` - Consider breaking it down into smaller, focused modules or components.`);
40823
- }
40824
- if (counts.entityCount !== null && counts.maxEntities !== null) {
40825
- guidance.push(`- The file defines too many responsibilities (${counts.entityCount} in single file)`, ` - Keep in mind the Single Responsibility Principle (SRP)`, ` - Consider breaking it down into smaller, focused modules or components.`);
40826
- }
40827
- guidance.push('- Purpose of this refactoring is to improve code maintainability and readability.', '- Look at the internal structure, the usage and also surrounding code to understand how to best refactor this file.', '- Consider breaking down large functions into smaller, more manageable ones, removing any redundant code, and ensuring that the file adheres to the project coding standards.', '- After the refactoring, ensure that (1) `npm run test-name-discrepancies` and (2) `npm run test-package-generation` are passing successfully.', ' 1. All the things you have moved to new files should correspond the thing in the file with the file name, for example `MyComponent.tsx` should export `MyComponent`.', ' 2. All the things you have moved to new files but are private things to the outside world should have `@private function of TheMainThing` JSDoc comment.', '- Keep in mind DRY *(Do not repeat yourself)* and SOLID principles while refactoring.', '- **Do not change the external behavior** of the code. Focus solely on improving the internal structure and organization of the code.', '- Before you start refactoring, make sure to read the code carefully and understand its current structure and functionality. Do a analysis of the current functionality before you start.');
40828
- // <- TODO: Leverage `spaceTrim` here
40829
- return guidance;
40830
- }
40831
- /**
40832
- * Extracts line and entity counts from refactor reasons.
40833
- */
40834
- function extractReasonCounts(reasons) {
40835
- let lineCount = null;
40836
- let maxLines = null;
40837
- let entityCount = null;
40838
- let maxEntities = null;
40839
- for (const reason of reasons) {
40840
- const lineMatch = reason.match(/lines\s+(?<count>\d+)\/(?<max>\d+)/i);
40841
- if (lineMatch === null || lineMatch === void 0 ? void 0 : lineMatch.groups) {
40842
- lineCount = Number(lineMatch.groups.count);
40843
- maxLines = Number(lineMatch.groups.max);
40844
- continue;
40845
- }
40846
- const entityMatch = reason.match(/entities\s+(?<count>\d+)\/(?<max>\d+)/i);
40847
- if (entityMatch === null || entityMatch === void 0 ? void 0 : entityMatch.groups) {
40848
- entityCount = Number(entityMatch.groups.count);
40849
- maxEntities = Number(entityMatch.groups.max);
40850
- }
40851
- }
40852
- return {
40853
- lineCount,
40854
- maxLines,
40855
- entityCount,
40856
- maxEntities,
40857
- };
40858
- }
40859
- /**
40860
- * Builds a summary note about file density based on counts.
40861
- */
40862
- function buildDensityNote(counts) {
40863
- if (counts.lineCount !== null && counts.entityCount !== null) {
40864
- return 'The file mixes multiple concerns, making it harder to follow.';
40865
- }
40866
- if (counts.lineCount !== null) {
40867
- return 'The file is large enough that it is hard to follow.';
40868
- }
40869
- if (counts.entityCount !== null) {
40870
- return 'The file is dense enough that it is hard to follow.';
40871
- }
40872
- return null;
40997
+ return createdPrompts;
40873
40998
  }
40874
40999
  /**
40875
41000
  * Creates the prompt slug from a file path while keeping it readable.
41001
+ *
41002
+ * @private function of writeRefactorCandidatePrompts
40876
41003
  */
40877
41004
  function buildPromptSlug(relativePath) {
40878
41005
  const prefixed = `${PROMPT_SLUG_PREFIX}-${normalizeToKebabCase(relativePath) || 'file'}`;
@@ -40884,178 +41011,83 @@ function buildPromptSlug(relativePath) {
40884
41011
  return `${trimmed}-${hash}`;
40885
41012
  }
40886
41013
  /**
40887
- * Collects all repo-relative target paths already referenced in prompts.
40888
- */
40889
- async function loadExistingPromptTargets(promptsDir) {
40890
- var _a;
40891
- if (!existsSync(promptsDir)) {
40892
- return new Set();
40893
- }
40894
- const promptFiles = await glob('**/*.md', {
40895
- cwd: promptsDir,
40896
- nodir: true,
40897
- });
40898
- const targets = new Set();
40899
- const targetRegex = new RegExp(`^\\s*-\\s+${escapeRegExp(PROMPT_TARGET_LABEL)}:\\s+\\\`(?<path>[^\\\`]+)\\\``, 'gm');
40900
- for (const promptFile of promptFiles) {
40901
- const content = await readFile(join(promptsDir, promptFile), 'utf-8');
40902
- for (const match of content.matchAll(targetRegex)) {
40903
- const captured = (_a = match.groups) === null || _a === void 0 ? void 0 : _a.path;
40904
- if (captured) {
40905
- targets.add(normalizeRelativePath(captured));
40906
- }
40907
- }
40908
- }
40909
- return targets;
40910
- }
40911
- /**
40912
- * Lists all source files to scan based on configured roots and extensions.
40913
- */
40914
- async function listSourceFiles(rootDir) {
40915
- const extensions = SOURCE_FILE_EXTENSIONS.map((extension) => extension.replace(/^\./, '')).join(',');
40916
- const extensionGlob = `{${extensions}}`;
40917
- const patterns = [...SOURCE_ROOTS.map((root) => `${root}/**/*.${extensionGlob}`), `*.${extensionGlob}`];
40918
- const files = new Set();
40919
- for (const pattern of patterns) {
40920
- const matches = await glob(pattern, {
40921
- cwd: rootDir,
40922
- ignore: SOURCE_FILE_IGNORE_GLOBS,
40923
- nodir: true,
40924
- absolute: true,
40925
- });
40926
- for (const match of matches) {
40927
- files.add(match);
40928
- }
40929
- }
40930
- return Array.from(files).sort();
40931
- }
40932
- /**
40933
- * Builds a set of normalized paths exempt from line-count checks.
40934
- */
40935
- async function buildExemptPathSet(rootDir, patterns) {
40936
- const exemptPaths = new Set();
40937
- for (const pattern of patterns) {
40938
- const matches = await glob(pattern, {
40939
- cwd: rootDir,
40940
- ignore: SOURCE_FILE_IGNORE_GLOBS,
40941
- nodir: true,
40942
- absolute: true,
40943
- });
40944
- for (const match of matches) {
40945
- exemptPaths.add(normalizeAbsolutePath(match));
40946
- }
40947
- }
40948
- return exemptPaths;
40949
- }
40950
- /**
40951
- * Determines whether a file is generated by scanning for known markers.
40952
- */
40953
- function isGeneratedFile(content) {
40954
- return GENERATED_CODE_MARKERS.some((marker) => content.includes(marker));
40955
- }
40956
- /**
40957
- * Gets the maximum allowed lines for a file extension.
40958
- */
40959
- function getMaxLinesForExtension(extension) {
40960
- var _a;
40961
- return (_a = LINE_COUNT_LIMITS_BY_EXTENSION[extension]) !== null && _a !== void 0 ? _a : DEFAULT_MAX_LINE_COUNT;
40962
- }
40963
- /**
40964
- * Counts lines while ignoring a trailing newline.
41014
+ * Creates a short stable hash used for trimmed slugs.
41015
+ *
41016
+ * @private function of writeRefactorCandidatePrompts
40965
41017
  */
40966
- function countLines(content) {
40967
- if (content.length === 0) {
40968
- return 0;
41018
+ function hashString(value) {
41019
+ let hash = 5381;
41020
+ for (let i = 0; i < value.length; i += 1) {
41021
+ hash = (hash << 5) + hash + value.charCodeAt(i);
40969
41022
  }
40970
- const lines = content.split(/\r?\n/);
40971
- return lines[lines.length - 1] === '' ? lines.length - 1 : lines.length;
41023
+ return (hash >>> 0).toString(36);
40972
41024
  }
40973
- /**
40974
- * Counts top-level entities in a source file.
40975
- */
40976
- function countEntities(content, extension, filePath) {
40977
- const scriptKind = getScriptKindForExtension(extension);
40978
- const sourceFile = ts.createSourceFile(filePath, content, ts.ScriptTarget.Latest, false, scriptKind);
40979
- return countEntitiesInSourceFile(sourceFile);
41025
+ /** Note: [🟡] Code for repository script [writeRefactorCandidatePrompts](scripts/find-refactor-candidates/writeRefactorCandidatePrompts.ts) should never be published outside of `@promptbook/cli` */
41026
+
41027
+ if (require.main === module) {
41028
+ findRefactorCandidates()
41029
+ .catch((error) => {
41030
+ assertsError(error);
41031
+ console.error(colors.bgRed(`${error.name} in ${basename(__filename)}`));
41032
+ console.error(colors.red(error.stack || error.message));
41033
+ process.exit(1);
41034
+ })
41035
+ .then(() => {
41036
+ process.exit(0);
41037
+ });
40980
41038
  }
40981
41039
  /**
40982
- * Counts top-level entities in a parsed TypeScript source file.
41040
+ * Initializes environment for this script.
41041
+ *
41042
+ * @private utility for `findRefactorCandidates`
40983
41043
  */
40984
- function countEntitiesInSourceFile(sourceFile) {
40985
- let count = 0;
40986
- // Only count top-level declarations to avoid inflating with members or nested scopes.
40987
- for (const statement of sourceFile.statements) {
40988
- if (ts.isFunctionDeclaration(statement) ||
40989
- ts.isClassDeclaration(statement) ||
40990
- ts.isInterfaceDeclaration(statement) ||
40991
- ts.isTypeAliasDeclaration(statement) ||
40992
- ts.isEnumDeclaration(statement) ||
40993
- ts.isModuleDeclaration(statement)) {
40994
- count += 1;
40995
- continue;
40996
- }
40997
- if (ts.isVariableStatement(statement)) {
40998
- for (const declaration of statement.declarationList.declarations) {
40999
- const initializer = declaration.initializer;
41000
- if (initializer &&
41001
- (ts.isArrowFunction(initializer) ||
41002
- ts.isFunctionExpression(initializer) ||
41003
- ts.isClassExpression(initializer))) {
41004
- count += 1;
41005
- }
41006
- }
41007
- }
41008
- }
41009
- return count;
41044
+ function initializeFindRefactorCandidatesRun() {
41045
+ dotenv.config({ path: '.env' });
41010
41046
  }
41011
41047
  /**
41012
- * Resolves the script kind for a source file extension.
41048
+ * Orchestrates scanning for refactor candidates and generating prompts.
41049
+ *
41050
+ * @public exported from `@promptbook/cli`
41013
41051
  */
41014
- function getScriptKindForExtension(extension) {
41015
- if (extension === '.tsx') {
41016
- return ts.ScriptKind.TSX;
41052
+ async function findRefactorCandidates() {
41053
+ initializeFindRefactorCandidatesRun();
41054
+ console.info(colors.cyan('?? Find refactor candidates'));
41055
+ const rootDir = process.cwd();
41056
+ const promptsDir = join(rootDir, PROMPTS_DIR_NAME);
41057
+ const existingTargets = await loadExistingPromptTargets(promptsDir);
41058
+ const candidates = await findRefactorCandidatesInProject(rootDir);
41059
+ if (candidates.length === 0) {
41060
+ console.info(colors.green('No refactor candidates found.'));
41061
+ return;
41017
41062
  }
41018
- if (extension === '.jsx') {
41019
- return ts.ScriptKind.JSX;
41063
+ logRefactorCandidates(candidates);
41064
+ const candidatesToWrite = candidates.filter((candidate) => !existingTargets.has(candidate.relativePath));
41065
+ const alreadyTracked = candidates.length - candidatesToWrite.length;
41066
+ if (candidatesToWrite.length === 0) {
41067
+ console.info(colors.green('All candidates already have prompts.'));
41068
+ return;
41020
41069
  }
41021
- if (extension === '.js') {
41022
- return ts.ScriptKind.JS;
41070
+ const createdPrompts = await writeRefactorCandidatePrompts({
41071
+ candidates: candidatesToWrite,
41072
+ rootDir,
41073
+ promptsDir,
41074
+ });
41075
+ console.info(colors.green(`Created ${createdPrompts.length} prompt(s) in ${PROMPTS_DIR_NAME}.`));
41076
+ if (alreadyTracked > 0) {
41077
+ console.info(colors.gray(`Skipped ${alreadyTracked} candidate(s) with existing prompts.`));
41023
41078
  }
41024
- return ts.ScriptKind.TS;
41025
- }
41026
- /**
41027
- * Normalizes a path to use forward slashes.
41028
- */
41029
- function normalizeRelativePath(pathValue) {
41030
- const normalized = pathValue.replace(/\\/g, '/');
41031
- return normalized.replace(/^\.\//, '');
41032
- }
41033
- /**
41034
- * Normalizes an absolute path for consistent comparisons.
41035
- */
41036
- function normalizeAbsolutePath(pathValue) {
41037
- const normalized = resolve(pathValue);
41038
- return process.platform === 'win32' ? normalized.toLowerCase() : normalized;
41039
41079
  }
41040
41080
  /**
41041
- * Escapes a string for use in a regular expression literal.
41042
- */
41043
- function escapeRegExp(value) {
41044
- return value.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
41045
- }
41046
- /**
41047
- * Creates a short stable hash used for trimmed slugs.
41081
+ * Prints discovered refactor candidates with their reasons.
41082
+ *
41083
+ * @private function of findRefactorCandidates
41048
41084
  */
41049
- function hashString(value) {
41050
- let hash = 5381;
41051
- for (let i = 0; i < value.length; i += 1) {
41052
- hash = (hash << 5) + hash + value.charCodeAt(i);
41085
+ function logRefactorCandidates(candidates) {
41086
+ for (const candidate of candidates) {
41087
+ console.info(colors.yellow(`${candidate.relativePath} <- ${candidate.reasons.join('; ')}`));
41053
41088
  }
41054
- return (hash >>> 0).toString(36);
41055
41089
  }
41056
- /**
41057
- * Note: [?] Code in this file should never be published in any package
41058
- */
41090
+ /** Note: [🟡] Code for repository script [find-refactor-candidates](scripts/find-refactor-candidates/find-refactor-candidates.ts) should never be published outside of `@promptbook/cli` */
41059
41091
 
41060
41092
  var findRefactorCandidates$1 = /*#__PURE__*/Object.freeze({
41061
41093
  __proto__: null,
@@ -41957,9 +41989,7 @@ async function isWorkingTreeClean(path) {
41957
41989
  });
41958
41990
  return gitStatus.includes(`working tree clean`);
41959
41991
  }
41960
- /**
41961
- * Note: [🟡] Code in this file should never be published outside of `@promptbook/cli`
41962
- */
41992
+ /** Note: [🟡] Code for CLI support script [isWorkingTreeClean](scripts/utils/autocommit/isWorkingTreeClean.ts) should never be published outside of `@promptbook/cli` */
41963
41993
 
41964
41994
  /**
41965
41995
  * Ensures the git working tree is clean before running the prompt.
@@ -43523,6 +43553,9 @@ function createCodingContext() {
43523
43553
  - When throwing errors, throw [branded errors](src/errors) and use \`spaceTrim\` utility to write clear and well-formatted multilie detailed error messages.
43524
43554
  - Format errors as markdown, for example \`variabiles\` should be in backticks, important notes can be in bold, etc.
43525
43555
  - Constants should be always \`UPPER_SNAKE_CASE\`
43556
+ - Boolean variables should be always prefixed with "is", for example \`isUserChatJobLeaseExpired\` or \`IS_DEBUG_MODE\`
43557
+ - Do not use abbreviations, for example use \`isExpired\` instead of \`isExp\`, \`translateMessage\` instead of \`t\`, etc.
43558
+ - But it is fine to use well-known abbreviations, for example \`id\`, \`url\`, \`html\`, etc.
43526
43559
  - When writing multiline strings, use \`spaceTrim\` utility
43527
43560
  - DO only the change described here above DO not add any additional features or make any additional changes that are not described in the prompt.
43528
43561
  - If you find some critical issue that is not described in the prompt, report it to the file \`./AGENT_REPORT.md\` on the root of the project