@promptbook/cli 0.112.0-31 → 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.
- package/esm/index.es.js +714 -548
- package/esm/index.es.js.map +1 -1
- package/esm/scripts/find-fresh-emoji-tags/find-fresh-emoji-tags.d.ts +1 -3
- package/esm/scripts/find-refactor-candidates/analyzeSourceFileForRefactorCandidate.d.ts +27 -0
- package/esm/scripts/find-refactor-candidates/buildPromptContent.d.ts +8 -0
- package/esm/scripts/find-refactor-candidates/find-refactor-candidates.d.ts +1 -3
- package/esm/scripts/find-refactor-candidates/findRefactorCandidatesInProject.d.ts +8 -0
- package/esm/scripts/find-refactor-candidates/loadExistingPromptTargets.d.ts +7 -0
- package/esm/scripts/find-refactor-candidates/normalizeRefactorCandidatePath.d.ts +7 -0
- package/esm/scripts/find-refactor-candidates/writeRefactorCandidatePrompts.d.ts +27 -0
- package/esm/scripts/run-codex-prompts/runners/github-copilot/GitHubCopilotRunner.d.ts +19 -0
- package/esm/scripts/run-codex-prompts/runners/github-copilot/buildGitHubCopilotScript.d.ts +5 -0
- package/esm/scripts/utils/autocommit/isWorkingTreeClean.d.ts +1 -3
- package/esm/src/_packages/components.index.d.ts +6 -0
- package/esm/src/_packages/types.index.d.ts +55 -49
- package/esm/src/book-2.0/agent-source/AgentReferenceResolver.d.ts +11 -0
- package/esm/src/book-2.0/agent-source/CreateAgentModelRequirementsOptions.d.ts +8 -0
- package/esm/src/book-2.0/agent-source/TeammateProfileResolver.d.ts +33 -0
- package/esm/src/book-2.0/agent-source/createTeamToolName.d.ts +7 -7
- package/esm/src/book-components/Chat/Chat/ChatActionsBar.d.ts +5 -0
- package/esm/src/book-components/Chat/Chat/ChatInputAreaDictationPanel.d.ts +42 -0
- package/esm/src/book-components/Chat/Chat/ChatMessageItem.d.ts +18 -15
- package/esm/src/book-components/Chat/Chat/ChatMessageItem.test.d.ts +1 -1
- package/esm/src/book-components/Chat/Chat/ChatMessageList.d.ts +14 -0
- package/esm/src/book-components/Chat/Chat/ChatMessageRichContent.d.ts +32 -0
- package/esm/src/book-components/Chat/Chat/ChatMessageToolCallChips.d.ts +22 -0
- package/esm/src/book-components/Chat/Chat/ChatProps.d.ts +290 -0
- package/esm/src/book-components/Chat/Chat/ChatToolCallModal.d.ts +16 -0
- package/esm/src/book-components/Chat/Chat/StreamingFeaturePlaceholder.d.ts +33 -0
- package/esm/src/book-components/Chat/Chat/createChatMessageToolCallRenderModel.d.ts +76 -0
- package/esm/src/book-components/Chat/Chat/createProgressCardChecklistMarkdown.d.ts +16 -0
- package/esm/src/book-components/Chat/Chat/renderAdvancedToolCallDetails.d.ts +4 -0
- package/esm/src/book-components/Chat/Chat/renderEmailToolCallDetails.d.ts +26 -0
- package/esm/src/book-components/Chat/Chat/renderMemoryToolCallDetails.d.ts +31 -0
- package/esm/src/book-components/Chat/Chat/renderPopupToolCallDetails.d.ts +32 -0
- package/esm/src/book-components/Chat/Chat/renderRunBrowserToolCallDetails.d.ts +31 -0
- package/esm/src/book-components/Chat/Chat/renderSearchToolCallDetails.d.ts +31 -0
- package/esm/src/book-components/Chat/Chat/renderSelfLearningToolCallDetails.d.ts +38 -0
- package/esm/src/book-components/Chat/Chat/renderTimeToolCallDetails.d.ts +38 -0
- package/esm/src/book-components/Chat/Chat/renderTimeoutToolCallDetails.d.ts +46 -0
- package/esm/src/book-components/Chat/Chat/renderToolCallClockPanel.d.ts +33 -0
- package/esm/src/book-components/Chat/Chat/renderToolCallDetails.d.ts +10 -1
- package/esm/src/book-components/Chat/Chat/renderToolCallProgressPlaceholder.d.ts +29 -0
- package/esm/src/book-components/Chat/Chat/renderWalletCredentialToolCallDetails.d.ts +26 -0
- package/esm/src/book-components/Chat/Chat/resolveToolCallProgressMessage.d.ts +9 -0
- package/esm/src/book-components/Chat/Chat/useChatInputAreaAttachments.d.ts +32 -0
- package/esm/src/book-components/Chat/Chat/useChatInputAreaDictation.d.ts +76 -0
- package/esm/src/book-components/Chat/Chat/useChatMessageAvatarTooltip.d.ts +31 -0
- package/esm/src/book-components/Chat/Chat/useChatMessageSpeechPlayback.d.ts +29 -0
- package/esm/src/book-components/Chat/MarkdownContent/MarkdownContent.d.ts +2 -1
- package/esm/src/book-components/Chat/MarkdownContent/MarkdownContent.test.d.ts +2 -0
- package/esm/src/book-components/Chat/hooks/useChatCompleteNotification.d.ts +18 -0
- package/esm/src/book-components/Chat/hooks/useChatCompleteNotification.test.d.ts +2 -0
- package/esm/src/book-components/Chat/types/ChatMessage.d.ts +77 -1
- package/esm/src/book-components/Chat/utils/formatToolCallDateTime.d.ts +37 -0
- package/esm/src/book-components/Chat/utils/formatToolCallLocalTime.d.ts +11 -0
- package/esm/src/book-components/Chat/utils/formatToolCallTranslationTemplate.d.ts +10 -0
- package/esm/src/book-components/Chat/utils/getChatMessageTimingDisplay.d.ts +5 -1
- package/esm/src/book-components/Chat/utils/getToolCallChipletInfo.d.ts +26 -1
- package/esm/src/book-components/Chat/utils/timeoutToolCallPresentation.d.ts +26 -3
- package/esm/src/cli/$runPromptbookCli.d.ts +1 -3
- package/esm/src/cli/cli-commands/_boilerplate.d.ts +2 -4
- package/esm/src/cli/cli-commands/about.d.ts +1 -1
- package/esm/src/cli/cli-commands/coder/find-fresh-emoji-tags.d.ts +2 -4
- package/esm/src/cli/cli-commands/coder/find-refactor-candidates.d.ts +2 -4
- package/esm/src/cli/cli-commands/coder/generate-boilerplates.d.ts +2 -4
- package/esm/src/cli/cli-commands/coder/init.d.ts +2 -4
- package/esm/src/cli/cli-commands/coder/run.d.ts +2 -4
- package/esm/src/cli/cli-commands/coder/verify.d.ts +2 -4
- package/esm/src/cli/cli-commands/coder.d.ts +2 -4
- package/esm/src/cli/cli-commands/hello.d.ts +1 -1
- package/esm/src/cli/cli-commands/list-models.d.ts +2 -4
- package/esm/src/cli/cli-commands/list-scrapers.d.ts +2 -4
- package/esm/src/cli/cli-commands/login.d.ts +1 -1
- package/esm/src/cli/cli-commands/make.d.ts +1 -1
- package/esm/src/cli/cli-commands/prettify.d.ts +1 -1
- package/esm/src/cli/cli-commands/run.d.ts +1 -1
- package/esm/src/cli/cli-commands/runInteractiveChatbot.d.ts +1 -1
- package/esm/src/cli/cli-commands/start-agents-server.d.ts +2 -4
- package/esm/src/cli/cli-commands/start-pipelines-server.d.ts +1 -1
- package/esm/src/cli/cli-commands/test-command.d.ts +1 -1
- package/esm/src/cli/main.d.ts +2 -4
- package/esm/src/cli/promptbookCli.d.ts +1 -1
- package/esm/src/commitments/USE_BROWSER/fetchUrlContent.d.ts +1 -3
- package/esm/src/conversion/archive/loadArchive.d.ts +1 -3
- package/esm/src/conversion/archive/saveArchive.d.ts +1 -1
- package/esm/src/conversion/validation/_importPipeline.d.ts +2 -4
- package/esm/src/dialogs/simple-prompt/SimplePromptInterfaceTools.d.ts +1 -3
- package/esm/src/executables/$provideExecutablesForNode.d.ts +1 -1
- package/esm/src/executables/apps/locateLibreoffice.d.ts +2 -4
- package/esm/src/executables/apps/locatePandoc.d.ts +2 -4
- package/esm/src/executables/locateApp.d.ts +2 -4
- package/esm/src/executables/platforms/locateAppOnLinux.d.ts +2 -4
- package/esm/src/executables/platforms/locateAppOnMacOs.d.ts +2 -4
- package/esm/src/executables/platforms/locateAppOnWindows.d.ts +2 -4
- package/esm/src/execution/translation/automatic-translate/translateMessages.d.ts +2 -4
- package/esm/src/execution/utils/$provideExecutionToolsForNode.d.ts +2 -4
- package/esm/src/llm-providers/_common/register/$provideEnvFilename.d.ts +1 -3
- package/esm/src/llm-providers/_common/register/$provideLlmToolsConfigurationFromEnv.d.ts +1 -3
- package/esm/src/llm-providers/_common/register/$provideLlmToolsForWizardOrCli.d.ts +1 -1
- package/esm/src/llm-providers/_common/register/$provideLlmToolsFromEnv.d.ts +1 -3
- package/esm/src/llm-providers/_multiple/playground/playground.d.ts +1 -3
- package/esm/src/llm-providers/agent/playground/playground.d.ts +1 -1
- package/esm/src/llm-providers/anthropic-claude/playground/playground.d.ts +1 -1
- package/esm/src/llm-providers/azure-openai/playground/playground.d.ts +2 -4
- package/esm/src/llm-providers/ollama/playground/playground.d.ts +2 -4
- package/esm/src/llm-providers/openai/playground/playground.d.ts +2 -4
- package/esm/src/llm-providers/remote/playground/playground.d.ts +1 -3
- package/esm/src/llm-providers/vercel/playground/playground.d.ts +2 -4
- package/esm/src/playground/permanent/_boilerplate.d.ts +1 -3
- package/esm/src/playground/permanent/agent-with-browser-playground.d.ts +1 -3
- package/esm/src/playground/permanent/error-handling-playground.d.ts +1 -3
- package/esm/src/playground/playground.d.ts +2 -4
- package/esm/src/remote-server/startAgentServer.d.ts +1 -3
- package/esm/src/remote-server/startRemoteServer.d.ts +1 -2
- package/esm/src/scrapers/_boilerplate/BoilerplateScraper.d.ts +4 -6
- package/esm/src/scrapers/_boilerplate/playground/boilerplate-scraper-playground.d.ts +1 -3
- package/esm/src/scrapers/_common/register/$provideFilesystemForNode.d.ts +2 -4
- package/esm/src/scrapers/_common/register/$provideScrapersForNode.d.ts +2 -4
- package/esm/src/scrapers/_common/register/$provideScriptingForNode.d.ts +2 -4
- package/esm/src/scrapers/_common/utils/getScraperIntermediateSource.d.ts +1 -1
- package/esm/src/scrapers/document/DocumentScraper.d.ts +1 -1
- package/esm/src/scrapers/document/playground/document-scraper-playground.d.ts +1 -3
- package/esm/src/scrapers/document-legacy/LegacyDocumentScraper.d.ts +1 -1
- package/esm/src/scrapers/document-legacy/playground/legacy-document-scraper-playground.d.ts +1 -3
- package/esm/src/scrapers/markdown/playground/markdown-scraper-playground.d.ts +1 -3
- package/esm/src/scrapers/markitdown/MarkitdownScraper.d.ts +1 -1
- package/esm/src/scrapers/markitdown/playground/markitdown-scraper-playground.d.ts +1 -3
- package/esm/src/scrapers/pdf/PdfScraper.d.ts +1 -1
- package/esm/src/scrapers/pdf/playground/pdf-scraper-playground.d.ts +1 -3
- package/esm/src/scrapers/website/WebsiteScraper.d.ts +1 -1
- package/esm/src/scrapers/website/playground/website-scraper-playground.d.ts +1 -3
- package/esm/src/speech-recognition/BrowserSpeechRecognition.d.ts +2 -4
- package/esm/src/storage/file-cache-storage/FileCacheStorage.d.ts +2 -4
- package/esm/src/storage/local-storage/getIndexedDbStorage.d.ts +1 -3
- package/esm/src/storage/local-storage/getLocalStorage.d.ts +1 -3
- package/esm/src/storage/local-storage/getSessionStorage.d.ts +1 -3
- package/esm/src/transpilers/openai-sdk/playground/playground.d.ts +1 -3
- package/esm/src/types/InputParameters_private.d.ts +11 -0
- package/esm/src/types/Parameters_private.d.ts +16 -0
- package/esm/src/types/ReservedParameters_private.d.ts +10 -0
- package/esm/src/types/number_bytes.d.ts +21 -0
- package/esm/src/types/number_id.d.ts +13 -0
- package/esm/src/types/number_likeness.d.ts +8 -0
- package/esm/src/types/number_milliseconds.d.ts +33 -0
- package/esm/src/types/number_percent.d.ts +18 -0
- package/esm/src/types/number_positive.d.ts +16 -0
- package/esm/src/types/number_usd.d.ts +6 -106
- package/esm/src/types/string_agent_hash_private.d.ts +9 -0
- package/esm/src/types/string_agent_name_in_book_private.d.ts +8 -0
- package/esm/src/types/string_agent_name_private.d.ts +9 -0
- package/esm/src/types/string_agent_permanent_id_private.d.ts +10 -0
- package/esm/src/types/string_base64_private.d.ts +17 -0
- package/esm/src/types/string_business_category_name_private.d.ts +6 -0
- package/esm/src/types/string_char_private.d.ts +8 -0
- package/esm/src/types/string_chat_prompt_private.d.ts +9 -0
- package/esm/src/types/string_completion_prompt_private.d.ts +9 -0
- package/esm/src/types/string_email_private.d.ts +16 -0
- package/esm/src/types/string_host_private.d.ts +55 -0
- package/esm/src/types/string_mime_type_private.d.ts +17 -0
- package/esm/src/types/string_model_description_private.d.ts +8 -0
- package/esm/src/types/string_model_name_private.d.ts +8 -0
- package/esm/src/types/string_name_private.d.ts +9 -0
- package/esm/src/types/string_page_private.d.ts +9 -0
- package/esm/src/types/string_parameter_name.d.ts +74 -31
- package/esm/src/types/string_parameter_value_private.d.ts +9 -0
- package/esm/src/types/string_persona_description_private.d.ts +8 -0
- package/esm/src/types/string_prompt_image_private.d.ts +8 -0
- package/esm/src/types/string_prompt_private.d.ts +8 -0
- package/esm/src/types/string_reserved_parameter_name_private.d.ts +11 -0
- package/esm/src/types/string_system_message_private.d.ts +9 -0
- package/esm/src/types/string_template_private.d.ts +8 -0
- package/esm/src/types/string_text_prompt_private.d.ts +9 -0
- package/esm/src/types/string_title_private.d.ts +9 -0
- package/esm/src/types/string_url.d.ts +50 -46
- package/esm/src/types/string_url_private.d.ts +88 -0
- package/esm/src/types/typeAliases.d.ts +7 -1
- package/esm/src/utils/execCommand/$execCommand.d.ts +1 -3
- package/esm/src/utils/execCommand/$execCommands.d.ts +1 -3
- package/esm/src/utils/files/$induceBookDownload.d.ts +1 -3
- package/esm/src/utils/files/$induceFileDownload.d.ts +1 -3
- package/esm/src/utils/files/ObjectUrl.d.ts +1 -3
- package/esm/src/utils/toolCalls/mergeToolCalls.d.ts +1 -1
- package/esm/src/version.d.ts +1 -1
- package/esm/src/wizard/$getCompiledBook.d.ts +2 -4
- package/esm/src/wizard/wizard.d.ts +2 -4
- package/package.json +1 -1
- package/umd/index.umd.js +714 -548
- package/umd/index.umd.js.map +1 -1
- package/umd/scripts/find-fresh-emoji-tags/find-fresh-emoji-tags.d.ts +1 -3
- package/umd/scripts/find-refactor-candidates/analyzeSourceFileForRefactorCandidate.d.ts +27 -0
- package/umd/scripts/find-refactor-candidates/buildPromptContent.d.ts +8 -0
- package/umd/scripts/find-refactor-candidates/find-refactor-candidates.d.ts +1 -3
- package/umd/scripts/find-refactor-candidates/findRefactorCandidatesInProject.d.ts +8 -0
- package/umd/scripts/find-refactor-candidates/loadExistingPromptTargets.d.ts +7 -0
- package/umd/scripts/find-refactor-candidates/normalizeRefactorCandidatePath.d.ts +7 -0
- package/umd/scripts/find-refactor-candidates/writeRefactorCandidatePrompts.d.ts +27 -0
- package/umd/scripts/run-codex-prompts/runners/github-copilot/GitHubCopilotRunner.d.ts +19 -0
- package/umd/scripts/run-codex-prompts/runners/github-copilot/buildGitHubCopilotScript.d.ts +5 -0
- package/umd/scripts/utils/autocommit/isWorkingTreeClean.d.ts +1 -3
- package/umd/src/_packages/components.index.d.ts +6 -0
- package/umd/src/_packages/types.index.d.ts +55 -49
- package/umd/src/book-2.0/agent-source/AgentReferenceResolver.d.ts +11 -0
- package/umd/src/book-2.0/agent-source/CreateAgentModelRequirementsOptions.d.ts +8 -0
- package/umd/src/book-2.0/agent-source/TeammateProfileResolver.d.ts +33 -0
- package/umd/src/book-2.0/agent-source/createTeamToolName.d.ts +7 -7
- package/umd/src/book-components/Chat/Chat/ChatActionsBar.d.ts +5 -0
- package/umd/src/book-components/Chat/Chat/ChatInputAreaDictationPanel.d.ts +42 -0
- package/umd/src/book-components/Chat/Chat/ChatMessageItem.d.ts +18 -15
- package/umd/src/book-components/Chat/Chat/ChatMessageItem.test.d.ts +1 -1
- package/umd/src/book-components/Chat/Chat/ChatMessageList.d.ts +14 -0
- package/umd/src/book-components/Chat/Chat/ChatMessageRichContent.d.ts +32 -0
- package/umd/src/book-components/Chat/Chat/ChatMessageToolCallChips.d.ts +22 -0
- package/umd/src/book-components/Chat/Chat/ChatProps.d.ts +290 -0
- package/umd/src/book-components/Chat/Chat/ChatToolCallModal.d.ts +16 -0
- package/umd/src/book-components/Chat/Chat/StreamingFeaturePlaceholder.d.ts +33 -0
- package/umd/src/book-components/Chat/Chat/createChatMessageToolCallRenderModel.d.ts +76 -0
- package/umd/src/book-components/Chat/Chat/createProgressCardChecklistMarkdown.d.ts +16 -0
- package/umd/src/book-components/Chat/Chat/renderAdvancedToolCallDetails.d.ts +4 -0
- package/umd/src/book-components/Chat/Chat/renderEmailToolCallDetails.d.ts +26 -0
- package/umd/src/book-components/Chat/Chat/renderMemoryToolCallDetails.d.ts +31 -0
- package/umd/src/book-components/Chat/Chat/renderPopupToolCallDetails.d.ts +32 -0
- package/umd/src/book-components/Chat/Chat/renderRunBrowserToolCallDetails.d.ts +31 -0
- package/umd/src/book-components/Chat/Chat/renderSearchToolCallDetails.d.ts +31 -0
- package/umd/src/book-components/Chat/Chat/renderSelfLearningToolCallDetails.d.ts +38 -0
- package/umd/src/book-components/Chat/Chat/renderTimeToolCallDetails.d.ts +38 -0
- package/umd/src/book-components/Chat/Chat/renderTimeoutToolCallDetails.d.ts +46 -0
- package/umd/src/book-components/Chat/Chat/renderToolCallClockPanel.d.ts +33 -0
- package/umd/src/book-components/Chat/Chat/renderToolCallDetails.d.ts +10 -1
- package/umd/src/book-components/Chat/Chat/renderToolCallProgressPlaceholder.d.ts +29 -0
- package/umd/src/book-components/Chat/Chat/renderWalletCredentialToolCallDetails.d.ts +26 -0
- package/umd/src/book-components/Chat/Chat/resolveToolCallProgressMessage.d.ts +9 -0
- package/umd/src/book-components/Chat/Chat/useChatInputAreaAttachments.d.ts +32 -0
- package/umd/src/book-components/Chat/Chat/useChatInputAreaDictation.d.ts +76 -0
- package/umd/src/book-components/Chat/Chat/useChatMessageAvatarTooltip.d.ts +31 -0
- package/umd/src/book-components/Chat/Chat/useChatMessageSpeechPlayback.d.ts +29 -0
- package/umd/src/book-components/Chat/MarkdownContent/MarkdownContent.d.ts +2 -1
- package/umd/src/book-components/Chat/MarkdownContent/MarkdownContent.test.d.ts +2 -0
- package/umd/src/book-components/Chat/hooks/useChatCompleteNotification.d.ts +18 -0
- package/umd/src/book-components/Chat/hooks/useChatCompleteNotification.test.d.ts +2 -0
- package/umd/src/book-components/Chat/types/ChatMessage.d.ts +77 -1
- package/umd/src/book-components/Chat/utils/formatToolCallDateTime.d.ts +37 -0
- package/umd/src/book-components/Chat/utils/formatToolCallLocalTime.d.ts +11 -0
- package/umd/src/book-components/Chat/utils/formatToolCallTranslationTemplate.d.ts +10 -0
- package/umd/src/book-components/Chat/utils/getChatMessageTimingDisplay.d.ts +5 -1
- package/umd/src/book-components/Chat/utils/getToolCallChipletInfo.d.ts +26 -1
- package/umd/src/book-components/Chat/utils/timeoutToolCallPresentation.d.ts +26 -3
- package/umd/src/cli/$runPromptbookCli.d.ts +1 -3
- package/umd/src/cli/cli-commands/_boilerplate.d.ts +2 -4
- package/umd/src/cli/cli-commands/about.d.ts +1 -1
- package/umd/src/cli/cli-commands/coder/find-fresh-emoji-tags.d.ts +2 -4
- package/umd/src/cli/cli-commands/coder/find-refactor-candidates.d.ts +2 -4
- package/umd/src/cli/cli-commands/coder/generate-boilerplates.d.ts +2 -4
- package/umd/src/cli/cli-commands/coder/init.d.ts +2 -4
- package/umd/src/cli/cli-commands/coder/run.d.ts +2 -4
- package/umd/src/cli/cli-commands/coder/verify.d.ts +2 -4
- package/umd/src/cli/cli-commands/coder.d.ts +2 -4
- package/umd/src/cli/cli-commands/hello.d.ts +1 -1
- package/umd/src/cli/cli-commands/list-models.d.ts +2 -4
- package/umd/src/cli/cli-commands/list-scrapers.d.ts +2 -4
- package/umd/src/cli/cli-commands/login.d.ts +1 -1
- package/umd/src/cli/cli-commands/make.d.ts +1 -1
- package/umd/src/cli/cli-commands/prettify.d.ts +1 -1
- package/umd/src/cli/cli-commands/run.d.ts +1 -1
- package/umd/src/cli/cli-commands/runInteractiveChatbot.d.ts +1 -1
- package/umd/src/cli/cli-commands/start-agents-server.d.ts +2 -4
- package/umd/src/cli/cli-commands/start-pipelines-server.d.ts +1 -1
- package/umd/src/cli/cli-commands/test-command.d.ts +1 -1
- package/umd/src/cli/main.d.ts +2 -4
- package/umd/src/cli/promptbookCli.d.ts +1 -1
- package/umd/src/commitments/USE_BROWSER/fetchUrlContent.d.ts +1 -3
- package/umd/src/conversion/archive/loadArchive.d.ts +1 -3
- package/umd/src/conversion/archive/saveArchive.d.ts +1 -1
- package/umd/src/conversion/validation/_importPipeline.d.ts +2 -4
- package/umd/src/dialogs/simple-prompt/SimplePromptInterfaceTools.d.ts +1 -3
- package/umd/src/executables/$provideExecutablesForNode.d.ts +1 -1
- package/umd/src/executables/apps/locateLibreoffice.d.ts +2 -4
- package/umd/src/executables/apps/locatePandoc.d.ts +2 -4
- package/umd/src/executables/locateApp.d.ts +2 -4
- package/umd/src/executables/platforms/locateAppOnLinux.d.ts +2 -4
- package/umd/src/executables/platforms/locateAppOnMacOs.d.ts +2 -4
- package/umd/src/executables/platforms/locateAppOnWindows.d.ts +2 -4
- package/umd/src/execution/translation/automatic-translate/translateMessages.d.ts +2 -4
- package/umd/src/execution/utils/$provideExecutionToolsForNode.d.ts +2 -4
- package/umd/src/llm-providers/_common/register/$provideEnvFilename.d.ts +1 -3
- package/umd/src/llm-providers/_common/register/$provideLlmToolsConfigurationFromEnv.d.ts +1 -3
- package/umd/src/llm-providers/_common/register/$provideLlmToolsForWizardOrCli.d.ts +1 -1
- package/umd/src/llm-providers/_common/register/$provideLlmToolsFromEnv.d.ts +1 -3
- package/umd/src/llm-providers/_multiple/playground/playground.d.ts +1 -3
- package/umd/src/llm-providers/agent/playground/playground.d.ts +1 -1
- package/umd/src/llm-providers/anthropic-claude/playground/playground.d.ts +1 -1
- package/umd/src/llm-providers/azure-openai/playground/playground.d.ts +2 -4
- package/umd/src/llm-providers/ollama/playground/playground.d.ts +2 -4
- package/umd/src/llm-providers/openai/playground/playground.d.ts +2 -4
- package/umd/src/llm-providers/remote/playground/playground.d.ts +1 -3
- package/umd/src/llm-providers/vercel/playground/playground.d.ts +2 -4
- package/umd/src/playground/permanent/_boilerplate.d.ts +1 -3
- package/umd/src/playground/permanent/agent-with-browser-playground.d.ts +1 -3
- package/umd/src/playground/permanent/error-handling-playground.d.ts +1 -3
- package/umd/src/playground/playground.d.ts +2 -4
- package/umd/src/remote-server/startAgentServer.d.ts +1 -3
- package/umd/src/remote-server/startRemoteServer.d.ts +1 -2
- package/umd/src/scrapers/_boilerplate/BoilerplateScraper.d.ts +4 -6
- package/umd/src/scrapers/_boilerplate/playground/boilerplate-scraper-playground.d.ts +1 -3
- package/umd/src/scrapers/_common/register/$provideFilesystemForNode.d.ts +2 -4
- package/umd/src/scrapers/_common/register/$provideScrapersForNode.d.ts +2 -4
- package/umd/src/scrapers/_common/register/$provideScriptingForNode.d.ts +2 -4
- package/umd/src/scrapers/_common/utils/getScraperIntermediateSource.d.ts +1 -1
- package/umd/src/scrapers/document/DocumentScraper.d.ts +1 -1
- package/umd/src/scrapers/document/playground/document-scraper-playground.d.ts +1 -3
- package/umd/src/scrapers/document-legacy/LegacyDocumentScraper.d.ts +1 -1
- package/umd/src/scrapers/document-legacy/playground/legacy-document-scraper-playground.d.ts +1 -3
- package/umd/src/scrapers/markdown/playground/markdown-scraper-playground.d.ts +1 -3
- package/umd/src/scrapers/markitdown/MarkitdownScraper.d.ts +1 -1
- package/umd/src/scrapers/markitdown/playground/markitdown-scraper-playground.d.ts +1 -3
- package/umd/src/scrapers/pdf/PdfScraper.d.ts +1 -1
- package/umd/src/scrapers/pdf/playground/pdf-scraper-playground.d.ts +1 -3
- package/umd/src/scrapers/website/WebsiteScraper.d.ts +1 -1
- package/umd/src/scrapers/website/playground/website-scraper-playground.d.ts +1 -3
- package/umd/src/speech-recognition/BrowserSpeechRecognition.d.ts +2 -4
- package/umd/src/storage/file-cache-storage/FileCacheStorage.d.ts +2 -4
- package/umd/src/storage/local-storage/getIndexedDbStorage.d.ts +1 -3
- package/umd/src/storage/local-storage/getLocalStorage.d.ts +1 -3
- package/umd/src/storage/local-storage/getSessionStorage.d.ts +1 -3
- package/umd/src/transpilers/openai-sdk/playground/playground.d.ts +1 -3
- package/umd/src/types/InputParameters_private.d.ts +11 -0
- package/umd/src/types/Parameters_private.d.ts +16 -0
- package/umd/src/types/ReservedParameters_private.d.ts +10 -0
- package/umd/src/types/number_bytes.d.ts +21 -0
- package/umd/src/types/number_id.d.ts +13 -0
- package/umd/src/types/number_likeness.d.ts +8 -0
- package/umd/src/types/number_milliseconds.d.ts +33 -0
- package/umd/src/types/number_percent.d.ts +18 -0
- package/umd/src/types/number_positive.d.ts +16 -0
- package/umd/src/types/number_usd.d.ts +6 -106
- package/umd/src/types/string_agent_hash_private.d.ts +9 -0
- package/umd/src/types/string_agent_name_in_book_private.d.ts +8 -0
- package/umd/src/types/string_agent_name_private.d.ts +9 -0
- package/umd/src/types/string_agent_permanent_id_private.d.ts +10 -0
- package/umd/src/types/string_base64_private.d.ts +17 -0
- package/umd/src/types/string_business_category_name_private.d.ts +6 -0
- package/umd/src/types/string_char_private.d.ts +8 -0
- package/umd/src/types/string_chat_prompt_private.d.ts +9 -0
- package/umd/src/types/string_completion_prompt_private.d.ts +9 -0
- package/umd/src/types/string_email_private.d.ts +16 -0
- package/umd/src/types/string_host_private.d.ts +55 -0
- package/umd/src/types/string_mime_type_private.d.ts +17 -0
- package/umd/src/types/string_model_description_private.d.ts +8 -0
- package/umd/src/types/string_model_name_private.d.ts +8 -0
- package/umd/src/types/string_name_private.d.ts +9 -0
- package/umd/src/types/string_page_private.d.ts +9 -0
- package/umd/src/types/string_parameter_name.d.ts +74 -31
- package/umd/src/types/string_parameter_value_private.d.ts +9 -0
- package/umd/src/types/string_persona_description_private.d.ts +8 -0
- package/umd/src/types/string_prompt_image_private.d.ts +8 -0
- package/umd/src/types/string_prompt_private.d.ts +8 -0
- package/umd/src/types/string_reserved_parameter_name_private.d.ts +11 -0
- package/umd/src/types/string_system_message_private.d.ts +9 -0
- package/umd/src/types/string_template_private.d.ts +8 -0
- package/umd/src/types/string_text_prompt_private.d.ts +9 -0
- package/umd/src/types/string_title_private.d.ts +9 -0
- package/umd/src/types/string_url.d.ts +50 -46
- package/umd/src/types/string_url_private.d.ts +88 -0
- package/umd/src/types/typeAliases.d.ts +7 -1
- package/umd/src/utils/execCommand/$execCommand.d.ts +1 -3
- package/umd/src/utils/execCommand/$execCommands.d.ts +1 -3
- package/umd/src/utils/files/$induceBookDownload.d.ts +1 -3
- package/umd/src/utils/files/$induceFileDownload.d.ts +1 -3
- package/umd/src/utils/files/ObjectUrl.d.ts +1 -3
- package/umd/src/utils/toolCalls/mergeToolCalls.d.ts +1 -1
- package/umd/src/version.d.ts +1 -1
- package/umd/src/wizard/$getCompiledBook.d.ts +2 -4
- 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-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
|
@@ -2040,6 +2032,7 @@ function $initializeCoderRunCommand(program) {
|
|
|
2040
2032
|
|
|
2041
2033
|
Runners:
|
|
2042
2034
|
- openai-codex: OpenAI Codex integration (requires --model)
|
|
2035
|
+
- github-copilot: GitHub Copilot CLI integration
|
|
2043
2036
|
- cline: Cline CLI integration
|
|
2044
2037
|
- claude-code: Claude Code integration
|
|
2045
2038
|
- opencode: Opencode integration
|
|
@@ -2052,7 +2045,7 @@ function $initializeCoderRunCommand(program) {
|
|
|
2052
2045
|
- Dry-run mode to preview prompts
|
|
2053
2046
|
`));
|
|
2054
2047
|
command.option('--dry-run', 'Print unwritten prompts without executing', false);
|
|
2055
|
-
command.option('--agent <agent-name>', 'Select runner: openai-codex, cline, claude-code, opencode, gemini (required for non-dry-run)');
|
|
2048
|
+
command.option('--agent <agent-name>', 'Select runner: openai-codex, github-copilot, cline, claude-code, opencode, gemini (required for non-dry-run)');
|
|
2056
2049
|
command.option('--model <model>', spaceTrim$1(`
|
|
2057
2050
|
Model to use (required for openai-codex and gemini)
|
|
2058
2051
|
|
|
@@ -2072,6 +2065,7 @@ function $initializeCoderRunCommand(program) {
|
|
|
2072
2065
|
let agentName = undefined;
|
|
2073
2066
|
if (agent) {
|
|
2074
2067
|
if (agent === 'openai-codex' ||
|
|
2068
|
+
agent === 'github-copilot' ||
|
|
2075
2069
|
agent === 'cline' ||
|
|
2076
2070
|
agent === 'claude-code' ||
|
|
2077
2071
|
agent === 'opencode' ||
|
|
@@ -2079,12 +2073,12 @@ function $initializeCoderRunCommand(program) {
|
|
|
2079
2073
|
agentName = agent;
|
|
2080
2074
|
}
|
|
2081
2075
|
else {
|
|
2082
|
-
console.error(colors.red(`Invalid agent "${agent}". Must be one of: openai-codex, cline, claude-code, opencode, gemini`));
|
|
2076
|
+
console.error(colors.red(`Invalid agent "${agent}". Must be one of: openai-codex, github-copilot, cline, claude-code, opencode, gemini`));
|
|
2083
2077
|
return process.exit(1);
|
|
2084
2078
|
}
|
|
2085
2079
|
}
|
|
2086
2080
|
if (!agentName && !dryRun) {
|
|
2087
|
-
console.error(colors.red('You must choose an agent using --agent <openai-codex|cline|claude-code|opencode|gemini>'));
|
|
2081
|
+
console.error(colors.red('You must choose an agent using --agent <openai-codex|github-copilot|cline|claude-code|opencode|gemini>'));
|
|
2088
2082
|
return process.exit(1);
|
|
2089
2083
|
}
|
|
2090
2084
|
// Convert commander options to RunOptions format
|
|
@@ -2127,10 +2121,8 @@ function parseIntOption(value) {
|
|
|
2127
2121
|
}
|
|
2128
2122
|
return parsed;
|
|
2129
2123
|
}
|
|
2130
|
-
/**
|
|
2131
|
-
|
|
2132
|
-
* Note: [🟡] Code in this file should never be published outside of `@promptbook/cli`
|
|
2133
|
-
*/
|
|
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 */
|
|
2134
2126
|
|
|
2135
2127
|
/**
|
|
2136
2128
|
* Initializes `coder verify` command for Promptbook CLI utilities
|
|
@@ -2166,10 +2158,8 @@ function $initializeCoderVerifyCommand(program) {
|
|
|
2166
2158
|
return process.exit(0);
|
|
2167
2159
|
}));
|
|
2168
2160
|
}
|
|
2169
|
-
/**
|
|
2170
|
-
|
|
2171
|
-
* Note: [🟡] Code in this file should never be published outside of `@promptbook/cli`
|
|
2172
|
-
*/
|
|
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 */
|
|
2173
2163
|
|
|
2174
2164
|
/**
|
|
2175
2165
|
* Initializes `coder` command with subcommands for Promptbook CLI utilities
|
|
@@ -2213,10 +2203,8 @@ function $initializeCoderCommand(program) {
|
|
|
2213
2203
|
coderCommand.help();
|
|
2214
2204
|
});
|
|
2215
2205
|
}
|
|
2216
|
-
/**
|
|
2217
|
-
|
|
2218
|
-
* Note: [🟡] Code in this file should never be published outside of `@promptbook/cli`
|
|
2219
|
-
*/
|
|
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 */
|
|
2220
2208
|
|
|
2221
2209
|
/**
|
|
2222
2210
|
* Initializes testing `hello` command for Promptbook CLI utilities
|
|
@@ -2241,10 +2229,10 @@ function $initializeHelloCommand(program) {
|
|
|
2241
2229
|
return process.exit(0);
|
|
2242
2230
|
}));
|
|
2243
2231
|
}
|
|
2232
|
+
/** Note: [🟡] Code for CLI command [hello](src/cli/cli-commands/hello.ts) should never be published outside of `@promptbook/cli` */
|
|
2244
2233
|
/**
|
|
2245
2234
|
* TODO: [🧠][🐣] Make here some easter egg with generated hello greeting via LLM models
|
|
2246
2235
|
* Note: [💞] Ignore a discrepancy between file name and entity name
|
|
2247
|
-
* Note: [🟡] Code in this file should never be published outside of `@promptbook/cli`
|
|
2248
2236
|
*/
|
|
2249
2237
|
|
|
2250
2238
|
/**
|
|
@@ -2685,10 +2673,8 @@ function $provideFilesystemForNode(options) {
|
|
|
2685
2673
|
watch,
|
|
2686
2674
|
};
|
|
2687
2675
|
}
|
|
2688
|
-
/**
|
|
2689
|
-
|
|
2690
|
-
* TODO: [🏓] Unite `xxxForServer` and `xxxForNode` naming
|
|
2691
|
-
*/
|
|
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 */
|
|
2692
2678
|
|
|
2693
2679
|
/**
|
|
2694
2680
|
* Checks if the file exists
|
|
@@ -2774,9 +2760,7 @@ async function $provideEnvFilename() {
|
|
|
2774
2760
|
}
|
|
2775
2761
|
return null;
|
|
2776
2762
|
}
|
|
2777
|
-
/**
|
|
2778
|
-
* Note: [🟢] Code in this file should never be never released in packages that could be imported into browser environment
|
|
2779
|
-
*/
|
|
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 */
|
|
2780
2764
|
|
|
2781
2765
|
/**
|
|
2782
2766
|
* Stores data in .env variables
|
|
@@ -3860,10 +3844,8 @@ class FileCacheStorage {
|
|
|
3860
3844
|
// [0] When `setItem` and `removeItem` called, the state of the file system should be the same
|
|
3861
3845
|
}
|
|
3862
3846
|
}
|
|
3863
|
-
/**
|
|
3864
|
-
|
|
3865
|
-
* Note: [🟢] Code in this file should never be never released in packages that could be imported into browser environment
|
|
3866
|
-
*/
|
|
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 */
|
|
3867
3849
|
|
|
3868
3850
|
/**
|
|
3869
3851
|
* This error indicates problems parsing the format value
|
|
@@ -8153,9 +8135,7 @@ async function $provideLlmToolsConfigurationFromEnv() {
|
|
|
8153
8135
|
.filter((configuration) => configuration !== null);
|
|
8154
8136
|
return llmToolsConfiguration;
|
|
8155
8137
|
}
|
|
8156
|
-
/**
|
|
8157
|
-
* Note: [🟢] Code in this file should never be never released in packages that could be imported into browser environment
|
|
8158
|
-
*/
|
|
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 */
|
|
8159
8139
|
|
|
8160
8140
|
/**
|
|
8161
8141
|
* Profile for Multiple providers aggregation
|
|
@@ -8486,20 +8466,18 @@ async function $provideLlmToolsFromEnv(options = {}) {
|
|
|
8486
8466
|
}
|
|
8487
8467
|
return createLlmToolsFromConfiguration(configuration, options);
|
|
8488
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 */
|
|
8489
8470
|
/**
|
|
8490
8471
|
* TODO: The architecture for LLM tools configuration consists of three key functions:
|
|
8491
8472
|
* 1. `$provideLlmToolsFromEnv` - High-level function that detects available providers from env vars and returns ready-to-use LLM tools
|
|
8492
8473
|
* 2. `$provideLlmToolsConfigurationFromEnv` - Middle layer that extracts configuration objects from environment variables
|
|
8493
8474
|
* 3. `createLlmToolsFromConfiguration` - Low-level function that instantiates LLM tools from explicit configuration
|
|
8494
|
-
*
|
|
8495
8475
|
* This layered approach allows flexibility in how tools are configured:
|
|
8496
8476
|
* - Use $provideLlmToolsFromEnv for automatic detection and setup in Node.js environments
|
|
8497
8477
|
* - Use $provideLlmToolsConfigurationFromEnv to extract config objects for modification before instantiation
|
|
8498
8478
|
* - Use createLlmToolsFromConfiguration for explicit control over tool configurations
|
|
8499
|
-
*
|
|
8500
8479
|
* TODO: [🧠][🍛] Which name is better `$provideLlmToolsFromEnv` or `$provideLlmToolsFromEnvironment`?
|
|
8501
8480
|
* TODO: [🧠] Is there some meaningfull way how to test this util
|
|
8502
|
-
* Note: [🟢] Code in this file should never be never released in packages that could be imported into browser environment
|
|
8503
8481
|
* TODO: [🥃] Allow `ptbk make` without llm tools
|
|
8504
8482
|
* TODO: This should be maybe not under `_common` but under `utils`
|
|
8505
8483
|
* TODO: [®] DRY Register logic
|
|
@@ -8562,8 +8540,8 @@ async function $provideLlmToolsForWizardOrCli(options) {
|
|
|
8562
8540
|
isCacheReloaded,
|
|
8563
8541
|
});
|
|
8564
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 */
|
|
8565
8544
|
/**
|
|
8566
|
-
* Note: [🟢] Code in this file should never be never released in packages that could be imported into browser environment
|
|
8567
8545
|
* TODO: [👷♂️] Write a comprehensive manual about the construction of LLM tools
|
|
8568
8546
|
* TODO: [🥃] Allow `ptbk make` without llm tools
|
|
8569
8547
|
* TODO: This should be maybe not under `_common` but under `utils-internal` / `utils/internal`
|
|
@@ -8732,10 +8710,8 @@ function $initializeListModelsCommand(program) {
|
|
|
8732
8710
|
return process.exit(0);
|
|
8733
8711
|
}));
|
|
8734
8712
|
}
|
|
8735
|
-
/**
|
|
8736
|
-
|
|
8737
|
-
* Note: [🟡] Code in this file should never be published outside of `@promptbook/cli`
|
|
8738
|
-
*/
|
|
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 */
|
|
8739
8715
|
|
|
8740
8716
|
/**
|
|
8741
8717
|
* Normalize options for `execCommand` and `execCommands`
|
|
@@ -8902,9 +8878,7 @@ function $execCommand(options) {
|
|
|
8902
8878
|
}
|
|
8903
8879
|
});
|
|
8904
8880
|
}
|
|
8905
|
-
/**
|
|
8906
|
-
* Note: [🟢] Code in this file should never be never released in packages that could be imported into browser environment
|
|
8907
|
-
*/
|
|
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 */
|
|
8908
8882
|
|
|
8909
8883
|
/**
|
|
8910
8884
|
* Attempts to locate the specified application on a Linux system using the 'which' command.
|
|
@@ -8922,10 +8896,8 @@ async function locateAppOnLinux({ linuxWhich, }) {
|
|
|
8922
8896
|
return null;
|
|
8923
8897
|
}
|
|
8924
8898
|
}
|
|
8925
|
-
/**
|
|
8926
|
-
|
|
8927
|
-
* Note: [🟢] Code in this file should never be never released in packages that could be imported into browser environment
|
|
8928
|
-
*/
|
|
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` */
|
|
8929
8901
|
|
|
8930
8902
|
/**
|
|
8931
8903
|
* Checks if the file is executable
|
|
@@ -8978,10 +8950,8 @@ async function locateAppOnMacOs({ macOsName, }) {
|
|
|
8978
8950
|
return null;
|
|
8979
8951
|
}
|
|
8980
8952
|
}
|
|
8981
|
-
/**
|
|
8982
|
-
|
|
8983
|
-
* Note: [🟢] Code in this file should never be never released in packages that could be imported into browser environment
|
|
8984
|
-
*/
|
|
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` */
|
|
8985
8955
|
|
|
8986
8956
|
/**
|
|
8987
8957
|
* Attempts to locate the specified application on a Windows system by searching common installation directories.
|
|
@@ -9010,10 +8980,8 @@ async function locateAppOnWindows({ appName, windowsSuffix, }) {
|
|
|
9010
8980
|
return null;
|
|
9011
8981
|
}
|
|
9012
8982
|
}
|
|
9013
|
-
/**
|
|
9014
|
-
|
|
9015
|
-
* Note: [🟢] Code in this file should never be never released in packages that could be imported into browser environment
|
|
9016
|
-
*/
|
|
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` */
|
|
9017
8985
|
|
|
9018
8986
|
/**
|
|
9019
8987
|
* Locates an application on the system
|
|
@@ -9050,10 +9018,8 @@ function locateApp(options) {
|
|
|
9050
9018
|
}
|
|
9051
9019
|
}
|
|
9052
9020
|
}
|
|
9053
|
-
/**
|
|
9054
|
-
|
|
9055
|
-
* Note: [🟢] Code in this file should never be never released in packages that could be imported into browser environment
|
|
9056
|
-
*/
|
|
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` */
|
|
9057
9023
|
|
|
9058
9024
|
/**
|
|
9059
9025
|
* Locates the LibreOffice executable on the current system by searching platform-specific paths.
|
|
@@ -9069,10 +9035,8 @@ function locateLibreoffice() {
|
|
|
9069
9035
|
macOsName: 'LibreOffice',
|
|
9070
9036
|
});
|
|
9071
9037
|
}
|
|
9072
|
-
/**
|
|
9073
|
-
|
|
9074
|
-
* Note: [🟢] Code in this file should never be never released in packages that could be imported into browser environment
|
|
9075
|
-
*/
|
|
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` */
|
|
9076
9040
|
|
|
9077
9041
|
/**
|
|
9078
9042
|
* Locates the Pandoc executable on the current system by searching platform-specific paths.
|
|
@@ -9088,10 +9052,8 @@ function locatePandoc() {
|
|
|
9088
9052
|
macOsName: 'Pandoc',
|
|
9089
9053
|
});
|
|
9090
9054
|
}
|
|
9091
|
-
/**
|
|
9092
|
-
|
|
9093
|
-
* Note: [🟢] Code in this file should never be never released in packages that could be imported into browser environment
|
|
9094
|
-
*/
|
|
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` */
|
|
9095
9057
|
|
|
9096
9058
|
/**
|
|
9097
9059
|
* Provides paths to required executables (i.e. as Pandoc and LibreOffice) for Node.js environments.
|
|
@@ -9108,9 +9070,9 @@ async function $provideExecutablesForNode(options) {
|
|
|
9108
9070
|
// <- TODO: [🧠] `null` vs `undefined`
|
|
9109
9071
|
};
|
|
9110
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 */
|
|
9111
9074
|
/**
|
|
9112
9075
|
* TODO: [🧠] Allow to override the executables without need to call `locatePandoc` / `locateLibreoffice` in case of provided
|
|
9113
|
-
* Note: [🟢] Code in this file should never be never released in packages that could be imported into browser environment
|
|
9114
9076
|
* TODO: [🏓] Unite `xxxForServer` and `xxxForNode` naming
|
|
9115
9077
|
*/
|
|
9116
9078
|
|
|
@@ -9150,10 +9112,8 @@ async function $provideScrapersForNode(tools, options) {
|
|
|
9150
9112
|
}
|
|
9151
9113
|
return scrapers;
|
|
9152
9114
|
}
|
|
9153
|
-
/**
|
|
9154
|
-
|
|
9155
|
-
* TODO: [🏓] Unite `xxxForServer` and `xxxForNode` naming
|
|
9156
|
-
*/
|
|
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 */
|
|
9157
9117
|
|
|
9158
9118
|
/**
|
|
9159
9119
|
* Global registry for storing metadata about all available scrapers and converters.
|
|
@@ -9287,10 +9247,8 @@ function $initializeListScrapersCommand(program) {
|
|
|
9287
9247
|
return process.exit(0);
|
|
9288
9248
|
}));
|
|
9289
9249
|
}
|
|
9290
|
-
/**
|
|
9291
|
-
|
|
9292
|
-
* Note: [🟡] Code in this file should never be published outside of `@promptbook/cli`
|
|
9293
|
-
*/
|
|
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 */
|
|
9294
9252
|
|
|
9295
9253
|
/**
|
|
9296
9254
|
* Initializes `login` command for Promptbook CLI utilities
|
|
@@ -9317,10 +9275,10 @@ function $initializeLoginCommand(program) {
|
|
|
9317
9275
|
return process.exit(0);
|
|
9318
9276
|
}));
|
|
9319
9277
|
}
|
|
9278
|
+
/** Note: [🟡] Code for CLI command [login](src/cli/cli-commands/login.ts) should never be published outside of `@promptbook/cli` */
|
|
9320
9279
|
/**
|
|
9321
9280
|
* TODO: Implement non-interactive login
|
|
9322
9281
|
* Note: [💞] Ignore a discrepancy between file name and entity name
|
|
9323
|
-
* Note: [🟡] Code in this file should never be published outside of `@promptbook/cli`
|
|
9324
9282
|
*/
|
|
9325
9283
|
|
|
9326
9284
|
/**
|
|
@@ -9641,9 +9599,7 @@ async function loadArchive(filePath, fs) {
|
|
|
9641
9599
|
}
|
|
9642
9600
|
return collectionJson;
|
|
9643
9601
|
}
|
|
9644
|
-
/**
|
|
9645
|
-
* Note: [🟢] Code in this file should never be never released in packages that could be imported into browser environment
|
|
9646
|
-
*/
|
|
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 */
|
|
9647
9603
|
|
|
9648
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"}];
|
|
9649
9605
|
|
|
@@ -16056,12 +16012,12 @@ async function getScraperIntermediateSource(source, options) {
|
|
|
16056
16012
|
};
|
|
16057
16013
|
return fileHandler;
|
|
16058
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 */
|
|
16059
16016
|
/**
|
|
16060
16017
|
* Note: Not using `FileCacheStorage` for two reasons:
|
|
16061
16018
|
* 1) Need to store more than serialized JSONs
|
|
16062
16019
|
* 2) Need to switch between a `rootDirname` and `cacheDirname` <- TODO: [😡]
|
|
16063
16020
|
* TODO: [🐱🐉][🧠] Make some smart crop
|
|
16064
|
-
* Note: [🟢] Code in this file should never be never released in packages that could be imported into browser environment
|
|
16065
16021
|
*/
|
|
16066
16022
|
|
|
16067
16023
|
/**
|
|
@@ -16393,11 +16349,11 @@ class WebsiteScraper {
|
|
|
16393
16349
|
return knowledge;
|
|
16394
16350
|
}
|
|
16395
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 */
|
|
16396
16353
|
/**
|
|
16397
16354
|
* TODO: [👣] Scraped website in .md can act as cache item - there is no need to run conversion each time
|
|
16398
16355
|
* TODO: [🪂] Do it in parallel 11:11
|
|
16399
16356
|
* Note: No need to aggregate usage here, it is done by intercepting the llmTools
|
|
16400
|
-
* Note: [🟢] Code in this file should never be never released in packages that could be imported into browser environment
|
|
16401
16357
|
*/
|
|
16402
16358
|
|
|
16403
16359
|
/**
|
|
@@ -16520,9 +16476,7 @@ async function fetchUrlContent(url) {
|
|
|
16520
16476
|
`);
|
|
16521
16477
|
}
|
|
16522
16478
|
}
|
|
16523
|
-
/**
|
|
16524
|
-
* Note: [🟢] Code in this file should never be never released in packages that could be imported into browser environment
|
|
16525
|
-
*/
|
|
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 */
|
|
16526
16480
|
|
|
16527
16481
|
/**
|
|
16528
16482
|
* Cached implementation of `run_browser` when it can be resolved.
|
|
@@ -21113,10 +21067,6 @@ class StyleCommitmentDefinition extends BaseCommitmentDefinition {
|
|
|
21113
21067
|
* Prefix used for TEAM tool names.
|
|
21114
21068
|
*/
|
|
21115
21069
|
const TEAM_TOOL_PREFIX = 'team_chat_';
|
|
21116
|
-
/**
|
|
21117
|
-
* Length of URL hash suffix appended to TEAM tool names.
|
|
21118
|
-
*/
|
|
21119
|
-
const TEAM_TOOL_HASH_LENGTH = 10;
|
|
21120
21070
|
/**
|
|
21121
21071
|
* Fallback normalized name when teammate label is empty.
|
|
21122
21072
|
*/
|
|
@@ -21133,20 +21083,19 @@ function normalizeTeammateToolNamePart(teammateLabel) {
|
|
|
21133
21083
|
return normalized || TEAM_TOOL_FALLBACK_NAME;
|
|
21134
21084
|
}
|
|
21135
21085
|
/**
|
|
21136
|
-
* Builds a deterministic TEAM tool name from teammate
|
|
21086
|
+
* Builds a deterministic TEAM tool name from the teammate label.
|
|
21137
21087
|
*
|
|
21138
|
-
* The
|
|
21139
|
-
*
|
|
21088
|
+
* The tool name is derived solely from the human-readable label so that it
|
|
21089
|
+
* remains stable and predictable regardless of internal technical identifiers.
|
|
21140
21090
|
*
|
|
21141
|
-
* @param
|
|
21142
|
-
* @param teammateLabel - Human-readable teammate label.
|
|
21143
|
-
* @returns
|
|
21091
|
+
* @param _teammateUrl - Canonical teammate URL (kept for API compatibility, not used).
|
|
21092
|
+
* @param teammateLabel - Human-readable teammate label used as the basis for the name.
|
|
21093
|
+
* @returns TEAM tool name derived from the label.
|
|
21144
21094
|
* @private internal utility of TEAM commitments and chat UI mapping
|
|
21145
21095
|
*/
|
|
21146
|
-
function createTeamToolName(
|
|
21096
|
+
function createTeamToolName(_teammateUrl, teammateLabel) {
|
|
21147
21097
|
const normalizedLabel = normalizeTeammateToolNamePart(teammateLabel);
|
|
21148
|
-
|
|
21149
|
-
return `${TEAM_TOOL_PREFIX}${normalizedLabel}_${hash}`;
|
|
21098
|
+
return `${TEAM_TOOL_PREFIX}${normalizedLabel}`;
|
|
21150
21099
|
}
|
|
21151
21100
|
|
|
21152
21101
|
const urlRegex = /https?:\/\/[^\s]+/gi;
|
|
@@ -21351,7 +21300,7 @@ class TeamCommitmentDefinition extends BaseCommitmentDefinition {
|
|
|
21351
21300
|
`);
|
|
21352
21301
|
}
|
|
21353
21302
|
applyToAgentModelRequirements(requirements, content) {
|
|
21354
|
-
var _a, _b;
|
|
21303
|
+
var _a, _b, _c;
|
|
21355
21304
|
const trimmedContent = content.trim();
|
|
21356
21305
|
if (!trimmedContent) {
|
|
21357
21306
|
return requirements;
|
|
@@ -21363,14 +21312,18 @@ class TeamCommitmentDefinition extends BaseCommitmentDefinition {
|
|
|
21363
21312
|
}
|
|
21364
21313
|
const agentName = ((_a = requirements._metadata) === null || _a === void 0 ? void 0 : _a.agentName) || 'Agent';
|
|
21365
21314
|
const existingTeammates = ((_b = requirements._metadata) === null || _b === void 0 ? void 0 : _b.teammates) || [];
|
|
21315
|
+
const preResolvedProfiles = (((_c = requirements._metadata) === null || _c === void 0 ? void 0 : _c.preResolvedTeammateProfiles) || {});
|
|
21366
21316
|
const resolvedTeammates = resolveTeamTeammateLabels(trimmedContent, teammates);
|
|
21367
21317
|
const teamEntries = resolvedTeammates.map((teammate) => {
|
|
21318
|
+
const profile = preResolvedProfiles[teammate.url];
|
|
21319
|
+
const resolvedLabel = (profile === null || profile === void 0 ? void 0 : profile.agentName) || teammate.label;
|
|
21368
21320
|
const existingTeammate = existingTeammates.find((entry) => entry.url === teammate.url);
|
|
21369
21321
|
return {
|
|
21370
21322
|
toolName: ((existingTeammate === null || existingTeammate === void 0 ? void 0 : existingTeammate.toolName) ||
|
|
21371
|
-
createTeamToolName(teammate.url,
|
|
21372
|
-
teammate,
|
|
21323
|
+
createTeamToolName(teammate.url, resolvedLabel)),
|
|
21324
|
+
teammate: { ...teammate, label: resolvedLabel },
|
|
21373
21325
|
agentName,
|
|
21326
|
+
description: (profile === null || profile === void 0 ? void 0 : profile.personaDescription) || null,
|
|
21374
21327
|
};
|
|
21375
21328
|
});
|
|
21376
21329
|
for (const entry of teamEntries) {
|
|
@@ -21382,9 +21335,12 @@ class TeamCommitmentDefinition extends BaseCommitmentDefinition {
|
|
|
21382
21335
|
if (updatedTools.some((tool) => tool.name === entry.toolName)) {
|
|
21383
21336
|
continue;
|
|
21384
21337
|
}
|
|
21338
|
+
const toolDescription = entry.description
|
|
21339
|
+
? `Consult teammate ${entry.teammate.label}\n${entry.description}`
|
|
21340
|
+
: `Consult teammate ${entry.teammate.label}`;
|
|
21385
21341
|
updatedTools.push({
|
|
21386
21342
|
name: entry.toolName,
|
|
21387
|
-
description:
|
|
21343
|
+
description: toolDescription,
|
|
21388
21344
|
parameters: {
|
|
21389
21345
|
type: 'object',
|
|
21390
21346
|
properties: {
|
|
@@ -21413,8 +21369,7 @@ class TeamCommitmentDefinition extends BaseCommitmentDefinition {
|
|
|
21413
21369
|
toolName: entry.toolName,
|
|
21414
21370
|
});
|
|
21415
21371
|
}
|
|
21416
|
-
const
|
|
21417
|
-
const teamSystemMessage = this.createSystemMessageSection('Teammates:', buildTeamSystemMessageBody(teamOverviewText, teamEntries));
|
|
21372
|
+
const teamSystemMessage = this.createSystemMessageSection('Teammates:', buildTeamSystemMessageBody(teamEntries));
|
|
21418
21373
|
return this.appendToSystemMessage({
|
|
21419
21374
|
...requirements,
|
|
21420
21375
|
tools: updatedTools,
|
|
@@ -21451,25 +21406,24 @@ function resolveTeamTeammateLabels(teamContent, teammates) {
|
|
|
21451
21406
|
};
|
|
21452
21407
|
});
|
|
21453
21408
|
}
|
|
21454
|
-
/**
|
|
21455
|
-
* Rewrites TEAM commitment content into a URL-free teammate overview text.
|
|
21456
|
-
*/
|
|
21457
|
-
function createTeamOverviewText(teamContent, teamEntries) {
|
|
21458
|
-
let overviewText = teamContent;
|
|
21459
|
-
for (const entry of teamEntries) {
|
|
21460
|
-
overviewText = overviewText.split(entry.teammate.url).join(entry.teammate.label);
|
|
21461
|
-
}
|
|
21462
|
-
return overviewText.trim();
|
|
21463
|
-
}
|
|
21464
21409
|
/**
|
|
21465
21410
|
* Builds the textual TEAM section body for the final system message.
|
|
21411
|
+
*
|
|
21412
|
+
* Each teammate is listed with its tool name and, when available, a one-line description.
|
|
21413
|
+
* Uses `spaceTrim` to ensure consistent whitespace and indentation.
|
|
21466
21414
|
*/
|
|
21467
|
-
function buildTeamSystemMessageBody(
|
|
21468
|
-
const
|
|
21469
|
-
|
|
21470
|
-
|
|
21471
|
-
|
|
21472
|
-
|
|
21415
|
+
function buildTeamSystemMessageBody(teamEntries) {
|
|
21416
|
+
const lines = teamEntries.map((entry, index) => {
|
|
21417
|
+
const toolLine = `${index + 1}) ${entry.teammate.label} tool \`${entry.toolName}\``;
|
|
21418
|
+
if (!entry.description) {
|
|
21419
|
+
return toolLine;
|
|
21420
|
+
}
|
|
21421
|
+
return spaceTrim$1(`
|
|
21422
|
+
${toolLine}
|
|
21423
|
+
${entry.description}
|
|
21424
|
+
`);
|
|
21425
|
+
});
|
|
21426
|
+
return lines.join('\n');
|
|
21473
21427
|
}
|
|
21474
21428
|
/**
|
|
21475
21429
|
* Registers tool function and title for a teammate tool.
|
|
@@ -28278,10 +28232,8 @@ async function $provideExecutionToolsForNode(options) {
|
|
|
28278
28232
|
};
|
|
28279
28233
|
return tools;
|
|
28280
28234
|
}
|
|
28281
|
-
/**
|
|
28282
|
-
|
|
28283
|
-
* TODO: [🏓] Unite `xxxForServer` and `xxxForNode` naming
|
|
28284
|
-
*/
|
|
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 */
|
|
28285
28237
|
|
|
28286
28238
|
/**
|
|
28287
28239
|
* Checks if the directory exists
|
|
@@ -28631,10 +28583,10 @@ async function saveArchive(filePath, collectionJson, fs) {
|
|
|
28631
28583
|
const data = await archive.generateAsync({ type: 'nodebuffer', streamFiles: true });
|
|
28632
28584
|
await fs.writeFile(filePath, data);
|
|
28633
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 */
|
|
28634
28587
|
/**
|
|
28635
28588
|
* TODO: Add metadata to zip
|
|
28636
28589
|
* TODO: Compression level and other zip options from config
|
|
28637
|
-
* Note: [🟢] Code in this file should never be never released in packages that could be imported into browser environment
|
|
28638
28590
|
*/
|
|
28639
28591
|
|
|
28640
28592
|
/**
|
|
@@ -28722,10 +28674,8 @@ async function $provideScriptingForNode(options) {
|
|
|
28722
28674
|
// TODO: [🔱] Do here auto-installation
|
|
28723
28675
|
return [new JavascriptExecutionTools({ ...options, functions: getAllCommitmentsToolFunctionsForNode() })];
|
|
28724
28676
|
}
|
|
28725
|
-
/**
|
|
28726
|
-
|
|
28727
|
-
* TODO: [🏓] Unite `xxxForServer` and `xxxForNode` naming
|
|
28728
|
-
*/
|
|
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 */
|
|
28729
28679
|
|
|
28730
28680
|
/**
|
|
28731
28681
|
* Initializes `make` command for Promptbook CLI utilities
|
|
@@ -28964,11 +28914,11 @@ function $initializeMakeCommand(program) {
|
|
|
28964
28914
|
return process.exit(0);
|
|
28965
28915
|
}));
|
|
28966
28916
|
}
|
|
28917
|
+
/** Note: [🟡] Code for CLI command [make](src/cli/cli-commands/make.ts) should never be published outside of `@promptbook/cli` */
|
|
28967
28918
|
/**
|
|
28968
28919
|
* TODO: [🥃][main] !!3 Allow `ptbk make` without configuring any llm tools
|
|
28969
28920
|
* TODO: [0] DRY Javascript and typescript - Maybe make ONLY typescript and for javascript just remove types
|
|
28970
28921
|
* Note: [💞] Ignore a discrepancy between file name and entity name
|
|
28971
|
-
* Note: [🟡] Code in this file should never be published outside of `@promptbook/cli`
|
|
28972
28922
|
* TODO: [🖇] What about symlinks? Maybe flag --follow-symlinks
|
|
28973
28923
|
*/
|
|
28974
28924
|
|
|
@@ -29102,10 +29052,10 @@ function $initializePrettifyCommand(program) {
|
|
|
29102
29052
|
return process.exit(0);
|
|
29103
29053
|
}));
|
|
29104
29054
|
}
|
|
29055
|
+
/** Note: [🟡] Code for CLI command [prettify](src/cli/cli-commands/prettify.ts) should never be published outside of `@promptbook/cli` */
|
|
29105
29056
|
/**
|
|
29106
29057
|
* TODO: [😶] Unite folder listing
|
|
29107
29058
|
* Note: [💞] Ignore a discrepancy between file name and entity name
|
|
29108
|
-
* Note: [🟡] Code in this file should never be published outside of `@promptbook/cli`
|
|
29109
29059
|
* TODO: [🖇] What about symlinks? Maybe flag --follow-symlinks
|
|
29110
29060
|
*/
|
|
29111
29061
|
|
|
@@ -29560,10 +29510,8 @@ async function $getCompiledBook(tools, pipelineSource, options) {
|
|
|
29560
29510
|
|
|
29561
29511
|
`));
|
|
29562
29512
|
}
|
|
29563
|
-
/**
|
|
29564
|
-
|
|
29565
|
-
* Note: [🟢] Code in this file should never be never released in packages that could be imported into browser environment
|
|
29566
|
-
*/
|
|
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 */
|
|
29567
29515
|
|
|
29568
29516
|
/**
|
|
29569
29517
|
* Run the interactive chatbot in CLI
|
|
@@ -29662,10 +29610,10 @@ async function runInteractiveChatbot(options) {
|
|
|
29662
29610
|
}
|
|
29663
29611
|
}
|
|
29664
29612
|
}
|
|
29613
|
+
/** Note: [🟡] Code for CLI command [runInteractiveChatbot](src/cli/cli-commands/runInteractiveChatbot.ts) should never be published outside of `@promptbook/cli` */
|
|
29665
29614
|
/**
|
|
29666
29615
|
* TODO: Saving reports from the chatbot conversation
|
|
29667
29616
|
* TODO: [⛲️] This is the right place to start implementing INK
|
|
29668
|
-
* Note: [🟡] Code in this file should never be published outside of `@promptbook/cli`
|
|
29669
29617
|
*/
|
|
29670
29618
|
|
|
29671
29619
|
/**
|
|
@@ -29920,12 +29868,12 @@ function $initializeRunCommand(program) {
|
|
|
29920
29868
|
return process.exit(0);
|
|
29921
29869
|
}));
|
|
29922
29870
|
}
|
|
29871
|
+
/** Note: [🟡] Code for CLI command [run](src/cli/cli-commands/run.ts) should never be published outside of `@promptbook/cli` */
|
|
29923
29872
|
/**
|
|
29924
29873
|
* TODO: !!5 Catch and wrap all errors from CLI
|
|
29925
29874
|
* TODO: [🧠] Pass `maxExecutionAttempts`, `csvSettings`
|
|
29926
29875
|
* TODO: [🥃][main] !!3 Allow `ptbk run` without configuring any llm tools
|
|
29927
29876
|
* Note: [💞] Ignore a discrepancy between file name and entity name
|
|
29928
|
-
* Note: [🟡] Code in this file should never be published outside of `@promptbook/cli`
|
|
29929
29877
|
* TODO: [🖇] What about symlinks? Maybe flag --follow-symlinks
|
|
29930
29878
|
*/
|
|
29931
29879
|
|
|
@@ -29954,9 +29902,7 @@ async function startAgentServer(options) {
|
|
|
29954
29902
|
isVerbose: true,
|
|
29955
29903
|
});
|
|
29956
29904
|
}
|
|
29957
|
-
/**
|
|
29958
|
-
* Note: [🟢] Code in this file should never be never released in packages that could be imported into browser environment
|
|
29959
|
-
*/
|
|
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 */
|
|
29960
29906
|
|
|
29961
29907
|
/**
|
|
29962
29908
|
* Initializes `start-agents-server` command for Promptbook CLI utilities
|
|
@@ -30040,10 +29986,8 @@ function $initializeStartAgentsServerCommand(program) {
|
|
|
30040
29986
|
await startAgentServer({ port });
|
|
30041
29987
|
}));
|
|
30042
29988
|
}
|
|
30043
|
-
/**
|
|
30044
|
-
|
|
30045
|
-
* Note: [🟡] Code in this file should never be published outside of `@promptbook/cli`
|
|
30046
|
-
*/
|
|
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 */
|
|
30047
29991
|
|
|
30048
29992
|
// TODO: [🥺] List running services from REMOTE_SERVER_URLS
|
|
30049
29993
|
// TODO: [🥺] Import directly from YML
|
|
@@ -31249,8 +31193,8 @@ function startRemoteServer(options) {
|
|
|
31249
31193
|
},
|
|
31250
31194
|
};
|
|
31251
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 */
|
|
31252
31197
|
/**
|
|
31253
|
-
|
|
31254
31198
|
* TODO: [🕋] Use here `aboutPromptbookInformation`
|
|
31255
31199
|
* TODO: [🌡] Add CORS and security - probably via `helmet`
|
|
31256
31200
|
* TODO: Split this file into multiple functions - handler for each request
|
|
@@ -31263,7 +31207,6 @@ function startRemoteServer(options) {
|
|
|
31263
31207
|
* TODO: [🃏] Pass here some security token to prevent malitious usage and/or DDoS
|
|
31264
31208
|
* TODO: [0] Set unavailable models as undefined in `RemoteLlmExecutionTools` NOT throw error here
|
|
31265
31209
|
* TODO: Allow to constrain anonymous mode for specific models / providers
|
|
31266
|
-
* Note: [🟢] Code in this file should never be never released in packages that could be imported into browser environment
|
|
31267
31210
|
*/
|
|
31268
31211
|
|
|
31269
31212
|
/**
|
|
@@ -31365,10 +31308,10 @@ function $initializeStartPipelinesServerCommand(program) {
|
|
|
31365
31308
|
return await forEver();
|
|
31366
31309
|
}));
|
|
31367
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` */
|
|
31368
31312
|
/**
|
|
31369
31313
|
* TODO: [🕋] Use here `aboutPromptbookInformation`
|
|
31370
31314
|
* Note: [💞] Ignore a discrepancy between file name and entity name
|
|
31371
|
-
* Note: [🟡] Code in this file should never be published outside of `@promptbook/cli`
|
|
31372
31315
|
*/
|
|
31373
31316
|
|
|
31374
31317
|
/**
|
|
@@ -31455,10 +31398,10 @@ function $initializeTestCommand(program) {
|
|
|
31455
31398
|
return process.exit(0);
|
|
31456
31399
|
}));
|
|
31457
31400
|
}
|
|
31401
|
+
/** Note: [🟡] Code for CLI command [test-command](src/cli/cli-commands/test-command.ts) should never be published outside of `@promptbook/cli` */
|
|
31458
31402
|
/**
|
|
31459
31403
|
* TODO: [😶] Unite folder listing
|
|
31460
31404
|
* Note: [💞] Ignore a discrepancy between file name and entity name
|
|
31461
|
-
* Note: [🟡] Code in this file should never be published outside of `@promptbook/cli`
|
|
31462
31405
|
* TODO: [🖇] What about symlinks? Maybe flag --follow-symlinks
|
|
31463
31406
|
* Note: This is named "test-command.ts" to avoid name collision with jest unit test files
|
|
31464
31407
|
*/
|
|
@@ -31516,12 +31459,12 @@ async function promptbookCli() {
|
|
|
31516
31459
|
program.commands.forEach($addGlobalOptionsToCommand);
|
|
31517
31460
|
program.parse(process.argv);
|
|
31518
31461
|
}
|
|
31462
|
+
/** Note: [🟡] Code for CLI program [promptbookCli](src/cli/promptbookCli.ts) should never be published outside of `@promptbook/cli` */
|
|
31519
31463
|
/**
|
|
31520
31464
|
* TODO: [🧠] Maybe `run` command the default, instead of `ptbk run ./foo.book` -> `ptbk ./foo.book`
|
|
31521
31465
|
* TODO: [🥠] Do not export, its just for CLI script
|
|
31522
31466
|
* TODO: [🕌] When more functionalities, rename
|
|
31523
31467
|
* Note: 11:11
|
|
31524
|
-
* Note: [🟡] Code in this file should never be published outside of `@promptbook/cli`
|
|
31525
31468
|
*/
|
|
31526
31469
|
|
|
31527
31470
|
/**
|
|
@@ -31542,9 +31485,7 @@ async function $runPromptbookCli() {
|
|
|
31542
31485
|
}
|
|
31543
31486
|
await promptbookCli();
|
|
31544
31487
|
}
|
|
31545
|
-
/**
|
|
31546
|
-
* Note: [🟡] Code in this file should never be published outside of `@promptbook/cli`
|
|
31547
|
-
*/
|
|
31488
|
+
/** Note: [🟡] Code for CLI bootstrap [$runPromptbookCli](src/cli/$runPromptbookCli.ts) should never be published outside of `@promptbook/cli` */
|
|
31548
31489
|
|
|
31549
31490
|
/**
|
|
31550
31491
|
* Note: [🔺] Purpose of this file is to export CLI for production environment
|
|
@@ -31558,10 +31499,8 @@ const _CLI = {
|
|
|
31558
31499
|
// Note: [🥠]
|
|
31559
31500
|
_initialize_promptbookCli: $runPromptbookCli,
|
|
31560
31501
|
};
|
|
31561
|
-
/**
|
|
31562
|
-
|
|
31563
|
-
* Note: [🟡] Code in this file should never be published outside of `@promptbook/cli`
|
|
31564
|
-
*/
|
|
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 */
|
|
31565
31504
|
|
|
31566
31505
|
/**
|
|
31567
31506
|
* Registration of LLM provider metadata
|
|
@@ -37887,12 +37826,10 @@ class BoilerplateScraper {
|
|
|
37887
37826
|
return knowledge;
|
|
37888
37827
|
}
|
|
37889
37828
|
}
|
|
37890
|
-
/**
|
|
37891
|
-
|
|
37892
|
-
|
|
37893
|
-
|
|
37894
|
-
* @@ Note: [🟢] Code in this file should never be never released in packages that could be imported into browser environment
|
|
37895
|
-
*/
|
|
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 */
|
|
37896
37833
|
|
|
37897
37834
|
/**
|
|
37898
37835
|
* Constructor of `BoilerplateScraper`
|
|
@@ -38050,11 +37987,11 @@ class DocumentScraper {
|
|
|
38050
37987
|
return knowledge;
|
|
38051
37988
|
}
|
|
38052
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 */
|
|
38053
37991
|
/**
|
|
38054
37992
|
* TODO: [👣] Converted documents can act as cached items - there is no need to run conversion each time
|
|
38055
37993
|
* TODO: [🪂] Do it in parallel 11:11
|
|
38056
37994
|
* Note: No need to aggregate usage here, it is done by intercepting the llmTools
|
|
38057
|
-
* Note: [🟢] Code in this file should never be never released in packages that could be imported into browser environment
|
|
38058
37995
|
*/
|
|
38059
37996
|
|
|
38060
37997
|
/**
|
|
@@ -38217,11 +38154,11 @@ class LegacyDocumentScraper {
|
|
|
38217
38154
|
return knowledge;
|
|
38218
38155
|
}
|
|
38219
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 */
|
|
38220
38158
|
/**
|
|
38221
38159
|
* TODO: [👣] Converted documents can act as cached items - there is no need to run conversion each time
|
|
38222
38160
|
* TODO: [🪂] Do it in parallel 11:11
|
|
38223
38161
|
* Note: No need to aggregate usage here, it is done by intercepting the llmTools
|
|
38224
|
-
* Note: [🟢] Code in this file should never be never released in packages that could be imported into browser environment
|
|
38225
38162
|
*/
|
|
38226
38163
|
|
|
38227
38164
|
/**
|
|
@@ -38455,12 +38392,12 @@ class MarkitdownScraper {
|
|
|
38455
38392
|
return knowledge;
|
|
38456
38393
|
}
|
|
38457
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 */
|
|
38458
38396
|
/**
|
|
38459
38397
|
* TODO: [🧠][🌜] Export only from `@promptbook/markitdown` or `@promptbook/pdf` NOT both
|
|
38460
38398
|
* TODO: [👣] Converted documents can act as cached items - there is no need to run conversion each time
|
|
38461
38399
|
* TODO: [🪂] Do it in parallel
|
|
38462
38400
|
* Note: No need to aggregate usage here, it is done by intercepting the llmTools
|
|
38463
|
-
* Note: [🟢] Code in this file should never be never released in packages that could be imported into browser environment
|
|
38464
38401
|
*/
|
|
38465
38402
|
|
|
38466
38403
|
/**
|
|
@@ -38564,11 +38501,11 @@ class PdfScraper {
|
|
|
38564
38501
|
throw new NotYetImplementedError('PDF scraping not yet implemented');
|
|
38565
38502
|
}
|
|
38566
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 */
|
|
38567
38505
|
/**
|
|
38568
38506
|
* TODO: [👣] Converted pdf documents can act as cached items - there is no need to run conversion each time
|
|
38569
38507
|
* TODO: [🪂] Do it in parallel 11:11
|
|
38570
38508
|
* Note: No need to aggregate usage here, it is done by intercepting the llmTools
|
|
38571
|
-
* Note: [🟢] Code in this file should never be never released in packages that could be imported into browser environment
|
|
38572
38509
|
*/
|
|
38573
38510
|
|
|
38574
38511
|
/**
|
|
@@ -39117,7 +39054,7 @@ function getSafeReferenceCommitmentFallback(commitmentType, originalContent) {
|
|
|
39117
39054
|
* @private @@@
|
|
39118
39055
|
*/
|
|
39119
39056
|
async function createAgentModelRequirementsWithCommitments(agentSource, modelName, options) {
|
|
39120
|
-
var _a;
|
|
39057
|
+
var _a, _b, _c;
|
|
39121
39058
|
const agentReferenceResolver = options === null || options === void 0 ? void 0 : options.agentReferenceResolver;
|
|
39122
39059
|
// Parse the agent source to extract commitments
|
|
39123
39060
|
const parseResult = parseAgentSourceWithCommitments(agentSource);
|
|
@@ -39185,6 +39122,36 @@ async function createAgentModelRequirementsWithCommitments(agentSource, modelNam
|
|
|
39185
39122
|
if (commitment.type === 'CLOSED' && i !== filteredCommitments.length - 1) {
|
|
39186
39123
|
continue;
|
|
39187
39124
|
}
|
|
39125
|
+
// For TEAM commitments, pre-resolve teammate profiles if a resolver is provided
|
|
39126
|
+
// and store them in metadata before the commitment is applied.
|
|
39127
|
+
const profileResolver = (_a = options === null || options === void 0 ? void 0 : options.teammateProfileResolver) !== null && _a !== void 0 ? _a : options === null || options === void 0 ? void 0 : options.agentReferenceResolver;
|
|
39128
|
+
if (commitment.type === 'TEAM' && (profileResolver === null || profileResolver === void 0 ? void 0 : profileResolver.resolveTeammateProfile)) {
|
|
39129
|
+
try {
|
|
39130
|
+
const parsedTeammates = parseTeamCommitmentContent(commitmentContent, { strict: false });
|
|
39131
|
+
const preResolved = {
|
|
39132
|
+
...(_b = requirements._metadata) === null || _b === void 0 ? void 0 : _b.preResolvedTeammateProfiles,
|
|
39133
|
+
};
|
|
39134
|
+
for (const teammate of parsedTeammates) {
|
|
39135
|
+
if (preResolved[teammate.url]) {
|
|
39136
|
+
continue;
|
|
39137
|
+
}
|
|
39138
|
+
const profile = await profileResolver.resolveTeammateProfile(teammate.url);
|
|
39139
|
+
if (profile) {
|
|
39140
|
+
preResolved[teammate.url] = profile;
|
|
39141
|
+
}
|
|
39142
|
+
}
|
|
39143
|
+
requirements = {
|
|
39144
|
+
...requirements,
|
|
39145
|
+
_metadata: {
|
|
39146
|
+
...requirements._metadata,
|
|
39147
|
+
preResolvedTeammateProfiles: preResolved,
|
|
39148
|
+
},
|
|
39149
|
+
};
|
|
39150
|
+
}
|
|
39151
|
+
catch (error) {
|
|
39152
|
+
console.warn('Failed to pre-resolve teammate profiles for TEAM commitment:', error);
|
|
39153
|
+
}
|
|
39154
|
+
}
|
|
39188
39155
|
const definition = getCommitmentDefinition(commitment.type);
|
|
39189
39156
|
if (definition) {
|
|
39190
39157
|
try {
|
|
@@ -39280,7 +39247,7 @@ async function createAgentModelRequirementsWithCommitments(agentSource, modelNam
|
|
|
39280
39247
|
// Add example interactions to the system message
|
|
39281
39248
|
const examples = [];
|
|
39282
39249
|
// 1. Initial message as an example agent response
|
|
39283
|
-
const initialMessage = (
|
|
39250
|
+
const initialMessage = (_c = parseResult.commitments.find((c) => c.type === 'INITIAL MESSAGE')) === null || _c === void 0 ? void 0 : _c.content;
|
|
39284
39251
|
if (initialMessage) {
|
|
39285
39252
|
examples.push(`Agent: ${initialMessage}`);
|
|
39286
39253
|
}
|
|
@@ -40415,15 +40382,357 @@ async function findFreshEmojiTag() {
|
|
|
40415
40382
|
//========================================/
|
|
40416
40383
|
// console.info(`[ Done 🤪 Find fresh emoji tag ]`);
|
|
40417
40384
|
}
|
|
40418
|
-
/**
|
|
40419
|
-
* Note: [🟡] Code in this file should never be published outside of `@promptbook/cli`
|
|
40420
|
-
*/
|
|
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` */
|
|
40421
40386
|
|
|
40422
40387
|
var findFreshEmojiTags = /*#__PURE__*/Object.freeze({
|
|
40423
40388
|
__proto__: null,
|
|
40424
40389
|
findFreshEmojiTag: findFreshEmojiTag
|
|
40425
40390
|
});
|
|
40426
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
|
+
|
|
40427
40736
|
/**
|
|
40428
40737
|
* Calculates the next available prompt numbering sequence for a month.
|
|
40429
40738
|
*/
|
|
@@ -40563,203 +40872,10 @@ var promptEmojiTags = /*#__PURE__*/Object.freeze({
|
|
|
40563
40872
|
getFreshPromptEmojiTags: getFreshPromptEmojiTags
|
|
40564
40873
|
});
|
|
40565
40874
|
|
|
40566
|
-
/**
|
|
40567
|
-
* Root folders that contain source-like files for scanning.
|
|
40568
|
-
*/
|
|
40569
|
-
const SOURCE_ROOTS = ['src', 'apps', 'scripts', 'examples', 'agents', 'other'];
|
|
40570
|
-
/**
|
|
40571
|
-
* File extensions treated as source code.
|
|
40572
|
-
*/
|
|
40573
|
-
const SOURCE_FILE_EXTENSIONS = ['.ts', '.tsx', '.js', '.jsx'];
|
|
40574
|
-
/**
|
|
40575
|
-
* Glob patterns that should be ignored when scanning for source files.
|
|
40576
|
-
*/
|
|
40577
|
-
const SOURCE_FILE_IGNORE_GLOBS = [
|
|
40578
|
-
'**/node_modules/**',
|
|
40579
|
-
'**/packages/**',
|
|
40580
|
-
'**/.*/**',
|
|
40581
|
-
'**/.git/**',
|
|
40582
|
-
'**/.idea/**',
|
|
40583
|
-
'**/.vscode/**',
|
|
40584
|
-
'**/.promptbook/**',
|
|
40585
|
-
'**/.next/**',
|
|
40586
|
-
'**/.tmp/**',
|
|
40587
|
-
'**/tmp/**',
|
|
40588
|
-
'**/coverage/**',
|
|
40589
|
-
'**/dist/**',
|
|
40590
|
-
'**/build/**',
|
|
40591
|
-
'**/out/**',
|
|
40592
|
-
'**/prompts/**',
|
|
40593
|
-
'**/changelog/**',
|
|
40594
|
-
];
|
|
40595
|
-
/**
|
|
40596
|
-
* Default maximum line count for source files.
|
|
40597
|
-
*/
|
|
40598
|
-
const DEFAULT_MAX_LINE_COUNT = 2000;
|
|
40599
|
-
/**
|
|
40600
|
-
* Per-extension line count limits.
|
|
40601
|
-
*/
|
|
40602
|
-
const LINE_COUNT_LIMITS_BY_EXTENSION = {
|
|
40603
|
-
'.ts': 2000,
|
|
40604
|
-
'.tsx': 2000,
|
|
40605
|
-
'.js': 2000,
|
|
40606
|
-
'.jsx': 2000,
|
|
40607
|
-
};
|
|
40608
|
-
/**
|
|
40609
|
-
* Glob patterns that are exempt from line-count checks.
|
|
40610
|
-
*/
|
|
40611
|
-
const LINE_COUNT_EXEMPT_GLOBS = ['other/cspell-dictionaries/**/*.txt'];
|
|
40612
|
-
/**
|
|
40613
|
-
* Maximum number of entities before a file is flagged.
|
|
40614
|
-
*/
|
|
40615
|
-
const MAX_ENTITIES_PER_FILE = 20;
|
|
40616
|
-
/**
|
|
40617
|
-
* File extensions eligible for entity counting.
|
|
40618
|
-
*/
|
|
40619
|
-
const ENTITY_COUNT_EXTENSIONS = ['.ts', '.tsx', '.js', '.jsx'];
|
|
40620
|
-
/**
|
|
40621
|
-
* Markers that identify generated files which should be skipped.
|
|
40622
|
-
*/
|
|
40623
|
-
const GENERATED_CODE_MARKERS = [
|
|
40624
|
-
'WARNING: This code has been generated',
|
|
40625
|
-
'This code has been generated so that any manual changes will be overwritten',
|
|
40626
|
-
];
|
|
40627
|
-
/**
|
|
40628
|
-
* Name of the prompts directory.
|
|
40629
|
-
*/
|
|
40630
|
-
const PROMPTS_DIR_NAME = 'prompts';
|
|
40631
|
-
/**
|
|
40632
|
-
* Step size used for prompt numbering.
|
|
40633
|
-
*/
|
|
40634
|
-
const PROMPT_NUMBER_STEP = 10;
|
|
40635
|
-
/**
|
|
40636
|
-
* Prefix used for generated prompt slugs.
|
|
40637
|
-
*/
|
|
40638
|
-
const PROMPT_SLUG_PREFIX = 'refactor';
|
|
40639
|
-
/**
|
|
40640
|
-
* Label used to mark the target file in generated prompts.
|
|
40641
|
-
*/
|
|
40642
|
-
const PROMPT_TARGET_LABEL = 'Target file';
|
|
40643
|
-
/**
|
|
40644
|
-
* Maximum length for generated prompt slugs.
|
|
40645
|
-
*/
|
|
40646
|
-
const PROMPT_SLUG_MAX_LENGTH = 80;
|
|
40647
|
-
/**
|
|
40648
|
-
* Note: [?] Code in this file should never be published in any package
|
|
40649
|
-
*/
|
|
40650
|
-
|
|
40651
|
-
if (require.main === module) {
|
|
40652
|
-
findRefactorCandidates()
|
|
40653
|
-
.catch((error) => {
|
|
40654
|
-
assertsError(error);
|
|
40655
|
-
console.error(colors.bgRed(`${error.name} in ${basename(__filename)}`));
|
|
40656
|
-
console.error(colors.red(error.stack || error.message));
|
|
40657
|
-
process.exit(1);
|
|
40658
|
-
})
|
|
40659
|
-
.then(() => {
|
|
40660
|
-
process.exit(0);
|
|
40661
|
-
});
|
|
40662
|
-
}
|
|
40663
|
-
/**
|
|
40664
|
-
* Initializes environment for this script.
|
|
40665
|
-
*
|
|
40666
|
-
* @private utility for `findRefactorCandidates`
|
|
40667
|
-
*/
|
|
40668
|
-
function initializeFindRefactorCandidatesRun() {
|
|
40669
|
-
dotenv.config({ path: '.env' });
|
|
40670
|
-
}
|
|
40671
|
-
/**
|
|
40672
|
-
* Orchestrates scanning for refactor candidates and generating prompts.
|
|
40673
|
-
*
|
|
40674
|
-
* @public exported from `@promptbook/cli`
|
|
40675
|
-
*/
|
|
40676
|
-
async function findRefactorCandidates() {
|
|
40677
|
-
initializeFindRefactorCandidatesRun();
|
|
40678
|
-
console.info(colors.cyan('?? Find refactor candidates'));
|
|
40679
|
-
const rootDir = process.cwd();
|
|
40680
|
-
const promptsDir = join(rootDir, PROMPTS_DIR_NAME);
|
|
40681
|
-
const existingTargets = await loadExistingPromptTargets(promptsDir);
|
|
40682
|
-
const lineCountExemptPaths = await buildExemptPathSet(rootDir, LINE_COUNT_EXEMPT_GLOBS);
|
|
40683
|
-
const sourceFiles = await listSourceFiles(rootDir);
|
|
40684
|
-
const candidates = [];
|
|
40685
|
-
for (const filePath of sourceFiles) {
|
|
40686
|
-
const normalizedPath = normalizeAbsolutePath(filePath);
|
|
40687
|
-
const content = await readFile(filePath, 'utf-8');
|
|
40688
|
-
if (isGeneratedFile(content)) {
|
|
40689
|
-
continue;
|
|
40690
|
-
}
|
|
40691
|
-
const extension = extname(filePath).toLowerCase();
|
|
40692
|
-
const relativePath = normalizeRelativePath(relative(rootDir, filePath));
|
|
40693
|
-
const reasons = [];
|
|
40694
|
-
if (!lineCountExemptPaths.has(normalizedPath)) {
|
|
40695
|
-
const lineCount = countLines(content);
|
|
40696
|
-
const maxLines = getMaxLinesForExtension(extension);
|
|
40697
|
-
if (lineCount > maxLines) {
|
|
40698
|
-
reasons.push(`lines ${lineCount}/${maxLines}`);
|
|
40699
|
-
}
|
|
40700
|
-
}
|
|
40701
|
-
if (ENTITY_COUNT_EXTENSIONS.includes(extension)) {
|
|
40702
|
-
const entityCount = countEntities(content, extension, filePath);
|
|
40703
|
-
if (entityCount > MAX_ENTITIES_PER_FILE) {
|
|
40704
|
-
reasons.push(`entities ${entityCount}/${MAX_ENTITIES_PER_FILE}`);
|
|
40705
|
-
}
|
|
40706
|
-
}
|
|
40707
|
-
if (reasons.length > 0) {
|
|
40708
|
-
candidates.push({
|
|
40709
|
-
absolutePath: filePath,
|
|
40710
|
-
relativePath,
|
|
40711
|
-
reasons,
|
|
40712
|
-
});
|
|
40713
|
-
}
|
|
40714
|
-
}
|
|
40715
|
-
if (candidates.length === 0) {
|
|
40716
|
-
console.info(colors.green('No refactor candidates found.'));
|
|
40717
|
-
return;
|
|
40718
|
-
}
|
|
40719
|
-
for (const candidate of candidates) {
|
|
40720
|
-
console.info(colors.yellow(`${candidate.relativePath} <- ${candidate.reasons.join('; ')}`));
|
|
40721
|
-
}
|
|
40722
|
-
const candidatesToWrite = candidates.filter((candidate) => !existingTargets.has(candidate.relativePath));
|
|
40723
|
-
const alreadyTracked = candidates.length - candidatesToWrite.length;
|
|
40724
|
-
if (candidatesToWrite.length === 0) {
|
|
40725
|
-
console.info(colors.green('All candidates already have prompts.'));
|
|
40726
|
-
return;
|
|
40727
|
-
}
|
|
40728
|
-
const promptNumbering = await getPromptNumbering({
|
|
40729
|
-
promptsDir,
|
|
40730
|
-
step: PROMPT_NUMBER_STEP,
|
|
40731
|
-
ignoreGlobs: ['**/node_modules/**'],
|
|
40732
|
-
});
|
|
40733
|
-
const { selectedEmojis } = await getFreshPromptEmojiTags({
|
|
40734
|
-
count: candidatesToWrite.length,
|
|
40735
|
-
rootDir,
|
|
40736
|
-
});
|
|
40737
|
-
await mkdir(promptsDir, { recursive: true });
|
|
40738
|
-
const createdPrompts = [];
|
|
40739
|
-
for (const [index, candidate] of candidatesToWrite.entries()) {
|
|
40740
|
-
const slug = buildPromptSlug(candidate.relativePath);
|
|
40741
|
-
const number = promptNumbering.startNumber + index * promptNumbering.step;
|
|
40742
|
-
const filename = buildPromptFilename(promptNumbering.datePrefix, number, slug);
|
|
40743
|
-
const promptPath = join(promptsDir, filename);
|
|
40744
|
-
const selectedEmoji = selectedEmojis[index];
|
|
40745
|
-
if (!selectedEmoji) {
|
|
40746
|
-
throw new Error(`Missing emoji for prompt candidate #${index + 1}`);
|
|
40747
|
-
}
|
|
40748
|
-
const emojiTag = formatPromptEmojiTag(selectedEmoji);
|
|
40749
|
-
const promptContent = buildPromptContent(candidate, emojiTag);
|
|
40750
|
-
await writeFile(promptPath, promptContent, 'utf-8');
|
|
40751
|
-
createdPrompts.push(filename);
|
|
40752
|
-
}
|
|
40753
|
-
console.info(colors.green(`Created ${createdPrompts.length} prompt(s) in ${PROMPTS_DIR_NAME}.`));
|
|
40754
|
-
if (alreadyTracked > 0) {
|
|
40755
|
-
console.info(colors.gray(`Skipped ${alreadyTracked} candidate(s) with existing prompts.`));
|
|
40756
|
-
}
|
|
40757
|
-
}
|
|
40758
40875
|
/**
|
|
40759
40876
|
* Builds prompt content for a refactor candidate.
|
|
40760
40877
|
*
|
|
40761
|
-
* @
|
|
40762
|
-
* @param emojiTag - Unique emoji tag for the prompt title.
|
|
40878
|
+
* @private function of findRefactorCandidates
|
|
40763
40879
|
*/
|
|
40764
40880
|
function buildPromptContent(candidate, emojiTag) {
|
|
40765
40881
|
const fileName = basename(candidate.relativePath);
|
|
@@ -40775,6 +40891,8 @@ function buildPromptContent(candidate, emojiTag) {
|
|
|
40775
40891
|
}
|
|
40776
40892
|
/**
|
|
40777
40893
|
* Builds the refactor guidance section for a prompt.
|
|
40894
|
+
*
|
|
40895
|
+
* @private function of buildPromptContent
|
|
40778
40896
|
*/
|
|
40779
40897
|
function buildPromptGuidance(candidate) {
|
|
40780
40898
|
const guidance = [
|
|
@@ -40791,12 +40909,13 @@ function buildPromptGuidance(candidate) {
|
|
|
40791
40909
|
if (counts.entityCount !== null && counts.maxEntities !== null) {
|
|
40792
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.`);
|
|
40793
40911
|
}
|
|
40794
|
-
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.');
|
|
40795
|
-
// <- TODO: Leverage `spaceTrim` here
|
|
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.');
|
|
40796
40913
|
return guidance;
|
|
40797
40914
|
}
|
|
40798
40915
|
/**
|
|
40799
40916
|
* Extracts line and entity counts from refactor reasons.
|
|
40917
|
+
*
|
|
40918
|
+
* @private function of buildPromptContent
|
|
40800
40919
|
*/
|
|
40801
40920
|
function extractReasonCounts(reasons) {
|
|
40802
40921
|
let lineCount = null;
|
|
@@ -40825,6 +40944,8 @@ function extractReasonCounts(reasons) {
|
|
|
40825
40944
|
}
|
|
40826
40945
|
/**
|
|
40827
40946
|
* Builds a summary note about file density based on counts.
|
|
40947
|
+
*
|
|
40948
|
+
* @private function of buildPromptContent
|
|
40828
40949
|
*/
|
|
40829
40950
|
function buildDensityNote(counts) {
|
|
40830
40951
|
if (counts.lineCount !== null && counts.entityCount !== null) {
|
|
@@ -40838,8 +40959,47 @@ function buildDensityNote(counts) {
|
|
|
40838
40959
|
}
|
|
40839
40960
|
return null;
|
|
40840
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;
|
|
40971
|
+
const promptNumbering = await getPromptNumbering({
|
|
40972
|
+
promptsDir,
|
|
40973
|
+
step: PROMPT_NUMBER_STEP,
|
|
40974
|
+
ignoreGlobs: ['**/node_modules/**'],
|
|
40975
|
+
});
|
|
40976
|
+
const { selectedEmojis } = await getFreshPromptEmojiTags({
|
|
40977
|
+
count: candidates.length,
|
|
40978
|
+
rootDir,
|
|
40979
|
+
tagPrefix: '🧹',
|
|
40980
|
+
});
|
|
40981
|
+
await mkdir(promptsDir, { recursive: true });
|
|
40982
|
+
const createdPrompts = [];
|
|
40983
|
+
for (const [index, candidate] of candidates.entries()) {
|
|
40984
|
+
const slug = buildPromptSlug(candidate.relativePath);
|
|
40985
|
+
const number = promptNumbering.startNumber + index * promptNumbering.step;
|
|
40986
|
+
const filename = buildPromptFilename(promptNumbering.datePrefix, number, slug);
|
|
40987
|
+
const promptPath = join(promptsDir, filename);
|
|
40988
|
+
const selectedEmoji = selectedEmojis[index];
|
|
40989
|
+
if (!selectedEmoji) {
|
|
40990
|
+
throw new Error(`Missing emoji for prompt candidate #${index + 1}`);
|
|
40991
|
+
}
|
|
40992
|
+
const emojiTag = formatPromptEmojiTag(selectedEmoji, '🧹');
|
|
40993
|
+
const promptContent = buildPromptContent(candidate, emojiTag);
|
|
40994
|
+
await writeFile(promptPath, promptContent, 'utf-8');
|
|
40995
|
+
createdPrompts.push(filename);
|
|
40996
|
+
}
|
|
40997
|
+
return createdPrompts;
|
|
40998
|
+
}
|
|
40841
40999
|
/**
|
|
40842
41000
|
* Creates the prompt slug from a file path while keeping it readable.
|
|
41001
|
+
*
|
|
41002
|
+
* @private function of writeRefactorCandidatePrompts
|
|
40843
41003
|
*/
|
|
40844
41004
|
function buildPromptSlug(relativePath) {
|
|
40845
41005
|
const prefixed = `${PROMPT_SLUG_PREFIX}-${normalizeToKebabCase(relativePath) || 'file'}`;
|
|
@@ -40851,178 +41011,83 @@ function buildPromptSlug(relativePath) {
|
|
|
40851
41011
|
return `${trimmed}-${hash}`;
|
|
40852
41012
|
}
|
|
40853
41013
|
/**
|
|
40854
|
-
*
|
|
40855
|
-
|
|
40856
|
-
|
|
40857
|
-
var _a;
|
|
40858
|
-
if (!existsSync(promptsDir)) {
|
|
40859
|
-
return new Set();
|
|
40860
|
-
}
|
|
40861
|
-
const promptFiles = await glob('**/*.md', {
|
|
40862
|
-
cwd: promptsDir,
|
|
40863
|
-
nodir: true,
|
|
40864
|
-
});
|
|
40865
|
-
const targets = new Set();
|
|
40866
|
-
const targetRegex = new RegExp(`^\\s*-\\s+${escapeRegExp(PROMPT_TARGET_LABEL)}:\\s+\\\`(?<path>[^\\\`]+)\\\``, 'gm');
|
|
40867
|
-
for (const promptFile of promptFiles) {
|
|
40868
|
-
const content = await readFile(join(promptsDir, promptFile), 'utf-8');
|
|
40869
|
-
for (const match of content.matchAll(targetRegex)) {
|
|
40870
|
-
const captured = (_a = match.groups) === null || _a === void 0 ? void 0 : _a.path;
|
|
40871
|
-
if (captured) {
|
|
40872
|
-
targets.add(normalizeRelativePath(captured));
|
|
40873
|
-
}
|
|
40874
|
-
}
|
|
40875
|
-
}
|
|
40876
|
-
return targets;
|
|
40877
|
-
}
|
|
40878
|
-
/**
|
|
40879
|
-
* Lists all source files to scan based on configured roots and extensions.
|
|
40880
|
-
*/
|
|
40881
|
-
async function listSourceFiles(rootDir) {
|
|
40882
|
-
const extensions = SOURCE_FILE_EXTENSIONS.map((extension) => extension.replace(/^\./, '')).join(',');
|
|
40883
|
-
const extensionGlob = `{${extensions}}`;
|
|
40884
|
-
const patterns = [...SOURCE_ROOTS.map((root) => `${root}/**/*.${extensionGlob}`), `*.${extensionGlob}`];
|
|
40885
|
-
const files = new Set();
|
|
40886
|
-
for (const pattern of patterns) {
|
|
40887
|
-
const matches = await glob(pattern, {
|
|
40888
|
-
cwd: rootDir,
|
|
40889
|
-
ignore: SOURCE_FILE_IGNORE_GLOBS,
|
|
40890
|
-
nodir: true,
|
|
40891
|
-
absolute: true,
|
|
40892
|
-
});
|
|
40893
|
-
for (const match of matches) {
|
|
40894
|
-
files.add(match);
|
|
40895
|
-
}
|
|
40896
|
-
}
|
|
40897
|
-
return Array.from(files).sort();
|
|
40898
|
-
}
|
|
40899
|
-
/**
|
|
40900
|
-
* Builds a set of normalized paths exempt from line-count checks.
|
|
40901
|
-
*/
|
|
40902
|
-
async function buildExemptPathSet(rootDir, patterns) {
|
|
40903
|
-
const exemptPaths = new Set();
|
|
40904
|
-
for (const pattern of patterns) {
|
|
40905
|
-
const matches = await glob(pattern, {
|
|
40906
|
-
cwd: rootDir,
|
|
40907
|
-
ignore: SOURCE_FILE_IGNORE_GLOBS,
|
|
40908
|
-
nodir: true,
|
|
40909
|
-
absolute: true,
|
|
40910
|
-
});
|
|
40911
|
-
for (const match of matches) {
|
|
40912
|
-
exemptPaths.add(normalizeAbsolutePath(match));
|
|
40913
|
-
}
|
|
40914
|
-
}
|
|
40915
|
-
return exemptPaths;
|
|
40916
|
-
}
|
|
40917
|
-
/**
|
|
40918
|
-
* Determines whether a file is generated by scanning for known markers.
|
|
40919
|
-
*/
|
|
40920
|
-
function isGeneratedFile(content) {
|
|
40921
|
-
return GENERATED_CODE_MARKERS.some((marker) => content.includes(marker));
|
|
40922
|
-
}
|
|
40923
|
-
/**
|
|
40924
|
-
* Gets the maximum allowed lines for a file extension.
|
|
40925
|
-
*/
|
|
40926
|
-
function getMaxLinesForExtension(extension) {
|
|
40927
|
-
var _a;
|
|
40928
|
-
return (_a = LINE_COUNT_LIMITS_BY_EXTENSION[extension]) !== null && _a !== void 0 ? _a : DEFAULT_MAX_LINE_COUNT;
|
|
40929
|
-
}
|
|
40930
|
-
/**
|
|
40931
|
-
* Counts lines while ignoring a trailing newline.
|
|
41014
|
+
* Creates a short stable hash used for trimmed slugs.
|
|
41015
|
+
*
|
|
41016
|
+
* @private function of writeRefactorCandidatePrompts
|
|
40932
41017
|
*/
|
|
40933
|
-
function
|
|
40934
|
-
|
|
40935
|
-
|
|
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);
|
|
40936
41022
|
}
|
|
40937
|
-
|
|
40938
|
-
return lines[lines.length - 1] === '' ? lines.length - 1 : lines.length;
|
|
41023
|
+
return (hash >>> 0).toString(36);
|
|
40939
41024
|
}
|
|
40940
|
-
/**
|
|
40941
|
-
|
|
40942
|
-
|
|
40943
|
-
|
|
40944
|
-
|
|
40945
|
-
|
|
40946
|
-
|
|
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
|
+
});
|
|
40947
41038
|
}
|
|
40948
41039
|
/**
|
|
40949
|
-
*
|
|
41040
|
+
* Initializes environment for this script.
|
|
41041
|
+
*
|
|
41042
|
+
* @private utility for `findRefactorCandidates`
|
|
40950
41043
|
*/
|
|
40951
|
-
function
|
|
40952
|
-
|
|
40953
|
-
// Only count top-level declarations to avoid inflating with members or nested scopes.
|
|
40954
|
-
for (const statement of sourceFile.statements) {
|
|
40955
|
-
if (ts.isFunctionDeclaration(statement) ||
|
|
40956
|
-
ts.isClassDeclaration(statement) ||
|
|
40957
|
-
ts.isInterfaceDeclaration(statement) ||
|
|
40958
|
-
ts.isTypeAliasDeclaration(statement) ||
|
|
40959
|
-
ts.isEnumDeclaration(statement) ||
|
|
40960
|
-
ts.isModuleDeclaration(statement)) {
|
|
40961
|
-
count += 1;
|
|
40962
|
-
continue;
|
|
40963
|
-
}
|
|
40964
|
-
if (ts.isVariableStatement(statement)) {
|
|
40965
|
-
for (const declaration of statement.declarationList.declarations) {
|
|
40966
|
-
const initializer = declaration.initializer;
|
|
40967
|
-
if (initializer &&
|
|
40968
|
-
(ts.isArrowFunction(initializer) ||
|
|
40969
|
-
ts.isFunctionExpression(initializer) ||
|
|
40970
|
-
ts.isClassExpression(initializer))) {
|
|
40971
|
-
count += 1;
|
|
40972
|
-
}
|
|
40973
|
-
}
|
|
40974
|
-
}
|
|
40975
|
-
}
|
|
40976
|
-
return count;
|
|
41044
|
+
function initializeFindRefactorCandidatesRun() {
|
|
41045
|
+
dotenv.config({ path: '.env' });
|
|
40977
41046
|
}
|
|
40978
41047
|
/**
|
|
40979
|
-
*
|
|
41048
|
+
* Orchestrates scanning for refactor candidates and generating prompts.
|
|
41049
|
+
*
|
|
41050
|
+
* @public exported from `@promptbook/cli`
|
|
40980
41051
|
*/
|
|
40981
|
-
function
|
|
40982
|
-
|
|
40983
|
-
|
|
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;
|
|
40984
41062
|
}
|
|
40985
|
-
|
|
40986
|
-
|
|
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;
|
|
40987
41069
|
}
|
|
40988
|
-
|
|
40989
|
-
|
|
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.`));
|
|
40990
41078
|
}
|
|
40991
|
-
return ts.ScriptKind.TS;
|
|
40992
|
-
}
|
|
40993
|
-
/**
|
|
40994
|
-
* Normalizes a path to use forward slashes.
|
|
40995
|
-
*/
|
|
40996
|
-
function normalizeRelativePath(pathValue) {
|
|
40997
|
-
const normalized = pathValue.replace(/\\/g, '/');
|
|
40998
|
-
return normalized.replace(/^\.\//, '');
|
|
40999
|
-
}
|
|
41000
|
-
/**
|
|
41001
|
-
* Normalizes an absolute path for consistent comparisons.
|
|
41002
|
-
*/
|
|
41003
|
-
function normalizeAbsolutePath(pathValue) {
|
|
41004
|
-
const normalized = resolve(pathValue);
|
|
41005
|
-
return process.platform === 'win32' ? normalized.toLowerCase() : normalized;
|
|
41006
|
-
}
|
|
41007
|
-
/**
|
|
41008
|
-
* Escapes a string for use in a regular expression literal.
|
|
41009
|
-
*/
|
|
41010
|
-
function escapeRegExp(value) {
|
|
41011
|
-
return value.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
|
|
41012
41079
|
}
|
|
41013
41080
|
/**
|
|
41014
|
-
*
|
|
41081
|
+
* Prints discovered refactor candidates with their reasons.
|
|
41082
|
+
*
|
|
41083
|
+
* @private function of findRefactorCandidates
|
|
41015
41084
|
*/
|
|
41016
|
-
function
|
|
41017
|
-
|
|
41018
|
-
|
|
41019
|
-
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('; ')}`));
|
|
41020
41088
|
}
|
|
41021
|
-
return (hash >>> 0).toString(36);
|
|
41022
41089
|
}
|
|
41023
|
-
/**
|
|
41024
|
-
* Note: [?] Code in this file should never be published in any package
|
|
41025
|
-
*/
|
|
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` */
|
|
41026
41091
|
|
|
41027
41092
|
var findRefactorCandidates$1 = /*#__PURE__*/Object.freeze({
|
|
41028
41093
|
__proto__: null,
|
|
@@ -41043,6 +41108,7 @@ function parseRunOptions(args) {
|
|
|
41043
41108
|
if (agentValue) {
|
|
41044
41109
|
const value = agentValue;
|
|
41045
41110
|
if (value === 'openai-codex' ||
|
|
41111
|
+
value === 'github-copilot' ||
|
|
41046
41112
|
value === 'cline' ||
|
|
41047
41113
|
value === 'claude-code' ||
|
|
41048
41114
|
value === 'opencode' ||
|
|
@@ -41059,7 +41125,7 @@ function parseRunOptions(args) {
|
|
|
41059
41125
|
const autoMigrate = args.includes('--auto-migrate');
|
|
41060
41126
|
const allowDestructiveAutoMigrate = args.includes('--allow-destructive-auto-migrate');
|
|
41061
41127
|
if (!agentName && !dryRun) {
|
|
41062
|
-
exitWithUsageError('You must choose an agent using --agent <openai-codex|cline|claude-code|opencode|gemini>');
|
|
41128
|
+
exitWithUsageError('You must choose an agent using --agent <openai-codex|github-copilot|cline|claude-code|opencode|gemini>');
|
|
41063
41129
|
}
|
|
41064
41130
|
return {
|
|
41065
41131
|
dryRun,
|
|
@@ -41923,9 +41989,7 @@ async function isWorkingTreeClean(path) {
|
|
|
41923
41989
|
});
|
|
41924
41990
|
return gitStatus.includes(`working tree clean`);
|
|
41925
41991
|
}
|
|
41926
|
-
/**
|
|
41927
|
-
* Note: [🟡] Code in this file should never be published outside of `@promptbook/cli`
|
|
41928
|
-
*/
|
|
41992
|
+
/** Note: [🟡] Code for CLI support script [isWorkingTreeClean](scripts/utils/autocommit/isWorkingTreeClean.ts) should never be published outside of `@promptbook/cli` */
|
|
41929
41993
|
|
|
41930
41994
|
/**
|
|
41931
41995
|
* Ensures the git working tree is clean before running the prompt.
|
|
@@ -43488,6 +43552,10 @@ function createCodingContext() {
|
|
|
43488
43552
|
- Keep small responsibilities of functions and classes, avoid creating big functions or classes that do many things.
|
|
43489
43553
|
- When throwing errors, throw [branded errors](src/errors) and use \`spaceTrim\` utility to write clear and well-formatted multilie detailed error messages.
|
|
43490
43554
|
- Format errors as markdown, for example \`variabiles\` should be in backticks, important notes can be in bold, etc.
|
|
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.
|
|
43491
43559
|
- When writing multiline strings, use \`spaceTrim\` utility
|
|
43492
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.
|
|
43493
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
|
|
@@ -43851,6 +43919,60 @@ class GeminiRunner {
|
|
|
43851
43919
|
}
|
|
43852
43920
|
}
|
|
43853
43921
|
|
|
43922
|
+
/**
|
|
43923
|
+
* Builds the shell script that runs GitHub Copilot CLI with the prompt and coding context.
|
|
43924
|
+
*/
|
|
43925
|
+
function buildGitHubCopilotScript(options) {
|
|
43926
|
+
const delimiter = 'GITHUB_COPILOT_PROMPT';
|
|
43927
|
+
const projectPath = toPosixPath(options.projectPath);
|
|
43928
|
+
const modelArgument = options.model ? ` --model ${options.model}` : '';
|
|
43929
|
+
return spaceTrim((block) => `
|
|
43930
|
+
cd "${projectPath}"
|
|
43931
|
+
|
|
43932
|
+
copilot -p "$(cat <<'${delimiter}'
|
|
43933
|
+
|
|
43934
|
+
${block(options.prompt)}
|
|
43935
|
+
|
|
43936
|
+
${block(createCodingContext())}
|
|
43937
|
+
|
|
43938
|
+
${delimiter}
|
|
43939
|
+
)" \
|
|
43940
|
+
--yolo \
|
|
43941
|
+
--no-ask-user \
|
|
43942
|
+
--no-color \
|
|
43943
|
+
--output-format json \
|
|
43944
|
+
--stream off${modelArgument}
|
|
43945
|
+
`);
|
|
43946
|
+
}
|
|
43947
|
+
|
|
43948
|
+
/**
|
|
43949
|
+
* Runs prompts via the GitHub Copilot CLI.
|
|
43950
|
+
*/
|
|
43951
|
+
class GitHubCopilotRunner {
|
|
43952
|
+
/**
|
|
43953
|
+
* Creates a new GitHub Copilot runner.
|
|
43954
|
+
*/
|
|
43955
|
+
constructor(options) {
|
|
43956
|
+
this.options = options;
|
|
43957
|
+
this.name = 'github-copilot';
|
|
43958
|
+
}
|
|
43959
|
+
/**
|
|
43960
|
+
* Runs the prompt using GitHub Copilot CLI.
|
|
43961
|
+
*/
|
|
43962
|
+
async runPrompt(options) {
|
|
43963
|
+
const scriptContent = buildGitHubCopilotScript({
|
|
43964
|
+
prompt: options.prompt,
|
|
43965
|
+
projectPath: options.projectPath,
|
|
43966
|
+
model: this.options.model,
|
|
43967
|
+
});
|
|
43968
|
+
await $runGoScript({
|
|
43969
|
+
scriptPath: options.scriptPath,
|
|
43970
|
+
scriptContent,
|
|
43971
|
+
});
|
|
43972
|
+
return { usage: UNCERTAIN_USAGE };
|
|
43973
|
+
}
|
|
43974
|
+
}
|
|
43975
|
+
|
|
43854
43976
|
/**
|
|
43855
43977
|
* Maximum number of output characters included in thrown error messages.
|
|
43856
43978
|
*/
|
|
@@ -44588,6 +44710,7 @@ const DEFAULT_CODEX_MODEL = 'gpt-5.2-codex';
|
|
|
44588
44710
|
const CLINE_MODEL = 'gemini:gemini-3-flash-preview';
|
|
44589
44711
|
const RUNNER_LABELS = {
|
|
44590
44712
|
'openai-codex': 'OpenAI Codex',
|
|
44713
|
+
'github-copilot': 'GitHub Copilot',
|
|
44591
44714
|
cline: 'Cline',
|
|
44592
44715
|
'claude-code': 'Claude Code',
|
|
44593
44716
|
opencode: 'Opencode',
|
|
@@ -44603,6 +44726,9 @@ function getRunnerMetadata(options, actualModel) {
|
|
|
44603
44726
|
if (options.agentName === 'openai-codex') {
|
|
44604
44727
|
modelName = actualModel;
|
|
44605
44728
|
}
|
|
44729
|
+
else if (options.agentName === 'github-copilot') {
|
|
44730
|
+
modelName = actualModel;
|
|
44731
|
+
}
|
|
44606
44732
|
else if (options.agentName === 'gemini') {
|
|
44607
44733
|
modelName = actualModel;
|
|
44608
44734
|
}
|
|
@@ -44640,8 +44766,7 @@ async function runCodexPrompts(providedOptions) {
|
|
|
44640
44766
|
return;
|
|
44641
44767
|
}
|
|
44642
44768
|
let runner;
|
|
44643
|
-
let
|
|
44644
|
-
let actualGeminiModel;
|
|
44769
|
+
let actualRunnerModel;
|
|
44645
44770
|
const agentName = options.agentName;
|
|
44646
44771
|
if (!agentName) {
|
|
44647
44772
|
throw new Error('Missing --agent in non-dry run mode');
|
|
@@ -44668,7 +44793,7 @@ async function runCodexPrompts(providedOptions) {
|
|
|
44668
44793
|
else {
|
|
44669
44794
|
modelToUse = options.model;
|
|
44670
44795
|
}
|
|
44671
|
-
|
|
44796
|
+
actualRunnerModel = modelToUse;
|
|
44672
44797
|
runner = new OpenAiCodexRunner({
|
|
44673
44798
|
codexCommand: 'codex',
|
|
44674
44799
|
model: modelToUse,
|
|
@@ -44685,6 +44810,13 @@ async function runCodexPrompts(providedOptions) {
|
|
|
44685
44810
|
model: CLINE_MODEL,
|
|
44686
44811
|
});
|
|
44687
44812
|
}
|
|
44813
|
+
else if (agentName === 'github-copilot') {
|
|
44814
|
+
const modelToUse = options.model === 'default' ? undefined : options.model;
|
|
44815
|
+
actualRunnerModel = modelToUse;
|
|
44816
|
+
runner = new GitHubCopilotRunner({
|
|
44817
|
+
model: modelToUse,
|
|
44818
|
+
});
|
|
44819
|
+
}
|
|
44688
44820
|
else if (agentName === 'claude-code') {
|
|
44689
44821
|
runner = new ClaudeCodeRunner();
|
|
44690
44822
|
}
|
|
@@ -44709,7 +44841,7 @@ async function runCodexPrompts(providedOptions) {
|
|
|
44709
44841
|
else {
|
|
44710
44842
|
modelToUse = options.model;
|
|
44711
44843
|
}
|
|
44712
|
-
|
|
44844
|
+
actualRunnerModel = modelToUse;
|
|
44713
44845
|
runner = new GeminiRunner({
|
|
44714
44846
|
model: modelToUse,
|
|
44715
44847
|
});
|
|
@@ -44718,7 +44850,7 @@ async function runCodexPrompts(providedOptions) {
|
|
|
44718
44850
|
throw new Error(`Unknown agent: ${agentName}`);
|
|
44719
44851
|
}
|
|
44720
44852
|
console.info(colors.green(`Running prompts with ${runner.name}`));
|
|
44721
|
-
const runnerMetadata = getRunnerMetadata(options,
|
|
44853
|
+
const runnerMetadata = getRunnerMetadata(options, actualRunnerModel);
|
|
44722
44854
|
let hasShownUpcomingTasks = false;
|
|
44723
44855
|
let hasWaitedForStart = false;
|
|
44724
44856
|
while (just(true)) {
|
|
@@ -45465,13 +45597,23 @@ function getToolCallIdentity(toolCall) {
|
|
|
45465
45597
|
*/
|
|
45466
45598
|
function mergeToolCalls(existingToolCalls, incomingToolCalls) {
|
|
45467
45599
|
if (!existingToolCalls || existingToolCalls.length === 0) {
|
|
45468
|
-
return incomingToolCalls ? [...incomingToolCalls] : [];
|
|
45600
|
+
return incomingToolCalls ? deduplicatePreparationToolCalls([...incomingToolCalls]) : [];
|
|
45469
45601
|
}
|
|
45470
45602
|
if (!incomingToolCalls || incomingToolCalls.length === 0) {
|
|
45471
45603
|
return [...existingToolCalls];
|
|
45472
45604
|
}
|
|
45473
45605
|
const mergedToolCalls = [...existingToolCalls];
|
|
45474
45606
|
for (const incomingToolCall of incomingToolCalls) {
|
|
45607
|
+
if (isAssistantPreparationToolCall(incomingToolCall)) {
|
|
45608
|
+
// A new preparation phase always replaces any previous assistant_preparation tool
|
|
45609
|
+
// call, regardless of phase argument, so only one chip is ever shown at a time.
|
|
45610
|
+
const existingPreparationIndex = mergedToolCalls.findIndex(isAssistantPreparationToolCall);
|
|
45611
|
+
if (existingPreparationIndex !== -1) {
|
|
45612
|
+
mergedToolCalls.splice(existingPreparationIndex, 1);
|
|
45613
|
+
}
|
|
45614
|
+
mergedToolCalls.push(incomingToolCall);
|
|
45615
|
+
continue;
|
|
45616
|
+
}
|
|
45475
45617
|
const incomingIdentity = getToolCallIdentity(incomingToolCall);
|
|
45476
45618
|
const existingIndex = mergedToolCalls.findIndex((existingToolCall) => getToolCallIdentity(existingToolCall) === incomingIdentity);
|
|
45477
45619
|
if (existingIndex === -1) {
|
|
@@ -45583,6 +45725,30 @@ function serializeValueForMerge(value) {
|
|
|
45583
45725
|
return String(value);
|
|
45584
45726
|
}
|
|
45585
45727
|
}
|
|
45728
|
+
/**
|
|
45729
|
+
* Ensures at most one `assistant_preparation` tool call survives in the list,
|
|
45730
|
+
* keeping the last occurrence so the most recent preparation phase is shown.
|
|
45731
|
+
*
|
|
45732
|
+
* @param toolCalls - Mutable list to deduplicate in-place.
|
|
45733
|
+
* @returns The same array after removing redundant preparation entries.
|
|
45734
|
+
* @private helper of `mergeToolCalls`
|
|
45735
|
+
*/
|
|
45736
|
+
function deduplicatePreparationToolCalls(toolCalls) {
|
|
45737
|
+
let lastPreparationIndex = -1;
|
|
45738
|
+
for (let index = toolCalls.length - 1; index >= 0; index--) {
|
|
45739
|
+
if (!isAssistantPreparationToolCall(toolCalls[index])) {
|
|
45740
|
+
continue;
|
|
45741
|
+
}
|
|
45742
|
+
if (lastPreparationIndex === -1) {
|
|
45743
|
+
lastPreparationIndex = index;
|
|
45744
|
+
}
|
|
45745
|
+
else {
|
|
45746
|
+
// Remove earlier duplicate — keep only the last (most recent) one.
|
|
45747
|
+
toolCalls.splice(index, 1);
|
|
45748
|
+
}
|
|
45749
|
+
}
|
|
45750
|
+
return toolCalls;
|
|
45751
|
+
}
|
|
45586
45752
|
|
|
45587
45753
|
/**
|
|
45588
45754
|
* Gets all tool titles provided by all commitments
|