@promptbook/cli 0.114.0-5 → 0.114.0-7
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/agents/default/developer.book +1 -0
- package/apps/agents-server/next.config.ts +22 -0
- package/apps/agents-server/package.json +6 -6
- package/apps/agents-server/scripts/build-agents-server.js +43 -7
- package/apps/agents-server/scripts/build-e2e.js +12 -2
- package/apps/agents-server/scripts/generate-reserved-paths/generate-reserved-paths.ts +30 -16
- package/apps/agents-server/scripts/kill-port.js +163 -0
- package/apps/agents-server/scripts/run-e2e-tests.js +21 -8
- package/apps/agents-server/scripts/run-npm.js +81 -5
- package/apps/agents-server/src/app/actions.ts +3 -0
- package/apps/agents-server/src/app/admin/email-server/page.tsx +17 -18
- package/apps/agents-server/src/app/admin/task-manager/TaskManagerTaskRow.tsx +2 -0
- package/apps/agents-server/src/app/admin/task-manager/[taskId]/TaskManagerTaskDetailClient.tsx +2 -0
- package/apps/agents-server/src/app/admin/task-manager/taskManagerTaskPresentation.tsx +23 -0
- package/apps/agents-server/src/app/agents/[agentName]/api/book/route.ts +7 -0
- package/apps/agents-server/src/app/agents/[agentName]/api/timeouts/[timeoutId]/route.ts +10 -153
- package/apps/agents-server/src/app/agents/[agentName]/api/timeouts/route.ts +9 -4
- package/apps/agents-server/src/app/agents/[agentName]/api/user-chats/[chatId]/route.ts +3 -0
- package/apps/agents-server/src/app/agents/[agentName]/api/user-chats/[chatId]/stream/route.ts +2 -0
- package/apps/agents-server/src/app/agents/[agentName]/api/user-chats/resolveUserChatScope.ts +8 -1
- package/apps/agents-server/src/app/agents/[agentName]/api/user-chats/route.ts +15 -7
- package/apps/agents-server/src/app/agents/[agentName]/book/useBookEditorSaving.ts +18 -28
- package/apps/agents-server/src/app/agents/[agentName]/chat/AgentChatHistoryClient.tsx +19 -1
- package/apps/agents-server/src/app/agents/[agentName]/chat/AgentChatSidebarDefault.tsx +17 -5
- package/apps/agents-server/src/app/agents/[agentName]/chat/AgentGoalChatNotice.tsx +23 -0
- package/apps/agents-server/src/app/agents/[agentName]/chat/AgentGoalChatPlannedMessages.tsx +153 -0
- package/apps/agents-server/src/app/agents/[agentName]/chat/CanonicalAgentChatPanel.tsx +6 -0
- package/apps/agents-server/src/app/agents/[agentName]/chat/CanonicalAgentChatSurface.tsx +13 -0
- package/apps/agents-server/src/app/agents/[agentName]/chat/ExternalUserChatAdminActions.tsx +51 -3
- package/apps/agents-server/src/app/agents/[agentName]/chat/TeamMemberFrozenChatPrimaryAgentLink.tsx +31 -0
- package/apps/agents-server/src/app/agents/[agentName]/chat/useAgentChatSidebarState.ts +26 -2
- package/apps/agents-server/src/app/agents/[agentName]/goal/page.tsx +35 -0
- package/apps/agents-server/src/app/agents/[agentName]/projects/[projectName]/page.tsx +2 -2
- package/apps/agents-server/src/app/api/admin/dns-records/cloudflare/route.ts +26 -16
- package/apps/agents-server/src/app/api/emails/incoming/stalwart/route.ts +9 -2
- package/apps/agents-server/src/app/superadmin/servers/ServersRegistryTable.tsx +31 -39
- package/apps/agents-server/src/components/AgentProfile/AgentProfile.tsx +10 -3
- package/apps/agents-server/src/components/AgentProjects/AgentProjectIcon.tsx +137 -0
- package/apps/agents-server/src/components/AgentProjects/AgentProjectItem.tsx +26 -10
- package/apps/agents-server/src/components/CloudflareDnsWizard/CloudflareDnsApiTokenImportStep.tsx +5 -6
- package/apps/agents-server/src/components/CloudflareDnsWizard/CloudflareDnsCheckStep.tsx +6 -5
- package/apps/agents-server/src/components/CloudflareDnsWizard/CloudflareDnsManualStep.tsx +10 -14
- package/apps/agents-server/src/components/CloudflareDnsWizard/CloudflareDnsWizard.tsx +11 -20
- package/apps/agents-server/src/components/CloudflareDnsWizard/useCloudflareDnsRecordImport.ts +5 -6
- package/apps/agents-server/src/components/DnsRecordsInstructions/DnsRecordsInstructions.tsx +91 -57
- package/apps/agents-server/src/components/DnsRecordsInstructions/DnsRecordsSectionPanel.tsx +63 -0
- package/apps/agents-server/src/components/DnsRecordsInstructions/DnsRecordsSectionVariantTabs.tsx +67 -0
- package/apps/agents-server/src/components/DnsRecordsInstructions/DnsRecordsTable.tsx +40 -0
- package/apps/agents-server/src/components/Header/buildActiveAgentViewItems.ts +5 -4
- package/apps/agents-server/src/components/Header/createAgentViewLabel.tsx +4 -4
- package/apps/agents-server/src/components/Header/resolveActiveAgentNavigation.ts +2 -2
- package/apps/agents-server/src/components/Homepage/useAgentsListImportExportState.ts +22 -10
- package/apps/agents-server/src/components/_utils/generateMetaTxt.ts +1 -1
- package/apps/agents-server/src/database/migratePrefix.ts +13 -12
- package/apps/agents-server/src/database/migrations/2026-08-0100-agent-goal-chat-source.sql +10 -0
- package/apps/agents-server/src/generated/reservedPaths.ts +42 -42
- package/apps/agents-server/src/languages/ServerTranslationKeys.ts +9 -1
- package/apps/agents-server/src/languages/translations/czech.yaml +9 -1
- package/apps/agents-server/src/languages/translations/english.yaml +9 -1
- package/apps/agents-server/src/message-providers/email/stalwart/parseInboundStalwartEmail.ts +17 -2
- package/apps/agents-server/src/utils/agentGoalChat/agentGoalChatConstants.ts +9 -0
- package/apps/agents-server/src/utils/agentGoalChat/agentGoalChatIdentity.ts +28 -0
- package/apps/agents-server/src/utils/agentGoalChat/appendAgentGoalChatNote.ts +43 -0
- package/apps/agents-server/src/utils/agentGoalChat/canAccessAgentGoalChat.ts +14 -0
- package/apps/agents-server/src/utils/agentGoalChat/createAgentGoalChatNoteContent.ts +69 -0
- package/apps/agents-server/src/utils/agentGoalChat/ensureAgentGoalChat.ts +66 -0
- package/apps/agents-server/src/utils/agentGoalChat/prependAgentGoalChatSummarySeed.ts +40 -0
- package/apps/agents-server/src/utils/agentGoalChat/recordAgentGoalChatLifecycleNote.ts +36 -0
- package/apps/agents-server/src/utils/agentGoalChat/resolveAgentGoalChatOwnerUserId.ts +104 -0
- package/apps/agents-server/src/utils/agentGoalChat/scheduleAgentGoalChatModifiedNote.ts +82 -0
- package/apps/agents-server/src/utils/agentGoalChat.ts +19 -0
- package/apps/agents-server/src/utils/agentProjects/AgentProjectInfo.ts +10 -1
- package/apps/agents-server/src/utils/agentProjects/AgentProjectReferenceInfo.ts +5 -2
- package/apps/agents-server/src/utils/agentProjects/agentProjectFileNames.ts +21 -0
- package/apps/agents-server/src/utils/agentProjects/agentProjectHrefs.ts +20 -11
- package/apps/agents-server/src/utils/agentProjects/agentProjectsPaths.ts +15 -5
- package/apps/agents-server/src/utils/agentProjects/createAgentProjectInitials.ts +36 -0
- package/apps/agents-server/src/utils/agentProjects/createAgentProjectMarkdownReferences.ts +11 -9
- package/apps/agents-server/src/utils/agentProjects/createAgentProjectsDnsRecordsSection.ts +113 -0
- package/apps/agents-server/src/utils/agentProjects/createStaticAgentProjectServer.ts +2 -6
- package/apps/agents-server/src/utils/agentProjects/humanizeAgentProjectName.ts +25 -0
- package/apps/agents-server/src/utils/agentProjects/listAgentProjectChatReferences.ts +10 -3
- package/apps/agents-server/src/utils/agentProjects/parseAgentProjectIndexHtml.ts +167 -0
- package/apps/agents-server/src/utils/agentProjects/readAgentProjectIndexHtmlProfile.ts +24 -0
- package/apps/agents-server/src/utils/agentProjects/readAgentProjectReadme.ts +3 -53
- package/apps/agents-server/src/utils/agentProjects/readAgentProjectRootTextFile.ts +73 -0
- package/apps/agents-server/src/utils/agentProjects/resolveAgentProjectFaviconRelativePath.ts +108 -0
- package/apps/agents-server/src/utils/agentProjects/resolveAgentProjectInfo.ts +12 -3
- package/apps/agents-server/src/utils/agentProjects/{resolveAgentProjectReadmeProfile.ts → resolveAgentProjectProfile.ts} +33 -33
- package/apps/agents-server/src/utils/agentProjects/resolveAgentProjectPublicUrls.ts +34 -0
- package/apps/agents-server/src/utils/bookLanguageDocumentation/createBookLanguageDocumentationPdfResponse.ts +19 -17
- package/apps/agents-server/src/utils/chatTasksAdmin.ts +9 -0
- package/apps/agents-server/src/utils/dnsRecords/DnsRecordInstruction.ts +20 -0
- package/apps/agents-server/src/utils/dnsRecords/DnsRecordsSection.ts +77 -0
- package/apps/agents-server/src/utils/dnsRecords/createServerDnsRecordsSections.ts +58 -0
- package/apps/agents-server/src/utils/dnsRecords/createServerDomainDnsRecordsSection.ts +48 -0
- package/apps/agents-server/src/utils/dnsRecords/dnsRecordGroups.ts +52 -0
- package/apps/agents-server/src/utils/dnsRecords/resolveDnsRecordBatchPlan.ts +47 -1
- package/apps/agents-server/src/utils/getAdminChatTasksResponse/getAdminChatTasks/adminChatTaskSqlQuery.ts +41 -36
- package/apps/agents-server/src/utils/getAdminChatTasksResponse/getAdminChatTasks/mapAdminChatTaskFallbackRows.ts +3 -0
- package/apps/agents-server/src/utils/getAdminChatTasksResponse/getAdminChatTasks/mapAdminChatTaskSqlRows.ts +2 -0
- package/apps/agents-server/src/utils/localChatRunner/parseLocalTeamConversations.ts +281 -0
- package/apps/agents-server/src/utils/localChatRunner/persistLocalTeamConversations.ts +71 -0
- package/apps/agents-server/src/utils/localChatRunner/prepareLocalTeamConversationWorkspace.ts +233 -0
- package/apps/agents-server/src/utils/localChatRunner/processLocalUserChatJob.ts +37 -6
- package/apps/agents-server/src/utils/serverManagement/createManagedServer/insertManagedServerRegistryRow.ts +2 -2
- package/apps/agents-server/src/utils/serverManagement/createManagedServer/seedServerCoreAgents.ts +7 -6
- package/apps/agents-server/src/utils/serverManagement/createManagedServer/seedServerDefaultAgents.ts +5 -4
- package/apps/agents-server/src/utils/serverManagement/createManagedServer/seedServerMetadata.ts +3 -2
- package/apps/agents-server/src/utils/serverManagement/createManagedServer/seedServerUsers.ts +3 -2
- package/apps/agents-server/src/utils/serverManagement/deleteManagedServer.ts +2 -2
- package/apps/agents-server/src/utils/stalwart/createEmailDnsRecordsSection.ts +53 -0
- package/apps/agents-server/src/utils/userChat/UserChatRecord.ts +13 -0
- package/apps/agents-server/src/utils/userChat/UserChatSource.ts +14 -0
- package/apps/agents-server/src/utils/userChat/createUserChatSummary.ts +10 -2
- package/apps/agents-server/src/utils/userChat/finalizeUserChatJob.ts +3 -2
- package/apps/agents-server/src/utils/userChat/getUserChat.ts +16 -1
- package/apps/agents-server/src/utils/userChat/getUserChatForJobRunner.ts +31 -0
- package/apps/agents-server/src/utils/userChat/listUserChats.ts +113 -110
- package/apps/agents-server/src/utils/userChat/persistFrozenUserChat.ts +21 -6
- package/apps/agents-server/src/utils/userChat/runImmediateUserChatAnswer.ts +2 -6
- package/apps/agents-server/src/utils/userChat/runUserChatJob.ts +2 -6
- package/apps/agents-server/src/utils/userChat/teamMemberUserChatContext.ts +63 -0
- package/apps/agents-server/src/utils/userChat.ts +5 -1
- package/apps/agents-server/src/utils/userChatClient/cancelAgentUserTimeout.ts +2 -2
- package/apps/agents-server/src/utils/userChatClient/fetchAgentUserTimeouts.ts +2 -2
- package/apps/agents-server/src/utils/userChatClient.ts +9 -31
- package/apps/agents-server/src/utils/userChatTimeout/UserChatTimeoutRecord.ts +10 -2
- package/apps/agents-server/src/utils/userChatTimeout/userChatTimeoutStore/claimNextDueUserChatTimeout.ts +28 -25
- package/apps/agents-server/src/utils/userChatTimeout/userChatTimeoutStore/getAgentScopedUserChatTimeout.ts +8 -4
- package/apps/agents-server/src/utils/userChatTimeout/userChatTimeoutStore/listAgentUserChatTimeouts.ts +4 -1
- package/apps/agents-server/src/utils/userChatTimeout/userChatTimeoutStore/recoverExpiredRunningUserChatTimeouts.ts +3 -2
- package/apps/agents-server/src/utils/userChatTimeout/userChatTimeoutWorker.ts +53 -0
- package/esm/index.es.js +1534 -401
- package/esm/index.es.js.map +1 -1
- package/esm/scripts/run-agent-messages/messages/buildAgentMessagePrompt.d.ts +7 -1
- package/esm/scripts/run-agent-messages/messages/buildAgentTeamPromptSection.d.ts +12 -0
- package/esm/scripts/run-agent-messages/messages/finalizeAgentTeamConversationWorkspace.d.ts +16 -0
- package/esm/scripts/run-agent-messages/messages/loadAgentTeamConversationWorkspace.d.ts +6 -0
- package/esm/scripts/run-codex-prompts/common/normalizeLineEndingsInChangedFiles.d.ts +2 -3
- package/esm/scripts/run-codex-prompts/git/coderCommitScope.d.ts +31 -0
- package/esm/scripts/run-codex-prompts/git/coderGitSync.d.ts +15 -2
- package/esm/scripts/run-codex-prompts/git/commitChanges.d.ts +9 -3
- package/esm/scripts/run-codex-prompts/git/workingTreeChanges.d.ts +40 -0
- package/esm/scripts/run-codex-prompts/server/coderServerHtml.d.ts +1 -1
- package/esm/scripts/run-codex-prompts/ui/buildCoderRunAgentVisual.d.ts +5 -5
- package/esm/scripts/run-codex-prompts/ui/buildCoderRunUiTerminalFrameUpdate.d.ts +27 -0
- package/esm/src/avatars/renderAvatarVisualTerminalText.d.ts +80 -0
- package/esm/src/avatars/types/AvatarVisualDefinition.d.ts +54 -0
- package/esm/src/book-3.0/AgentTeamConversationWorkspace.d.ts +85 -0
- package/esm/src/book-components/Chat/Chat/ChatProps.d.ts +3 -2
- package/esm/src/book-components/Chat/utils/renderMarkdown.d.ts +12 -3
- package/esm/src/cli/cli-commands/coder/boilerplateCount.d.ts +1 -1
- package/esm/src/cli/cli-commands/coder/generate-boilerplates.d.ts +1 -1
- package/esm/src/cli/cli-commands/common/{harness/$askForHarnessInstallationApproval.d.ts → npm/$askForNpmPackageInstallationApproval.d.ts} +2 -2
- package/{umd/src/cli/cli-commands/common/harness/$resolveLatestHarnessVersion.d.ts → esm/src/cli/cli-commands/common/npm/$resolveLatestNpmPackageVersion.d.ts} +2 -3
- package/esm/src/cli/cli-commands/common/npm/extractNpmPackageVersionFromOutput.d.ts +12 -0
- package/esm/src/cli/cli-commands/common/npm/isNpmPackageVersionOutdated.d.ts +9 -0
- package/esm/src/cli/cli-commands/common/promptbook-cli/$checkPromptbookCliInstallations.d.ts +9 -0
- package/esm/src/cli/cli-commands/common/promptbook-cli/$ensurePromptbookCliInstallations.d.ts +14 -0
- package/esm/src/cli/cli-commands/common/promptbook-cli/$ensurePromptbookCliInstallations.test.d.ts +1 -0
- package/esm/src/cli/cli-commands/common/promptbook-cli/$resolvePromptbookCliInstallations.d.ts +12 -0
- package/esm/src/cli/cli-commands/common/promptbook-cli/$resolvePromptbookCliInstallations.test.d.ts +1 -0
- package/esm/src/cli/cli-commands/common/promptbook-cli/$updatePromptbookCliInstallation.d.ts +10 -0
- package/esm/src/cli/cli-commands/common/promptbook-cli/PromptbookCliInstallation.d.ts +39 -0
- package/esm/src/cli/cli-commands/common/promptbook-cli/PromptbookCliInstallationStatus.d.ts +26 -0
- package/esm/src/cli/cli-commands/common/promptbook-cli/buildPromptbookCliInstallCommand.d.ts +7 -0
- package/esm/src/cli/cli-commands/common/promptbook-cli/buildPromptbookCliInstallCommand.test.d.ts +1 -0
- package/esm/src/cli/cli-commands/common/promptbook-cli/formatPromptbookCliInstallationWarning.d.ts +7 -0
- package/esm/src/utils/agent-message-runtime/resolveAgentMessageRuntimeActivity.d.ts +3 -3
- package/esm/src/utils/agents/terminalAgentAvatarVisual.d.ts +5 -2
- package/esm/src/utils/ascii-art/convertImageDataToAsciiArt.d.ts +6 -0
- package/esm/src/utils/ascii-art/createAnsiColorCode.d.ts +46 -0
- package/esm/src/utils/misc/debounce.d.ts +4 -2
- package/esm/src/utils/misc/debounce.test.d.ts +1 -0
- package/esm/src/version.d.ts +1 -1
- package/package.json +1 -1
- package/src/avatars/renderAvatarVisualTerminalText.ts +249 -0
- package/src/avatars/types/AvatarVisualDefinition.ts +60 -0
- package/src/avatars/visuals/asciiOctopusAvatarVisual.ts +144 -22
- package/src/book-2.0/book-language-documentation/createStandaloneBookLanguageMarkdown.ts +4 -4
- package/src/book-2.0/book-language-documentation/renderCommitmentCatalogSection.ts +1 -4
- package/src/book-2.0/book-language-documentation/renderGroupedCommitmentDocumentationMarkdown.ts +4 -17
- package/src/book-3.0/AgentTeamConversationWorkspace.ts +172 -0
- package/src/book-components/BookEditor/useBookEditorMonacoStyles.ts +56 -55
- package/src/book-components/Chat/Chat/Chat.module.css +1 -8
- package/src/book-components/Chat/Chat/ChatMessageMap.tsx +8 -4
- package/src/book-components/Chat/Chat/ChatProps.tsx +3 -2
- package/src/book-components/Chat/MarkdownContent/MarkdownContent.module.css +14 -14
- package/src/book-components/Chat/save/react/exports/chat-preview-2025-10-13 (1).jsx +95 -5
- package/src/book-components/Chat/utils/renderMarkdown.ts +535 -89
- package/src/cli/cli-commands/coder/add.ts +3 -3
- package/src/cli/cli-commands/coder/boilerplateCount.ts +1 -1
- package/src/cli/cli-commands/coder/generate-boilerplates.ts +27 -27
- package/src/cli/cli-commands/coder/getDefaultCoderPackageJsonScripts.ts +5 -4
- package/src/cli/cli-commands/coder/init.ts +3 -3
- package/src/cli/cli-commands/coder/run.ts +10 -2
- package/src/cli/cli-commands/common/coderGitSyncCliOptions.ts +6 -2
- package/src/cli/cli-commands/common/harness/$applyHarnessInstallationStatus.ts +2 -2
- package/src/cli/cli-commands/common/harness/$checkHarnessInstallation.ts +4 -4
- package/src/cli/cli-commands/common/harness/$resolveInstalledHarnessVersion.ts +2 -2
- package/src/cli/cli-commands/common/{harness/$askForHarnessInstallationApproval.ts → npm/$askForNpmPackageInstallationApproval.ts} +3 -3
- package/src/cli/cli-commands/common/npm/$resolveLatestNpmPackageVersion.ts +49 -0
- package/src/cli/cli-commands/common/npm/extractNpmPackageVersionFromOutput.ts +25 -0
- package/src/cli/cli-commands/common/{harness/isHarnessVersionOutdated.ts → npm/isNpmPackageVersionOutdated.ts} +6 -4
- package/src/cli/cli-commands/common/projectInitialization.ts +10 -1
- package/src/cli/cli-commands/common/promptbook-cli/$checkPromptbookCliInstallations.ts +73 -0
- package/src/cli/cli-commands/common/promptbook-cli/$ensurePromptbookCliInstallations.ts +94 -0
- package/src/cli/cli-commands/common/promptbook-cli/$resolvePromptbookCliInstallations.ts +223 -0
- package/src/cli/cli-commands/common/promptbook-cli/$updatePromptbookCliInstallation.ts +53 -0
- package/src/cli/cli-commands/common/promptbook-cli/PromptbookCliInstallation.ts +46 -0
- package/src/cli/cli-commands/common/promptbook-cli/PromptbookCliInstallationStatus.ts +32 -0
- package/src/cli/cli-commands/common/promptbook-cli/buildPromptbookCliInstallCommand.ts +22 -0
- package/src/cli/cli-commands/common/promptbook-cli/formatPromptbookCliInstallationWarning.ts +47 -0
- package/src/commands/FORMAT/formatCommandParser.ts +2 -2
- package/src/llm-providers/openai/utils/buildToolInvocationScript.ts +21 -18
- package/src/other/templates/getTemplatesPipelineCollection.ts +976 -668
- package/src/utils/agent-message-runtime/resolveAgentMessageRuntimeActivity.ts +80 -27
- package/src/utils/agents/terminalAgentAvatarVisual.ts +31 -3
- package/src/utils/ascii-art/convertImageDataToAsciiArt.ts +9 -109
- package/src/utils/ascii-art/createAnsiColorCode.ts +132 -0
- package/src/utils/misc/debounce.ts +26 -5
- package/src/version.ts +2 -2
- package/src/versions.txt +2 -0
- package/umd/index.umd.js +1533 -400
- package/umd/index.umd.js.map +1 -1
- package/umd/scripts/run-agent-messages/messages/buildAgentMessagePrompt.d.ts +7 -1
- package/umd/scripts/run-agent-messages/messages/buildAgentTeamPromptSection.d.ts +12 -0
- package/umd/scripts/run-agent-messages/messages/finalizeAgentTeamConversationWorkspace.d.ts +16 -0
- package/umd/scripts/run-agent-messages/messages/loadAgentTeamConversationWorkspace.d.ts +6 -0
- package/umd/scripts/run-codex-prompts/common/normalizeLineEndingsInChangedFiles.d.ts +2 -3
- package/umd/scripts/run-codex-prompts/git/coderCommitScope.d.ts +31 -0
- package/umd/scripts/run-codex-prompts/git/coderGitSync.d.ts +15 -2
- package/umd/scripts/run-codex-prompts/git/commitChanges.d.ts +9 -3
- package/umd/scripts/run-codex-prompts/git/workingTreeChanges.d.ts +40 -0
- package/umd/scripts/run-codex-prompts/server/coderServerHtml.d.ts +1 -1
- package/umd/scripts/run-codex-prompts/ui/buildCoderRunAgentVisual.d.ts +5 -5
- package/umd/scripts/run-codex-prompts/ui/buildCoderRunUiTerminalFrameUpdate.d.ts +27 -0
- package/umd/src/avatars/renderAvatarVisualTerminalText.d.ts +80 -0
- package/umd/src/avatars/renderAvatarVisualTerminalText.test.d.ts +1 -0
- package/umd/src/avatars/types/AvatarVisualDefinition.d.ts +54 -0
- package/umd/src/book-3.0/AgentTeamConversationWorkspace.d.ts +85 -0
- package/umd/src/book-components/Chat/Chat/ChatProps.d.ts +3 -2
- package/umd/src/book-components/Chat/utils/renderMarkdown.d.ts +12 -3
- package/umd/src/cli/cli-commands/coder/boilerplateCount.d.ts +1 -1
- package/umd/src/cli/cli-commands/coder/generate-boilerplates.d.ts +1 -1
- package/umd/src/cli/cli-commands/common/{harness/$askForHarnessInstallationApproval.d.ts → npm/$askForNpmPackageInstallationApproval.d.ts} +2 -2
- package/{esm/src/cli/cli-commands/common/harness/$resolveLatestHarnessVersion.d.ts → umd/src/cli/cli-commands/common/npm/$resolveLatestNpmPackageVersion.d.ts} +2 -3
- package/umd/src/cli/cli-commands/common/npm/$resolveLatestNpmPackageVersion.test.d.ts +1 -0
- package/umd/src/cli/cli-commands/common/npm/extractNpmPackageVersionFromOutput.d.ts +12 -0
- package/umd/src/cli/cli-commands/common/npm/extractNpmPackageVersionFromOutput.test.d.ts +1 -0
- package/umd/src/cli/cli-commands/common/npm/isNpmPackageVersionOutdated.d.ts +9 -0
- package/umd/src/cli/cli-commands/common/npm/isNpmPackageVersionOutdated.test.d.ts +1 -0
- package/umd/src/cli/cli-commands/common/promptbook-cli/$checkPromptbookCliInstallations.d.ts +9 -0
- package/umd/src/cli/cli-commands/common/promptbook-cli/$ensurePromptbookCliInstallations.d.ts +14 -0
- package/umd/src/cli/cli-commands/common/promptbook-cli/$ensurePromptbookCliInstallations.test.d.ts +1 -0
- package/umd/src/cli/cli-commands/common/promptbook-cli/$resolvePromptbookCliInstallations.d.ts +12 -0
- package/umd/src/cli/cli-commands/common/promptbook-cli/$resolvePromptbookCliInstallations.test.d.ts +1 -0
- package/umd/src/cli/cli-commands/common/promptbook-cli/$updatePromptbookCliInstallation.d.ts +10 -0
- package/umd/src/cli/cli-commands/common/promptbook-cli/PromptbookCliInstallation.d.ts +39 -0
- package/umd/src/cli/cli-commands/common/promptbook-cli/PromptbookCliInstallationStatus.d.ts +26 -0
- package/umd/src/cli/cli-commands/common/promptbook-cli/buildPromptbookCliInstallCommand.d.ts +7 -0
- package/umd/src/cli/cli-commands/common/promptbook-cli/buildPromptbookCliInstallCommand.test.d.ts +1 -0
- package/umd/src/cli/cli-commands/common/promptbook-cli/formatPromptbookCliInstallationWarning.d.ts +7 -0
- package/umd/src/utils/agent-message-runtime/resolveAgentMessageRuntimeActivity.d.ts +3 -3
- package/umd/src/utils/agents/terminalAgentAvatarVisual.d.ts +5 -2
- package/umd/src/utils/ascii-art/convertImageDataToAsciiArt.d.ts +6 -0
- package/umd/src/utils/ascii-art/createAnsiColorCode.d.ts +46 -0
- package/umd/src/utils/misc/debounce.d.ts +4 -2
- package/umd/src/utils/misc/debounce.test.d.ts +1 -0
- package/umd/src/version.d.ts +1 -1
- package/apps/agents-server/scripts/ignore-kill-eperm.js +0 -31
- package/apps/agents-server/src/app/agents/[agentName]/api/timeouts/actions/route.ts +0 -103
- package/apps/agents-server/src/app/agents/[agentName]/timeouts/AgentTimeoutsClient.tsx +0 -43
- package/apps/agents-server/src/app/agents/[agentName]/timeouts/AgentTimeoutsEditDialog.tsx +0 -98
- package/apps/agents-server/src/app/agents/[agentName]/timeouts/AgentTimeoutsFiltersCard.tsx +0 -75
- package/apps/agents-server/src/app/agents/[agentName]/timeouts/AgentTimeoutsHeader.tsx +0 -53
- package/apps/agents-server/src/app/agents/[agentName]/timeouts/AgentTimeoutsSummaryMetrics.tsx +0 -70
- package/apps/agents-server/src/app/agents/[agentName]/timeouts/AgentTimeoutsTableCard.tsx +0 -58
- package/apps/agents-server/src/app/agents/[agentName]/timeouts/AgentTimeoutsTableRow.tsx +0 -242
- package/apps/agents-server/src/app/agents/[agentName]/timeouts/loading.tsx +0 -15
- package/apps/agents-server/src/app/agents/[agentName]/timeouts/page.tsx +0 -28
- package/apps/agents-server/src/app/agents/[agentName]/timeouts/useAgentTimeoutsClientState.ts +0 -769
- package/apps/agents-server/src/components/AgentProjectDnsInstructions/AgentProjectDnsInstructions.tsx +0 -182
- package/apps/agents-server/src/utils/userChatClient/runAgentUserTimeoutBulkAction.ts +0 -24
- package/apps/agents-server/src/utils/userChatClient/updateAgentUserTimeout.ts +0 -25
- package/esm/src/cli/cli-commands/common/harness/extractHarnessVersionFromOutput.d.ts +0 -11
- package/esm/src/cli/cli-commands/common/harness/isHarnessVersionOutdated.d.ts +0 -9
- package/src/cli/cli-commands/common/harness/$resolveLatestHarnessVersion.ts +0 -34
- package/src/cli/cli-commands/common/harness/extractHarnessVersionFromOutput.ts +0 -28
- package/umd/src/cli/cli-commands/common/harness/extractHarnessVersionFromOutput.d.ts +0 -11
- package/umd/src/cli/cli-commands/common/harness/isHarnessVersionOutdated.d.ts +0 -9
- /package/esm/src/{cli/cli-commands/common/harness/extractHarnessVersionFromOutput.test.d.ts → avatars/renderAvatarVisualTerminalText.test.d.ts} +0 -0
- /package/esm/src/cli/cli-commands/common/{harness/isHarnessVersionOutdated.test.d.ts → npm/$resolveLatestNpmPackageVersion.test.d.ts} +0 -0
- /package/{umd/src/cli/cli-commands/common/harness/extractHarnessVersionFromOutput.test.d.ts → esm/src/cli/cli-commands/common/npm/extractNpmPackageVersionFromOutput.test.d.ts} +0 -0
- /package/{umd/src/cli/cli-commands/common/harness/isHarnessVersionOutdated.test.d.ts → esm/src/cli/cli-commands/common/npm/isNpmPackageVersionOutdated.test.d.ts} +0 -0
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
import colors from 'colors';
|
|
2
|
+
import { spaceTrim } from 'spacetrim';
|
|
3
|
+
import { $askForNpmPackageInstallationApproval } from '../npm/$askForNpmPackageInstallationApproval';
|
|
4
|
+
import type { PromptbookCliInstallationStatus } from './PromptbookCliInstallationStatus';
|
|
5
|
+
import { $checkPromptbookCliInstallations } from './$checkPromptbookCliInstallations';
|
|
6
|
+
import { $updatePromptbookCliInstallation } from './$updatePromptbookCliInstallation';
|
|
7
|
+
import { buildPromptbookCliInstallCommand } from './buildPromptbookCliInstallCommand';
|
|
8
|
+
import { formatPromptbookCliInstallationWarning } from './formatPromptbookCliInstallationWarning';
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Checks local and global Promptbook CLI installations before an interactive coder run and offers to update them.
|
|
12
|
+
*
|
|
13
|
+
* Once an update is approved, the caller must stop the current run and let the user start a fresh process. A local
|
|
14
|
+
* npm update can modify `package.json` and a lockfile, which would make the coder's working-tree preflight fail;
|
|
15
|
+
* more importantly, this Node.js process has already loaded the old CLI implementation.
|
|
16
|
+
*
|
|
17
|
+
* Note: `$` is used to indicate that this function is not a pure function - it reads package manifests, queries npm,
|
|
18
|
+
* asks the user, and may install npm packages
|
|
19
|
+
*
|
|
20
|
+
* @returns `true` when an update was approved and the current coder run should stop
|
|
21
|
+
* @private internal utility of `promptbookCli`
|
|
22
|
+
*/
|
|
23
|
+
export async function $ensurePromptbookCliInstallations(): Promise<boolean> {
|
|
24
|
+
if (!process.stdin.isTTY) {
|
|
25
|
+
// Note: Non-interactive runs cannot approve an update and should not wait for registry checks.
|
|
26
|
+
return false;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
const statuses = await $checkPromptbookCliInstallations();
|
|
30
|
+
const outdatedStatuses = statuses.filter(({ installationState }) => installationState === 'outdated');
|
|
31
|
+
|
|
32
|
+
if (outdatedStatuses.length === 0) {
|
|
33
|
+
reportPromptbookCliInstallationStatuses(statuses);
|
|
34
|
+
return false;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
console.warn(colors.yellow(formatPromptbookCliInstallationWarning(outdatedStatuses)));
|
|
38
|
+
|
|
39
|
+
const isUpdateApproved = await $askForNpmPackageInstallationApproval('Update Promptbook CLI now?');
|
|
40
|
+
|
|
41
|
+
if (!isUpdateApproved) {
|
|
42
|
+
const manualInstallCommands = outdatedStatuses
|
|
43
|
+
.map((status) => `- \`${buildPromptbookCliInstallCommand(status.installation)}\``)
|
|
44
|
+
.join('\n');
|
|
45
|
+
|
|
46
|
+
console.info(
|
|
47
|
+
colors.gray(
|
|
48
|
+
spaceTrim(
|
|
49
|
+
(block) => `
|
|
50
|
+
Skipped updating Promptbook CLI.
|
|
51
|
+
|
|
52
|
+
Run one of these commands manually:
|
|
53
|
+
|
|
54
|
+
${block(manualInstallCommands)}
|
|
55
|
+
`,
|
|
56
|
+
),
|
|
57
|
+
),
|
|
58
|
+
);
|
|
59
|
+
return false;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
for (const status of outdatedStatuses) {
|
|
63
|
+
await $updatePromptbookCliInstallation(status);
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
console.info(colors.green('Promptbook CLI update is complete. Run the command again to use the new version.'));
|
|
67
|
+
return true;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
/**
|
|
71
|
+
* Reports successful and unverifiable Promptbook CLI checks when no update is required.
|
|
72
|
+
*
|
|
73
|
+
* @private internal utility of `$ensurePromptbookCliInstallations`
|
|
74
|
+
*/
|
|
75
|
+
function reportPromptbookCliInstallationStatuses(statuses: ReadonlyArray<PromptbookCliInstallationStatus>): void {
|
|
76
|
+
for (const status of statuses) {
|
|
77
|
+
const { npmPackageName, installedVersion } = status.installation;
|
|
78
|
+
|
|
79
|
+
if (status.installationState === 'up-to-date') {
|
|
80
|
+
console.info(colors.gray(`✔ Promptbook CLI \`${npmPackageName}\` ${installedVersion} is up to date.`));
|
|
81
|
+
continue;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
if (status.installationState === 'unknown') {
|
|
85
|
+
console.info(
|
|
86
|
+
colors.gray(
|
|
87
|
+
`✔ Promptbook CLI \`${npmPackageName}\` ${installedVersion} is installed; the newest version could not be checked.`,
|
|
88
|
+
),
|
|
89
|
+
);
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
// Note: [🟡] Code for Promptbook CLI installation orchestration [$ensurePromptbookCliInstallations](src/cli/cli-commands/common/promptbook-cli/$ensurePromptbookCliInstallations.ts) should never be published outside of `@promptbook/cli`
|
|
@@ -0,0 +1,223 @@
|
|
|
1
|
+
import { readFile } from 'fs/promises';
|
|
2
|
+
import { join } from 'path';
|
|
3
|
+
import { $execCommand } from '../../../../utils/execCommand/$execCommand';
|
|
4
|
+
import {
|
|
5
|
+
PROMPTBOOK_CLI_NPM_PACKAGE_NAMES,
|
|
6
|
+
type PromptbookCliInstallation,
|
|
7
|
+
type PromptbookCliInstallationLocation,
|
|
8
|
+
type PromptbookCliNpmPackageName,
|
|
9
|
+
} from './PromptbookCliInstallation';
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Time limit for resolving npm's global `node_modules` directory.
|
|
13
|
+
*/
|
|
14
|
+
const NPM_GLOBAL_NODE_MODULES_PATH_COMMAND_TIMEOUT_MS = 30 * 1000;
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* JSON object shape used while reading package manifests without assuming unrelated fields.
|
|
18
|
+
*
|
|
19
|
+
* @private internal utility of `$resolvePromptbookCliInstallations`
|
|
20
|
+
*/
|
|
21
|
+
type JsonObject = Readonly<Record<string, unknown>>;
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* Finds every locally or globally installed Promptbook CLI package which can be updated.
|
|
25
|
+
*
|
|
26
|
+
* A local package must be declared directly in the current project's `package.json`; transitive packages are not
|
|
27
|
+
* updated because this command must not change dependencies chosen by another package.
|
|
28
|
+
*
|
|
29
|
+
* Note: `$` is used to indicate that this function is not a pure function - it reads package manifests and runs npm
|
|
30
|
+
*
|
|
31
|
+
* @private internal utility of `promptbookCli`
|
|
32
|
+
*/
|
|
33
|
+
export async function $resolvePromptbookCliInstallations(): Promise<ReadonlyArray<PromptbookCliInstallation>> {
|
|
34
|
+
const [localInstallations, globalInstallations] = await Promise.all([
|
|
35
|
+
$resolveLocalPromptbookCliInstallations(),
|
|
36
|
+
$resolveGlobalPromptbookCliInstallations(),
|
|
37
|
+
]);
|
|
38
|
+
|
|
39
|
+
return [...localInstallations, ...globalInstallations];
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* Finds Promptbook CLI packages installed directly in the current project's dependencies.
|
|
44
|
+
*
|
|
45
|
+
* @private internal utility of `$resolvePromptbookCliInstallations`
|
|
46
|
+
*/
|
|
47
|
+
async function $resolveLocalPromptbookCliInstallations(): Promise<ReadonlyArray<PromptbookCliInstallation>> {
|
|
48
|
+
const projectPath = process.cwd();
|
|
49
|
+
const projectPackageJson = await $readJsonObject(join(projectPath, 'package.json'));
|
|
50
|
+
|
|
51
|
+
if (projectPackageJson === null) {
|
|
52
|
+
return [];
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
const installations = await Promise.all(
|
|
56
|
+
PROMPTBOOK_CLI_NPM_PACKAGE_NAMES.map(async (npmPackageName) => {
|
|
57
|
+
const installationLocation = resolveLocalPromptbookCliInstallationLocation(
|
|
58
|
+
projectPackageJson,
|
|
59
|
+
npmPackageName,
|
|
60
|
+
);
|
|
61
|
+
|
|
62
|
+
if (installationLocation === undefined) {
|
|
63
|
+
return undefined;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
const installedVersion = await $resolveInstalledNpmPackageVersion(
|
|
67
|
+
join(projectPath, 'node_modules'),
|
|
68
|
+
npmPackageName,
|
|
69
|
+
);
|
|
70
|
+
|
|
71
|
+
if (installedVersion === undefined) {
|
|
72
|
+
return undefined;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
return { npmPackageName, installedVersion, installationLocation };
|
|
76
|
+
}),
|
|
77
|
+
);
|
|
78
|
+
|
|
79
|
+
return installations.filter(isDefined);
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
/**
|
|
83
|
+
* Finds Promptbook CLI packages installed in npm's global `node_modules` directory.
|
|
84
|
+
*
|
|
85
|
+
* @private internal utility of `$resolvePromptbookCliInstallations`
|
|
86
|
+
*/
|
|
87
|
+
async function $resolveGlobalPromptbookCliInstallations(): Promise<ReadonlyArray<PromptbookCliInstallation>> {
|
|
88
|
+
const globalNodeModulesPath = await $resolveNpmGlobalNodeModulesPath();
|
|
89
|
+
|
|
90
|
+
if (globalNodeModulesPath === null) {
|
|
91
|
+
return [];
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
const installations = await Promise.all(
|
|
95
|
+
PROMPTBOOK_CLI_NPM_PACKAGE_NAMES.map(async (npmPackageName) => {
|
|
96
|
+
const installedVersion = await $resolveInstalledNpmPackageVersion(globalNodeModulesPath, npmPackageName);
|
|
97
|
+
|
|
98
|
+
if (installedVersion === undefined) {
|
|
99
|
+
return undefined;
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
return {
|
|
103
|
+
npmPackageName,
|
|
104
|
+
installedVersion,
|
|
105
|
+
installationLocation: 'global' as const,
|
|
106
|
+
};
|
|
107
|
+
}),
|
|
108
|
+
);
|
|
109
|
+
|
|
110
|
+
return installations.filter(isDefined);
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
/**
|
|
114
|
+
* Resolves the current project's manifest section that declares a Promptbook CLI package.
|
|
115
|
+
*
|
|
116
|
+
* @private internal utility of `$resolvePromptbookCliInstallations`
|
|
117
|
+
*/
|
|
118
|
+
function resolveLocalPromptbookCliInstallationLocation(
|
|
119
|
+
packageJson: JsonObject,
|
|
120
|
+
npmPackageName: PromptbookCliNpmPackageName,
|
|
121
|
+
): PromptbookCliInstallationLocation | undefined {
|
|
122
|
+
if (readNestedStringProperty(packageJson, 'dependencies', npmPackageName) !== undefined) {
|
|
123
|
+
return 'local-dependency';
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
if (readNestedStringProperty(packageJson, 'devDependencies', npmPackageName) !== undefined) {
|
|
127
|
+
return 'local-development-dependency';
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
return undefined;
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
/**
|
|
134
|
+
* Reads an installed npm package version from a `node_modules` directory.
|
|
135
|
+
*
|
|
136
|
+
* @private internal utility of `$resolvePromptbookCliInstallations`
|
|
137
|
+
*/
|
|
138
|
+
async function $resolveInstalledNpmPackageVersion(
|
|
139
|
+
nodeModulesPath: string,
|
|
140
|
+
npmPackageName: PromptbookCliNpmPackageName,
|
|
141
|
+
): Promise<string | undefined> {
|
|
142
|
+
const installedPackageJson = await $readJsonObject(join(nodeModulesPath, npmPackageName, 'package.json'));
|
|
143
|
+
|
|
144
|
+
return installedPackageJson === null ? undefined : readStringProperty(installedPackageJson, 'version');
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
/**
|
|
148
|
+
* Resolves npm's global `node_modules` directory without querying the registry.
|
|
149
|
+
*
|
|
150
|
+
* @private internal utility of `$resolvePromptbookCliInstallations`
|
|
151
|
+
*/
|
|
152
|
+
async function $resolveNpmGlobalNodeModulesPath(): Promise<string | null> {
|
|
153
|
+
const output = await $execCommand({
|
|
154
|
+
command: 'npm root --global',
|
|
155
|
+
crashOnError: true,
|
|
156
|
+
timeout: NPM_GLOBAL_NODE_MODULES_PATH_COMMAND_TIMEOUT_MS,
|
|
157
|
+
isVerbose: false,
|
|
158
|
+
}).catch(() => '');
|
|
159
|
+
|
|
160
|
+
const globalNodeModulesPath = output.trim();
|
|
161
|
+
return globalNodeModulesPath === '' ? null : globalNodeModulesPath;
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
/**
|
|
165
|
+
* Reads a JSON object, returning `null` for missing or malformed files because update checks must stay advisory.
|
|
166
|
+
*
|
|
167
|
+
* @private internal utility of `$resolvePromptbookCliInstallations`
|
|
168
|
+
*/
|
|
169
|
+
async function $readJsonObject(filePath: string): Promise<JsonObject | null> {
|
|
170
|
+
try {
|
|
171
|
+
const parsedValue: unknown = JSON.parse(await readFile(filePath, 'utf8'));
|
|
172
|
+
|
|
173
|
+
return isJsonObject(parsedValue) ? parsedValue : null;
|
|
174
|
+
} catch {
|
|
175
|
+
return null;
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
/**
|
|
180
|
+
* Checks whether an unknown value can be read as a JSON object.
|
|
181
|
+
*
|
|
182
|
+
* @private internal utility of `$resolvePromptbookCliInstallations`
|
|
183
|
+
*/
|
|
184
|
+
function isJsonObject(value: unknown): value is JsonObject {
|
|
185
|
+
return typeof value === 'object' && value !== null && !Array.isArray(value);
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
/**
|
|
189
|
+
* Reads one string property from a JSON object.
|
|
190
|
+
*
|
|
191
|
+
* @private internal utility of `$resolvePromptbookCliInstallations`
|
|
192
|
+
*/
|
|
193
|
+
function readStringProperty(jsonObject: JsonObject, propertyName: string): string | undefined {
|
|
194
|
+
const value = jsonObject[propertyName];
|
|
195
|
+
|
|
196
|
+
return typeof value === 'string' ? value : undefined;
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
/**
|
|
200
|
+
* Reads one string property nested under another JSON object property.
|
|
201
|
+
*
|
|
202
|
+
* @private internal utility of `$resolvePromptbookCliInstallations`
|
|
203
|
+
*/
|
|
204
|
+
function readNestedStringProperty(
|
|
205
|
+
jsonObject: JsonObject,
|
|
206
|
+
parentPropertyName: string,
|
|
207
|
+
propertyName: string,
|
|
208
|
+
): string | undefined {
|
|
209
|
+
const nestedValue = jsonObject[parentPropertyName];
|
|
210
|
+
|
|
211
|
+
return isJsonObject(nestedValue) ? readStringProperty(nestedValue, propertyName) : undefined;
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
/**
|
|
215
|
+
* Narrows an array after `undefined` values were removed.
|
|
216
|
+
*
|
|
217
|
+
* @private internal utility of `$resolvePromptbookCliInstallations`
|
|
218
|
+
*/
|
|
219
|
+
function isDefined<TValue>(value: TValue | undefined): value is TValue {
|
|
220
|
+
return value !== undefined;
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
// Note: [🟡] Code for Promptbook CLI installation detection [$resolvePromptbookCliInstallations](src/cli/cli-commands/common/promptbook-cli/$resolvePromptbookCliInstallations.ts) should never be published outside of `@promptbook/cli`
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import colors from 'colors';
|
|
2
|
+
import { spaceTrim } from 'spacetrim';
|
|
3
|
+
import { assertsError } from '../../../../errors/assertsError';
|
|
4
|
+
import { $execCommand } from '../../../../utils/execCommand/$execCommand';
|
|
5
|
+
import type { PromptbookCliInstallationStatus } from './PromptbookCliInstallationStatus';
|
|
6
|
+
import { buildPromptbookCliInstallCommand } from './buildPromptbookCliInstallCommand';
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Updates one Promptbook CLI package in its existing local or global location.
|
|
10
|
+
*
|
|
11
|
+
* Note: `$` is used to indicate that this function is not a pure function - it installs an npm package
|
|
12
|
+
*
|
|
13
|
+
* @returns `true` when the package update succeeds, `false` when it fails
|
|
14
|
+
* @private internal utility of `promptbookCli`
|
|
15
|
+
*/
|
|
16
|
+
export async function $updatePromptbookCliInstallation(status: PromptbookCliInstallationStatus): Promise<boolean> {
|
|
17
|
+
const { npmPackageName } = status.installation;
|
|
18
|
+
const installCommand = buildPromptbookCliInstallCommand(status.installation);
|
|
19
|
+
|
|
20
|
+
console.info(colors.cyan(`Updating Promptbook CLI package \`${npmPackageName}\` with \`${installCommand}\`...`));
|
|
21
|
+
|
|
22
|
+
try {
|
|
23
|
+
await $execCommand({
|
|
24
|
+
command: installCommand,
|
|
25
|
+
crashOnError: true,
|
|
26
|
+
isVerbose: true,
|
|
27
|
+
});
|
|
28
|
+
} catch (error) {
|
|
29
|
+
assertsError(error);
|
|
30
|
+
const updateErrorMessage = error.message;
|
|
31
|
+
|
|
32
|
+
console.error(
|
|
33
|
+
colors.red(
|
|
34
|
+
spaceTrim(
|
|
35
|
+
(block) => `
|
|
36
|
+
Could not update **Promptbook CLI** package \`${npmPackageName}\`.
|
|
37
|
+
|
|
38
|
+
Update it manually with \`${installCommand}\` and run the command again.
|
|
39
|
+
|
|
40
|
+
${block(updateErrorMessage)}
|
|
41
|
+
`,
|
|
42
|
+
),
|
|
43
|
+
),
|
|
44
|
+
);
|
|
45
|
+
|
|
46
|
+
return false;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
console.info(colors.green(`Promptbook CLI package \`${npmPackageName}\` has been updated.`));
|
|
50
|
+
return true;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
// Note: [🟡] Code for Promptbook CLI installation update [$updatePromptbookCliInstallation](src/cli/cli-commands/common/promptbook-cli/$updatePromptbookCliInstallation.ts) should never be published outside of `@promptbook/cli`
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Npm packages which provide an executable Promptbook CLI.
|
|
3
|
+
*
|
|
4
|
+
* `ptbk` is the preferred package and forwards to `@promptbook/cli`; the latter can also be installed directly.
|
|
5
|
+
*
|
|
6
|
+
* @private internal utility of `promptbookCli`
|
|
7
|
+
*/
|
|
8
|
+
export const PROMPTBOOK_CLI_NPM_PACKAGE_NAMES = ['ptbk', '@promptbook/cli'] as const;
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Npm package which provides an executable Promptbook CLI.
|
|
12
|
+
*
|
|
13
|
+
* @private internal utility of `promptbookCli`
|
|
14
|
+
*/
|
|
15
|
+
export type PromptbookCliNpmPackageName = (typeof PROMPTBOOK_CLI_NPM_PACKAGE_NAMES)[number];
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Place where one Promptbook CLI package is installed.
|
|
19
|
+
*
|
|
20
|
+
* @private internal utility of `promptbookCli`
|
|
21
|
+
*/
|
|
22
|
+
export type PromptbookCliInstallationLocation = 'local-dependency' | 'local-development-dependency' | 'global';
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* One installed Promptbook CLI package that can be updated.
|
|
26
|
+
*
|
|
27
|
+
* @private internal utility of `promptbookCli`
|
|
28
|
+
*/
|
|
29
|
+
export type PromptbookCliInstallation = {
|
|
30
|
+
/**
|
|
31
|
+
* Npm package that provides the CLI.
|
|
32
|
+
*/
|
|
33
|
+
readonly npmPackageName: PromptbookCliNpmPackageName;
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* Version from the package's installed `package.json`.
|
|
37
|
+
*/
|
|
38
|
+
readonly installedVersion: string;
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* Local manifest section or global npm installation containing the package.
|
|
42
|
+
*/
|
|
43
|
+
readonly installationLocation: PromptbookCliInstallationLocation;
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
// Note: [🟡] Code for Promptbook CLI installation definitions [PromptbookCliInstallation](src/cli/cli-commands/common/promptbook-cli/PromptbookCliInstallation.ts) should never be published outside of `@promptbook/cli`
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import type { PromptbookCliInstallation } from './PromptbookCliInstallation';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Result of comparing one installed Promptbook CLI package with the newest published version.
|
|
5
|
+
*
|
|
6
|
+
* @private internal utility of `promptbookCli`
|
|
7
|
+
*/
|
|
8
|
+
export type PromptbookCliInstallationState = 'up-to-date' | 'outdated' | 'unknown';
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Version status of one Promptbook CLI installation.
|
|
12
|
+
*
|
|
13
|
+
* @private internal utility of `promptbookCli`
|
|
14
|
+
*/
|
|
15
|
+
export type PromptbookCliInstallationStatus = {
|
|
16
|
+
/**
|
|
17
|
+
* Installed CLI package being checked.
|
|
18
|
+
*/
|
|
19
|
+
readonly installation: PromptbookCliInstallation;
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Result of comparing the installed version with the newest published version.
|
|
23
|
+
*/
|
|
24
|
+
readonly installationState: PromptbookCliInstallationState;
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* Newest published package version, or `null` when npm could not be reached.
|
|
28
|
+
*/
|
|
29
|
+
readonly latestVersion: string | null;
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
// Note: [🟡] Code for Promptbook CLI installation status [PromptbookCliInstallationStatus](src/cli/cli-commands/common/promptbook-cli/PromptbookCliInstallationStatus.ts) should never be published outside of `@promptbook/cli`
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { PromptbookCliInstallation } from './PromptbookCliInstallation';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Builds the npm command that updates one existing Promptbook CLI installation.
|
|
5
|
+
*
|
|
6
|
+
* @private internal utility of `promptbookCli`
|
|
7
|
+
*/
|
|
8
|
+
export function buildPromptbookCliInstallCommand(installation: PromptbookCliInstallation): string {
|
|
9
|
+
const { npmPackageName, installationLocation } = installation;
|
|
10
|
+
|
|
11
|
+
if (installationLocation === 'global') {
|
|
12
|
+
return `npm install --global ${npmPackageName}@latest`;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
if (installationLocation === 'local-development-dependency') {
|
|
16
|
+
return `npm install --save-dev ${npmPackageName}@latest`;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
return `npm install --save ${npmPackageName}@latest`;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
// Note: [🟡] Code for Promptbook CLI installation command [buildPromptbookCliInstallCommand](src/cli/cli-commands/common/promptbook-cli/buildPromptbookCliInstallCommand.ts) should never be published outside of `@promptbook/cli`
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { spaceTrim } from 'spacetrim';
|
|
2
|
+
import type { PromptbookCliInstallationLocation } from './PromptbookCliInstallation';
|
|
3
|
+
import type { PromptbookCliInstallationStatus } from './PromptbookCliInstallationStatus';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Formats the warning shown when one or more Promptbook CLI installations are outdated.
|
|
7
|
+
*
|
|
8
|
+
* @private internal utility of `promptbookCli`
|
|
9
|
+
*/
|
|
10
|
+
export function formatPromptbookCliInstallationWarning(
|
|
11
|
+
statuses: ReadonlyArray<PromptbookCliInstallationStatus>,
|
|
12
|
+
): string {
|
|
13
|
+
const statusLines = statuses.map((status) => {
|
|
14
|
+
const { npmPackageName, installedVersion, installationLocation } = status.installation;
|
|
15
|
+
|
|
16
|
+
return `- ${formatPromptbookCliInstallationLocation(
|
|
17
|
+
installationLocation,
|
|
18
|
+
)} \`${npmPackageName}\`: installed \`${installedVersion}\`, newest \`${status.latestVersion}\``;
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
return spaceTrim(
|
|
22
|
+
(block) => `
|
|
23
|
+
**Promptbook CLI** is outdated.
|
|
24
|
+
|
|
25
|
+
${block(statusLines.join('\n'))}
|
|
26
|
+
`,
|
|
27
|
+
);
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* Describes an installation location in text suitable for an update warning.
|
|
32
|
+
*
|
|
33
|
+
* @private internal utility of `formatPromptbookCliInstallationWarning`
|
|
34
|
+
*/
|
|
35
|
+
function formatPromptbookCliInstallationLocation(installationLocation: PromptbookCliInstallationLocation): string {
|
|
36
|
+
if (installationLocation === 'global') {
|
|
37
|
+
return 'Globally installed';
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
if (installationLocation === 'local-development-dependency') {
|
|
41
|
+
return 'Locally in `devDependencies`';
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
return 'Locally in `dependencies`';
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
// Note: [🟡] Code for Promptbook CLI installation warning [formatPromptbookCliInstallationWarning](src/cli/cli-commands/common/promptbook-cli/formatPromptbookCliInstallationWarning.ts) should never be published outside of `@promptbook/cli`
|
|
@@ -70,8 +70,8 @@ export const formatCommandParser: PipelineTaskCommandParser<FormatCommand> = {
|
|
|
70
70
|
*/
|
|
71
71
|
$applyToTaskJson(command: FormatCommand, $taskJson: $TaskJson): $side_effect {
|
|
72
72
|
if ($taskJson.format !== undefined && command.format !== $taskJson.format) {
|
|
73
|
-
throw new ParseError(`Format format is already defined to "${$taskJson.format}".
|
|
74
|
-
Now you try to redefine it by "${command.format}"`);
|
|
73
|
+
throw new ParseError(spaceTrim(`Format format is already defined to "${$taskJson.format}".
|
|
74
|
+
Now you try to redefine it by "${command.format}"`));
|
|
75
75
|
}
|
|
76
76
|
$taskJson.format = command.format;
|
|
77
77
|
},
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { spaceTrim } from 'spacetrim';
|
|
1
2
|
import {
|
|
2
3
|
TOOL_PROGRESS_TOKEN_ARGUMENT,
|
|
3
4
|
TOOL_PROGRESS_TOKEN_PARAMETER,
|
|
@@ -16,26 +17,28 @@ export function buildToolInvocationScript(options: {
|
|
|
16
17
|
}): string {
|
|
17
18
|
const { functionName, functionArgsExpression } = options;
|
|
18
19
|
|
|
19
|
-
return
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
20
|
+
return spaceTrim(
|
|
21
|
+
(block) => `
|
|
22
|
+
const args = ${block(functionArgsExpression)};
|
|
23
|
+
const runtimeContextRaw =
|
|
24
|
+
typeof ${TOOL_RUNTIME_CONTEXT_PARAMETER} === 'undefined'
|
|
25
|
+
? undefined
|
|
26
|
+
: ${TOOL_RUNTIME_CONTEXT_PARAMETER};
|
|
25
27
|
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
28
|
+
if (runtimeContextRaw !== undefined && args && typeof args === 'object' && !Array.isArray(args)) {
|
|
29
|
+
args.${TOOL_RUNTIME_CONTEXT_ARGUMENT} = runtimeContextRaw;
|
|
30
|
+
}
|
|
29
31
|
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
32
|
+
const toolProgressTokenRaw =
|
|
33
|
+
typeof ${TOOL_PROGRESS_TOKEN_PARAMETER} === 'undefined'
|
|
34
|
+
? undefined
|
|
35
|
+
: ${TOOL_PROGRESS_TOKEN_PARAMETER};
|
|
34
36
|
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
37
|
+
if (toolProgressTokenRaw !== undefined && args && typeof args === 'object' && !Array.isArray(args)) {
|
|
38
|
+
args.${TOOL_PROGRESS_TOKEN_ARGUMENT} = toolProgressTokenRaw;
|
|
39
|
+
}
|
|
38
40
|
|
|
39
|
-
|
|
40
|
-
|
|
41
|
+
return await ${functionName}(args);
|
|
42
|
+
`,
|
|
43
|
+
);
|
|
41
44
|
}
|