@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.
Files changed (296) hide show
  1. package/agents/default/developer.book +1 -0
  2. package/apps/agents-server/next.config.ts +22 -0
  3. package/apps/agents-server/package.json +6 -6
  4. package/apps/agents-server/scripts/build-agents-server.js +43 -7
  5. package/apps/agents-server/scripts/build-e2e.js +12 -2
  6. package/apps/agents-server/scripts/generate-reserved-paths/generate-reserved-paths.ts +30 -16
  7. package/apps/agents-server/scripts/kill-port.js +163 -0
  8. package/apps/agents-server/scripts/run-e2e-tests.js +21 -8
  9. package/apps/agents-server/scripts/run-npm.js +81 -5
  10. package/apps/agents-server/src/app/actions.ts +3 -0
  11. package/apps/agents-server/src/app/admin/email-server/page.tsx +17 -18
  12. package/apps/agents-server/src/app/admin/task-manager/TaskManagerTaskRow.tsx +2 -0
  13. package/apps/agents-server/src/app/admin/task-manager/[taskId]/TaskManagerTaskDetailClient.tsx +2 -0
  14. package/apps/agents-server/src/app/admin/task-manager/taskManagerTaskPresentation.tsx +23 -0
  15. package/apps/agents-server/src/app/agents/[agentName]/api/book/route.ts +7 -0
  16. package/apps/agents-server/src/app/agents/[agentName]/api/timeouts/[timeoutId]/route.ts +10 -153
  17. package/apps/agents-server/src/app/agents/[agentName]/api/timeouts/route.ts +9 -4
  18. package/apps/agents-server/src/app/agents/[agentName]/api/user-chats/[chatId]/route.ts +3 -0
  19. package/apps/agents-server/src/app/agents/[agentName]/api/user-chats/[chatId]/stream/route.ts +2 -0
  20. package/apps/agents-server/src/app/agents/[agentName]/api/user-chats/resolveUserChatScope.ts +8 -1
  21. package/apps/agents-server/src/app/agents/[agentName]/api/user-chats/route.ts +15 -7
  22. package/apps/agents-server/src/app/agents/[agentName]/book/useBookEditorSaving.ts +18 -28
  23. package/apps/agents-server/src/app/agents/[agentName]/chat/AgentChatHistoryClient.tsx +19 -1
  24. package/apps/agents-server/src/app/agents/[agentName]/chat/AgentChatSidebarDefault.tsx +17 -5
  25. package/apps/agents-server/src/app/agents/[agentName]/chat/AgentGoalChatNotice.tsx +23 -0
  26. package/apps/agents-server/src/app/agents/[agentName]/chat/AgentGoalChatPlannedMessages.tsx +153 -0
  27. package/apps/agents-server/src/app/agents/[agentName]/chat/CanonicalAgentChatPanel.tsx +6 -0
  28. package/apps/agents-server/src/app/agents/[agentName]/chat/CanonicalAgentChatSurface.tsx +13 -0
  29. package/apps/agents-server/src/app/agents/[agentName]/chat/ExternalUserChatAdminActions.tsx +51 -3
  30. package/apps/agents-server/src/app/agents/[agentName]/chat/TeamMemberFrozenChatPrimaryAgentLink.tsx +31 -0
  31. package/apps/agents-server/src/app/agents/[agentName]/chat/useAgentChatSidebarState.ts +26 -2
  32. package/apps/agents-server/src/app/agents/[agentName]/goal/page.tsx +35 -0
  33. package/apps/agents-server/src/app/agents/[agentName]/projects/[projectName]/page.tsx +2 -2
  34. package/apps/agents-server/src/app/api/admin/dns-records/cloudflare/route.ts +26 -16
  35. package/apps/agents-server/src/app/api/emails/incoming/stalwart/route.ts +9 -2
  36. package/apps/agents-server/src/app/superadmin/servers/ServersRegistryTable.tsx +31 -39
  37. package/apps/agents-server/src/components/AgentProfile/AgentProfile.tsx +10 -3
  38. package/apps/agents-server/src/components/AgentProjects/AgentProjectIcon.tsx +137 -0
  39. package/apps/agents-server/src/components/AgentProjects/AgentProjectItem.tsx +26 -10
  40. package/apps/agents-server/src/components/CloudflareDnsWizard/CloudflareDnsApiTokenImportStep.tsx +5 -6
  41. package/apps/agents-server/src/components/CloudflareDnsWizard/CloudflareDnsCheckStep.tsx +6 -5
  42. package/apps/agents-server/src/components/CloudflareDnsWizard/CloudflareDnsManualStep.tsx +10 -14
  43. package/apps/agents-server/src/components/CloudflareDnsWizard/CloudflareDnsWizard.tsx +11 -20
  44. package/apps/agents-server/src/components/CloudflareDnsWizard/useCloudflareDnsRecordImport.ts +5 -6
  45. package/apps/agents-server/src/components/DnsRecordsInstructions/DnsRecordsInstructions.tsx +91 -57
  46. package/apps/agents-server/src/components/DnsRecordsInstructions/DnsRecordsSectionPanel.tsx +63 -0
  47. package/apps/agents-server/src/components/DnsRecordsInstructions/DnsRecordsSectionVariantTabs.tsx +67 -0
  48. package/apps/agents-server/src/components/DnsRecordsInstructions/DnsRecordsTable.tsx +40 -0
  49. package/apps/agents-server/src/components/Header/buildActiveAgentViewItems.ts +5 -4
  50. package/apps/agents-server/src/components/Header/createAgentViewLabel.tsx +4 -4
  51. package/apps/agents-server/src/components/Header/resolveActiveAgentNavigation.ts +2 -2
  52. package/apps/agents-server/src/components/Homepage/useAgentsListImportExportState.ts +22 -10
  53. package/apps/agents-server/src/components/_utils/generateMetaTxt.ts +1 -1
  54. package/apps/agents-server/src/database/migratePrefix.ts +13 -12
  55. package/apps/agents-server/src/database/migrations/2026-08-0100-agent-goal-chat-source.sql +10 -0
  56. package/apps/agents-server/src/generated/reservedPaths.ts +42 -42
  57. package/apps/agents-server/src/languages/ServerTranslationKeys.ts +9 -1
  58. package/apps/agents-server/src/languages/translations/czech.yaml +9 -1
  59. package/apps/agents-server/src/languages/translations/english.yaml +9 -1
  60. package/apps/agents-server/src/message-providers/email/stalwart/parseInboundStalwartEmail.ts +17 -2
  61. package/apps/agents-server/src/utils/agentGoalChat/agentGoalChatConstants.ts +9 -0
  62. package/apps/agents-server/src/utils/agentGoalChat/agentGoalChatIdentity.ts +28 -0
  63. package/apps/agents-server/src/utils/agentGoalChat/appendAgentGoalChatNote.ts +43 -0
  64. package/apps/agents-server/src/utils/agentGoalChat/canAccessAgentGoalChat.ts +14 -0
  65. package/apps/agents-server/src/utils/agentGoalChat/createAgentGoalChatNoteContent.ts +69 -0
  66. package/apps/agents-server/src/utils/agentGoalChat/ensureAgentGoalChat.ts +66 -0
  67. package/apps/agents-server/src/utils/agentGoalChat/prependAgentGoalChatSummarySeed.ts +40 -0
  68. package/apps/agents-server/src/utils/agentGoalChat/recordAgentGoalChatLifecycleNote.ts +36 -0
  69. package/apps/agents-server/src/utils/agentGoalChat/resolveAgentGoalChatOwnerUserId.ts +104 -0
  70. package/apps/agents-server/src/utils/agentGoalChat/scheduleAgentGoalChatModifiedNote.ts +82 -0
  71. package/apps/agents-server/src/utils/agentGoalChat.ts +19 -0
  72. package/apps/agents-server/src/utils/agentProjects/AgentProjectInfo.ts +10 -1
  73. package/apps/agents-server/src/utils/agentProjects/AgentProjectReferenceInfo.ts +5 -2
  74. package/apps/agents-server/src/utils/agentProjects/agentProjectFileNames.ts +21 -0
  75. package/apps/agents-server/src/utils/agentProjects/agentProjectHrefs.ts +20 -11
  76. package/apps/agents-server/src/utils/agentProjects/agentProjectsPaths.ts +15 -5
  77. package/apps/agents-server/src/utils/agentProjects/createAgentProjectInitials.ts +36 -0
  78. package/apps/agents-server/src/utils/agentProjects/createAgentProjectMarkdownReferences.ts +11 -9
  79. package/apps/agents-server/src/utils/agentProjects/createAgentProjectsDnsRecordsSection.ts +113 -0
  80. package/apps/agents-server/src/utils/agentProjects/createStaticAgentProjectServer.ts +2 -6
  81. package/apps/agents-server/src/utils/agentProjects/humanizeAgentProjectName.ts +25 -0
  82. package/apps/agents-server/src/utils/agentProjects/listAgentProjectChatReferences.ts +10 -3
  83. package/apps/agents-server/src/utils/agentProjects/parseAgentProjectIndexHtml.ts +167 -0
  84. package/apps/agents-server/src/utils/agentProjects/readAgentProjectIndexHtmlProfile.ts +24 -0
  85. package/apps/agents-server/src/utils/agentProjects/readAgentProjectReadme.ts +3 -53
  86. package/apps/agents-server/src/utils/agentProjects/readAgentProjectRootTextFile.ts +73 -0
  87. package/apps/agents-server/src/utils/agentProjects/resolveAgentProjectFaviconRelativePath.ts +108 -0
  88. package/apps/agents-server/src/utils/agentProjects/resolveAgentProjectInfo.ts +12 -3
  89. package/apps/agents-server/src/utils/agentProjects/{resolveAgentProjectReadmeProfile.ts → resolveAgentProjectProfile.ts} +33 -33
  90. package/apps/agents-server/src/utils/agentProjects/resolveAgentProjectPublicUrls.ts +34 -0
  91. package/apps/agents-server/src/utils/bookLanguageDocumentation/createBookLanguageDocumentationPdfResponse.ts +19 -17
  92. package/apps/agents-server/src/utils/chatTasksAdmin.ts +9 -0
  93. package/apps/agents-server/src/utils/dnsRecords/DnsRecordInstruction.ts +20 -0
  94. package/apps/agents-server/src/utils/dnsRecords/DnsRecordsSection.ts +77 -0
  95. package/apps/agents-server/src/utils/dnsRecords/createServerDnsRecordsSections.ts +58 -0
  96. package/apps/agents-server/src/utils/dnsRecords/createServerDomainDnsRecordsSection.ts +48 -0
  97. package/apps/agents-server/src/utils/dnsRecords/dnsRecordGroups.ts +52 -0
  98. package/apps/agents-server/src/utils/dnsRecords/resolveDnsRecordBatchPlan.ts +47 -1
  99. package/apps/agents-server/src/utils/getAdminChatTasksResponse/getAdminChatTasks/adminChatTaskSqlQuery.ts +41 -36
  100. package/apps/agents-server/src/utils/getAdminChatTasksResponse/getAdminChatTasks/mapAdminChatTaskFallbackRows.ts +3 -0
  101. package/apps/agents-server/src/utils/getAdminChatTasksResponse/getAdminChatTasks/mapAdminChatTaskSqlRows.ts +2 -0
  102. package/apps/agents-server/src/utils/localChatRunner/parseLocalTeamConversations.ts +281 -0
  103. package/apps/agents-server/src/utils/localChatRunner/persistLocalTeamConversations.ts +71 -0
  104. package/apps/agents-server/src/utils/localChatRunner/prepareLocalTeamConversationWorkspace.ts +233 -0
  105. package/apps/agents-server/src/utils/localChatRunner/processLocalUserChatJob.ts +37 -6
  106. package/apps/agents-server/src/utils/serverManagement/createManagedServer/insertManagedServerRegistryRow.ts +2 -2
  107. package/apps/agents-server/src/utils/serverManagement/createManagedServer/seedServerCoreAgents.ts +7 -6
  108. package/apps/agents-server/src/utils/serverManagement/createManagedServer/seedServerDefaultAgents.ts +5 -4
  109. package/apps/agents-server/src/utils/serverManagement/createManagedServer/seedServerMetadata.ts +3 -2
  110. package/apps/agents-server/src/utils/serverManagement/createManagedServer/seedServerUsers.ts +3 -2
  111. package/apps/agents-server/src/utils/serverManagement/deleteManagedServer.ts +2 -2
  112. package/apps/agents-server/src/utils/stalwart/createEmailDnsRecordsSection.ts +53 -0
  113. package/apps/agents-server/src/utils/userChat/UserChatRecord.ts +13 -0
  114. package/apps/agents-server/src/utils/userChat/UserChatSource.ts +14 -0
  115. package/apps/agents-server/src/utils/userChat/createUserChatSummary.ts +10 -2
  116. package/apps/agents-server/src/utils/userChat/finalizeUserChatJob.ts +3 -2
  117. package/apps/agents-server/src/utils/userChat/getUserChat.ts +16 -1
  118. package/apps/agents-server/src/utils/userChat/getUserChatForJobRunner.ts +31 -0
  119. package/apps/agents-server/src/utils/userChat/listUserChats.ts +113 -110
  120. package/apps/agents-server/src/utils/userChat/persistFrozenUserChat.ts +21 -6
  121. package/apps/agents-server/src/utils/userChat/runImmediateUserChatAnswer.ts +2 -6
  122. package/apps/agents-server/src/utils/userChat/runUserChatJob.ts +2 -6
  123. package/apps/agents-server/src/utils/userChat/teamMemberUserChatContext.ts +63 -0
  124. package/apps/agents-server/src/utils/userChat.ts +5 -1
  125. package/apps/agents-server/src/utils/userChatClient/cancelAgentUserTimeout.ts +2 -2
  126. package/apps/agents-server/src/utils/userChatClient/fetchAgentUserTimeouts.ts +2 -2
  127. package/apps/agents-server/src/utils/userChatClient.ts +9 -31
  128. package/apps/agents-server/src/utils/userChatTimeout/UserChatTimeoutRecord.ts +10 -2
  129. package/apps/agents-server/src/utils/userChatTimeout/userChatTimeoutStore/claimNextDueUserChatTimeout.ts +28 -25
  130. package/apps/agents-server/src/utils/userChatTimeout/userChatTimeoutStore/getAgentScopedUserChatTimeout.ts +8 -4
  131. package/apps/agents-server/src/utils/userChatTimeout/userChatTimeoutStore/listAgentUserChatTimeouts.ts +4 -1
  132. package/apps/agents-server/src/utils/userChatTimeout/userChatTimeoutStore/recoverExpiredRunningUserChatTimeouts.ts +3 -2
  133. package/apps/agents-server/src/utils/userChatTimeout/userChatTimeoutWorker.ts +53 -0
  134. package/esm/index.es.js +1534 -401
  135. package/esm/index.es.js.map +1 -1
  136. package/esm/scripts/run-agent-messages/messages/buildAgentMessagePrompt.d.ts +7 -1
  137. package/esm/scripts/run-agent-messages/messages/buildAgentTeamPromptSection.d.ts +12 -0
  138. package/esm/scripts/run-agent-messages/messages/finalizeAgentTeamConversationWorkspace.d.ts +16 -0
  139. package/esm/scripts/run-agent-messages/messages/loadAgentTeamConversationWorkspace.d.ts +6 -0
  140. package/esm/scripts/run-codex-prompts/common/normalizeLineEndingsInChangedFiles.d.ts +2 -3
  141. package/esm/scripts/run-codex-prompts/git/coderCommitScope.d.ts +31 -0
  142. package/esm/scripts/run-codex-prompts/git/coderGitSync.d.ts +15 -2
  143. package/esm/scripts/run-codex-prompts/git/commitChanges.d.ts +9 -3
  144. package/esm/scripts/run-codex-prompts/git/workingTreeChanges.d.ts +40 -0
  145. package/esm/scripts/run-codex-prompts/server/coderServerHtml.d.ts +1 -1
  146. package/esm/scripts/run-codex-prompts/ui/buildCoderRunAgentVisual.d.ts +5 -5
  147. package/esm/scripts/run-codex-prompts/ui/buildCoderRunUiTerminalFrameUpdate.d.ts +27 -0
  148. package/esm/src/avatars/renderAvatarVisualTerminalText.d.ts +80 -0
  149. package/esm/src/avatars/types/AvatarVisualDefinition.d.ts +54 -0
  150. package/esm/src/book-3.0/AgentTeamConversationWorkspace.d.ts +85 -0
  151. package/esm/src/book-components/Chat/Chat/ChatProps.d.ts +3 -2
  152. package/esm/src/book-components/Chat/utils/renderMarkdown.d.ts +12 -3
  153. package/esm/src/cli/cli-commands/coder/boilerplateCount.d.ts +1 -1
  154. package/esm/src/cli/cli-commands/coder/generate-boilerplates.d.ts +1 -1
  155. package/esm/src/cli/cli-commands/common/{harness/$askForHarnessInstallationApproval.d.ts → npm/$askForNpmPackageInstallationApproval.d.ts} +2 -2
  156. package/{umd/src/cli/cli-commands/common/harness/$resolveLatestHarnessVersion.d.ts → esm/src/cli/cli-commands/common/npm/$resolveLatestNpmPackageVersion.d.ts} +2 -3
  157. package/esm/src/cli/cli-commands/common/npm/extractNpmPackageVersionFromOutput.d.ts +12 -0
  158. package/esm/src/cli/cli-commands/common/npm/isNpmPackageVersionOutdated.d.ts +9 -0
  159. package/esm/src/cli/cli-commands/common/promptbook-cli/$checkPromptbookCliInstallations.d.ts +9 -0
  160. package/esm/src/cli/cli-commands/common/promptbook-cli/$ensurePromptbookCliInstallations.d.ts +14 -0
  161. package/esm/src/cli/cli-commands/common/promptbook-cli/$ensurePromptbookCliInstallations.test.d.ts +1 -0
  162. package/esm/src/cli/cli-commands/common/promptbook-cli/$resolvePromptbookCliInstallations.d.ts +12 -0
  163. package/esm/src/cli/cli-commands/common/promptbook-cli/$resolvePromptbookCliInstallations.test.d.ts +1 -0
  164. package/esm/src/cli/cli-commands/common/promptbook-cli/$updatePromptbookCliInstallation.d.ts +10 -0
  165. package/esm/src/cli/cli-commands/common/promptbook-cli/PromptbookCliInstallation.d.ts +39 -0
  166. package/esm/src/cli/cli-commands/common/promptbook-cli/PromptbookCliInstallationStatus.d.ts +26 -0
  167. package/esm/src/cli/cli-commands/common/promptbook-cli/buildPromptbookCliInstallCommand.d.ts +7 -0
  168. package/esm/src/cli/cli-commands/common/promptbook-cli/buildPromptbookCliInstallCommand.test.d.ts +1 -0
  169. package/esm/src/cli/cli-commands/common/promptbook-cli/formatPromptbookCliInstallationWarning.d.ts +7 -0
  170. package/esm/src/utils/agent-message-runtime/resolveAgentMessageRuntimeActivity.d.ts +3 -3
  171. package/esm/src/utils/agents/terminalAgentAvatarVisual.d.ts +5 -2
  172. package/esm/src/utils/ascii-art/convertImageDataToAsciiArt.d.ts +6 -0
  173. package/esm/src/utils/ascii-art/createAnsiColorCode.d.ts +46 -0
  174. package/esm/src/utils/misc/debounce.d.ts +4 -2
  175. package/esm/src/utils/misc/debounce.test.d.ts +1 -0
  176. package/esm/src/version.d.ts +1 -1
  177. package/package.json +1 -1
  178. package/src/avatars/renderAvatarVisualTerminalText.ts +249 -0
  179. package/src/avatars/types/AvatarVisualDefinition.ts +60 -0
  180. package/src/avatars/visuals/asciiOctopusAvatarVisual.ts +144 -22
  181. package/src/book-2.0/book-language-documentation/createStandaloneBookLanguageMarkdown.ts +4 -4
  182. package/src/book-2.0/book-language-documentation/renderCommitmentCatalogSection.ts +1 -4
  183. package/src/book-2.0/book-language-documentation/renderGroupedCommitmentDocumentationMarkdown.ts +4 -17
  184. package/src/book-3.0/AgentTeamConversationWorkspace.ts +172 -0
  185. package/src/book-components/BookEditor/useBookEditorMonacoStyles.ts +56 -55
  186. package/src/book-components/Chat/Chat/Chat.module.css +1 -8
  187. package/src/book-components/Chat/Chat/ChatMessageMap.tsx +8 -4
  188. package/src/book-components/Chat/Chat/ChatProps.tsx +3 -2
  189. package/src/book-components/Chat/MarkdownContent/MarkdownContent.module.css +14 -14
  190. package/src/book-components/Chat/save/react/exports/chat-preview-2025-10-13 (1).jsx +95 -5
  191. package/src/book-components/Chat/utils/renderMarkdown.ts +535 -89
  192. package/src/cli/cli-commands/coder/add.ts +3 -3
  193. package/src/cli/cli-commands/coder/boilerplateCount.ts +1 -1
  194. package/src/cli/cli-commands/coder/generate-boilerplates.ts +27 -27
  195. package/src/cli/cli-commands/coder/getDefaultCoderPackageJsonScripts.ts +5 -4
  196. package/src/cli/cli-commands/coder/init.ts +3 -3
  197. package/src/cli/cli-commands/coder/run.ts +10 -2
  198. package/src/cli/cli-commands/common/coderGitSyncCliOptions.ts +6 -2
  199. package/src/cli/cli-commands/common/harness/$applyHarnessInstallationStatus.ts +2 -2
  200. package/src/cli/cli-commands/common/harness/$checkHarnessInstallation.ts +4 -4
  201. package/src/cli/cli-commands/common/harness/$resolveInstalledHarnessVersion.ts +2 -2
  202. package/src/cli/cli-commands/common/{harness/$askForHarnessInstallationApproval.ts → npm/$askForNpmPackageInstallationApproval.ts} +3 -3
  203. package/src/cli/cli-commands/common/npm/$resolveLatestNpmPackageVersion.ts +49 -0
  204. package/src/cli/cli-commands/common/npm/extractNpmPackageVersionFromOutput.ts +25 -0
  205. package/src/cli/cli-commands/common/{harness/isHarnessVersionOutdated.ts → npm/isNpmPackageVersionOutdated.ts} +6 -4
  206. package/src/cli/cli-commands/common/projectInitialization.ts +10 -1
  207. package/src/cli/cli-commands/common/promptbook-cli/$checkPromptbookCliInstallations.ts +73 -0
  208. package/src/cli/cli-commands/common/promptbook-cli/$ensurePromptbookCliInstallations.ts +94 -0
  209. package/src/cli/cli-commands/common/promptbook-cli/$resolvePromptbookCliInstallations.ts +223 -0
  210. package/src/cli/cli-commands/common/promptbook-cli/$updatePromptbookCliInstallation.ts +53 -0
  211. package/src/cli/cli-commands/common/promptbook-cli/PromptbookCliInstallation.ts +46 -0
  212. package/src/cli/cli-commands/common/promptbook-cli/PromptbookCliInstallationStatus.ts +32 -0
  213. package/src/cli/cli-commands/common/promptbook-cli/buildPromptbookCliInstallCommand.ts +22 -0
  214. package/src/cli/cli-commands/common/promptbook-cli/formatPromptbookCliInstallationWarning.ts +47 -0
  215. package/src/commands/FORMAT/formatCommandParser.ts +2 -2
  216. package/src/llm-providers/openai/utils/buildToolInvocationScript.ts +21 -18
  217. package/src/other/templates/getTemplatesPipelineCollection.ts +976 -668
  218. package/src/utils/agent-message-runtime/resolveAgentMessageRuntimeActivity.ts +80 -27
  219. package/src/utils/agents/terminalAgentAvatarVisual.ts +31 -3
  220. package/src/utils/ascii-art/convertImageDataToAsciiArt.ts +9 -109
  221. package/src/utils/ascii-art/createAnsiColorCode.ts +132 -0
  222. package/src/utils/misc/debounce.ts +26 -5
  223. package/src/version.ts +2 -2
  224. package/src/versions.txt +2 -0
  225. package/umd/index.umd.js +1533 -400
  226. package/umd/index.umd.js.map +1 -1
  227. package/umd/scripts/run-agent-messages/messages/buildAgentMessagePrompt.d.ts +7 -1
  228. package/umd/scripts/run-agent-messages/messages/buildAgentTeamPromptSection.d.ts +12 -0
  229. package/umd/scripts/run-agent-messages/messages/finalizeAgentTeamConversationWorkspace.d.ts +16 -0
  230. package/umd/scripts/run-agent-messages/messages/loadAgentTeamConversationWorkspace.d.ts +6 -0
  231. package/umd/scripts/run-codex-prompts/common/normalizeLineEndingsInChangedFiles.d.ts +2 -3
  232. package/umd/scripts/run-codex-prompts/git/coderCommitScope.d.ts +31 -0
  233. package/umd/scripts/run-codex-prompts/git/coderGitSync.d.ts +15 -2
  234. package/umd/scripts/run-codex-prompts/git/commitChanges.d.ts +9 -3
  235. package/umd/scripts/run-codex-prompts/git/workingTreeChanges.d.ts +40 -0
  236. package/umd/scripts/run-codex-prompts/server/coderServerHtml.d.ts +1 -1
  237. package/umd/scripts/run-codex-prompts/ui/buildCoderRunAgentVisual.d.ts +5 -5
  238. package/umd/scripts/run-codex-prompts/ui/buildCoderRunUiTerminalFrameUpdate.d.ts +27 -0
  239. package/umd/src/avatars/renderAvatarVisualTerminalText.d.ts +80 -0
  240. package/umd/src/avatars/renderAvatarVisualTerminalText.test.d.ts +1 -0
  241. package/umd/src/avatars/types/AvatarVisualDefinition.d.ts +54 -0
  242. package/umd/src/book-3.0/AgentTeamConversationWorkspace.d.ts +85 -0
  243. package/umd/src/book-components/Chat/Chat/ChatProps.d.ts +3 -2
  244. package/umd/src/book-components/Chat/utils/renderMarkdown.d.ts +12 -3
  245. package/umd/src/cli/cli-commands/coder/boilerplateCount.d.ts +1 -1
  246. package/umd/src/cli/cli-commands/coder/generate-boilerplates.d.ts +1 -1
  247. package/umd/src/cli/cli-commands/common/{harness/$askForHarnessInstallationApproval.d.ts → npm/$askForNpmPackageInstallationApproval.d.ts} +2 -2
  248. package/{esm/src/cli/cli-commands/common/harness/$resolveLatestHarnessVersion.d.ts → umd/src/cli/cli-commands/common/npm/$resolveLatestNpmPackageVersion.d.ts} +2 -3
  249. package/umd/src/cli/cli-commands/common/npm/$resolveLatestNpmPackageVersion.test.d.ts +1 -0
  250. package/umd/src/cli/cli-commands/common/npm/extractNpmPackageVersionFromOutput.d.ts +12 -0
  251. package/umd/src/cli/cli-commands/common/npm/extractNpmPackageVersionFromOutput.test.d.ts +1 -0
  252. package/umd/src/cli/cli-commands/common/npm/isNpmPackageVersionOutdated.d.ts +9 -0
  253. package/umd/src/cli/cli-commands/common/npm/isNpmPackageVersionOutdated.test.d.ts +1 -0
  254. package/umd/src/cli/cli-commands/common/promptbook-cli/$checkPromptbookCliInstallations.d.ts +9 -0
  255. package/umd/src/cli/cli-commands/common/promptbook-cli/$ensurePromptbookCliInstallations.d.ts +14 -0
  256. package/umd/src/cli/cli-commands/common/promptbook-cli/$ensurePromptbookCliInstallations.test.d.ts +1 -0
  257. package/umd/src/cli/cli-commands/common/promptbook-cli/$resolvePromptbookCliInstallations.d.ts +12 -0
  258. package/umd/src/cli/cli-commands/common/promptbook-cli/$resolvePromptbookCliInstallations.test.d.ts +1 -0
  259. package/umd/src/cli/cli-commands/common/promptbook-cli/$updatePromptbookCliInstallation.d.ts +10 -0
  260. package/umd/src/cli/cli-commands/common/promptbook-cli/PromptbookCliInstallation.d.ts +39 -0
  261. package/umd/src/cli/cli-commands/common/promptbook-cli/PromptbookCliInstallationStatus.d.ts +26 -0
  262. package/umd/src/cli/cli-commands/common/promptbook-cli/buildPromptbookCliInstallCommand.d.ts +7 -0
  263. package/umd/src/cli/cli-commands/common/promptbook-cli/buildPromptbookCliInstallCommand.test.d.ts +1 -0
  264. package/umd/src/cli/cli-commands/common/promptbook-cli/formatPromptbookCliInstallationWarning.d.ts +7 -0
  265. package/umd/src/utils/agent-message-runtime/resolveAgentMessageRuntimeActivity.d.ts +3 -3
  266. package/umd/src/utils/agents/terminalAgentAvatarVisual.d.ts +5 -2
  267. package/umd/src/utils/ascii-art/convertImageDataToAsciiArt.d.ts +6 -0
  268. package/umd/src/utils/ascii-art/createAnsiColorCode.d.ts +46 -0
  269. package/umd/src/utils/misc/debounce.d.ts +4 -2
  270. package/umd/src/utils/misc/debounce.test.d.ts +1 -0
  271. package/umd/src/version.d.ts +1 -1
  272. package/apps/agents-server/scripts/ignore-kill-eperm.js +0 -31
  273. package/apps/agents-server/src/app/agents/[agentName]/api/timeouts/actions/route.ts +0 -103
  274. package/apps/agents-server/src/app/agents/[agentName]/timeouts/AgentTimeoutsClient.tsx +0 -43
  275. package/apps/agents-server/src/app/agents/[agentName]/timeouts/AgentTimeoutsEditDialog.tsx +0 -98
  276. package/apps/agents-server/src/app/agents/[agentName]/timeouts/AgentTimeoutsFiltersCard.tsx +0 -75
  277. package/apps/agents-server/src/app/agents/[agentName]/timeouts/AgentTimeoutsHeader.tsx +0 -53
  278. package/apps/agents-server/src/app/agents/[agentName]/timeouts/AgentTimeoutsSummaryMetrics.tsx +0 -70
  279. package/apps/agents-server/src/app/agents/[agentName]/timeouts/AgentTimeoutsTableCard.tsx +0 -58
  280. package/apps/agents-server/src/app/agents/[agentName]/timeouts/AgentTimeoutsTableRow.tsx +0 -242
  281. package/apps/agents-server/src/app/agents/[agentName]/timeouts/loading.tsx +0 -15
  282. package/apps/agents-server/src/app/agents/[agentName]/timeouts/page.tsx +0 -28
  283. package/apps/agents-server/src/app/agents/[agentName]/timeouts/useAgentTimeoutsClientState.ts +0 -769
  284. package/apps/agents-server/src/components/AgentProjectDnsInstructions/AgentProjectDnsInstructions.tsx +0 -182
  285. package/apps/agents-server/src/utils/userChatClient/runAgentUserTimeoutBulkAction.ts +0 -24
  286. package/apps/agents-server/src/utils/userChatClient/updateAgentUserTimeout.ts +0 -25
  287. package/esm/src/cli/cli-commands/common/harness/extractHarnessVersionFromOutput.d.ts +0 -11
  288. package/esm/src/cli/cli-commands/common/harness/isHarnessVersionOutdated.d.ts +0 -9
  289. package/src/cli/cli-commands/common/harness/$resolveLatestHarnessVersion.ts +0 -34
  290. package/src/cli/cli-commands/common/harness/extractHarnessVersionFromOutput.ts +0 -28
  291. package/umd/src/cli/cli-commands/common/harness/extractHarnessVersionFromOutput.d.ts +0 -11
  292. package/umd/src/cli/cli-commands/common/harness/isHarnessVersionOutdated.d.ts +0 -9
  293. /package/esm/src/{cli/cli-commands/common/harness/extractHarnessVersionFromOutput.test.d.ts → avatars/renderAvatarVisualTerminalText.test.d.ts} +0 -0
  294. /package/esm/src/cli/cli-commands/common/{harness/isHarnessVersionOutdated.test.d.ts → npm/$resolveLatestNpmPackageVersion.test.d.ts} +0 -0
  295. /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
  296. /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
@@ -102,11 +102,11 @@ export function $initializeCoderAddCommand(program: Program): $side_effect {
102
102
  const description = await resolveCoderPromptDescription(descriptionArgument);
103
103
 
104
104
  // Note: Import the git synchronization dynamically to keep the CLI fast for runs without `--commit`
105
- const { $commitCoderChanges, $pullCoderChanges } = await import(
105
+ const { $commitCoderChanges, $startCoderGitSync } = await import(
106
106
  '../../../../scripts/run-codex-prompts/git/coderGitSync'
107
107
  );
108
108
 
109
- await $pullCoderChanges({ gitSync, projectPath });
109
+ const commitScope = await $startCoderGitSync({ gitSync, projectPath });
110
110
 
111
111
  const { /* filePath,*/ emojiTag } = await addCoderPrompt({
112
112
  projectPath,
@@ -117,7 +117,7 @@ export function $initializeCoderAddCommand(program: Program): $side_effect {
117
117
 
118
118
  await $commitCoderChanges({
119
119
  gitSync,
120
- projectPath,
120
+ commitScope,
121
121
  commitMessage: `${emojiTag} Add prompt`,
122
122
  });
123
123
  }),
@@ -29,7 +29,7 @@ export type BoilerplateCount = {
29
29
  * Number of prompts written into each generated file.
30
30
  *
31
31
  * Note: More than one prompt per file is an advanced option - each prompt is one separate
32
- * coding task separated by `---` and tagged with its own fresh emoji tag.
32
+ * coding task separated by `---`, with all prompts in the file sharing its fresh emoji tag.
33
33
  */
34
34
  readonly promptsPerFileCount: number;
35
35
  };
@@ -39,7 +39,7 @@ export function $initializeCoderGenerateBoilerplatesCommand(program: Program): $
39
39
  command.description(
40
40
  spaceTrim(
41
41
  (block) => `
42
- Generate prompt boilerplate files with unique emoji tags
42
+ Generate prompt boilerplate files with one unique emoji tag per file
43
43
 
44
44
  ${block(CODER_GIT_SYNC_DESCRIPTION)}
45
45
  `,
@@ -71,11 +71,11 @@ export function $initializeCoderGenerateBoilerplatesCommand(program: Program): $
71
71
  const projectPath = process.cwd();
72
72
 
73
73
  // Note: Import the git synchronization dynamically to keep the CLI fast for runs without `--commit`
74
- const { $commitCoderChanges, $pullCoderChanges } = await import(
74
+ const { $commitCoderChanges, $startCoderGitSync } = await import(
75
75
  '../../../../scripts/run-codex-prompts/git/coderGitSync'
76
76
  );
77
77
 
78
- await $pullCoderChanges({ gitSync, projectPath });
78
+ const commitScope = await $startCoderGitSync({ gitSync, projectPath });
79
79
 
80
80
  await generatePromptBoilerplate({
81
81
  projectPath,
@@ -85,7 +85,7 @@ export function $initializeCoderGenerateBoilerplatesCommand(program: Program): $
85
85
 
86
86
  await $commitCoderChanges({
87
87
  gitSync,
88
- projectPath,
88
+ commitScope,
89
89
  commitMessage: `Prompts ${formatBoilerplateCount(boilerplateCount)}`,
90
90
  });
91
91
 
@@ -95,7 +95,7 @@ export function $initializeCoderGenerateBoilerplatesCommand(program: Program): $
95
95
  }
96
96
 
97
97
  /**
98
- * Generates boilerplate prompt files with unique emoji tags.
98
+ * Generates boilerplate prompt files with one unique emoji tag per file.
99
99
  *
100
100
  * @private internal function of `generatePromptBoilerplate` command
101
101
  */
@@ -134,10 +134,10 @@ export async function generatePromptBoilerplate({
134
134
  colors.blue(`Highest existing number for ${promptNumbering.datePrefix} found: ${highestNumberFormatted}`),
135
135
  );
136
136
 
137
- // Note: Every single generated prompt is one separate coding task, so each of them reserves its own fresh emoji tag
138
137
  const promptsCount = filesCount * promptsPerFileCount;
139
138
  const { availableCount, selectedEmojis } = await getFreshPromptEmojiTags({
140
- count: promptsCount,
139
+ // Note: Each generated file reserves one fresh emoji tag shared by all of its prompt sections
140
+ count: filesCount,
141
141
  rootDir: projectPath,
142
142
  });
143
143
 
@@ -154,9 +154,7 @@ export async function generatePromptBoilerplate({
154
154
  for (let i = 0; i < filesCount; i++) {
155
155
  const number = promptNumbering.startNumber + i * promptNumbering.step;
156
156
  const title = titles[i % titles.length]!;
157
- const emojiTags = selectedEmojis
158
- .slice(i * promptsPerFileCount, (i + 1) * promptsPerFileCount)
159
- .map((emoji) => formatPromptEmojiTag(emoji));
157
+ const emojiTag = formatPromptEmojiTag(selectedEmojis[i]!);
160
158
  const filename = buildPromptFilename(
161
159
  promptNumbering.datePrefix,
162
160
  number,
@@ -165,7 +163,8 @@ export async function generatePromptBoilerplate({
165
163
  const filepath = join(PROMPTS_DIRECTORY_PATH, filename);
166
164
  const absoluteFilepath = join(projectPath, filepath);
167
165
  const content = buildBoilerplatePromptFileContent({
168
- emojiTags,
166
+ emojiTag,
167
+ promptsPerFileCount,
169
168
  title,
170
169
  body: promptTemplate.content,
171
170
  });
@@ -175,7 +174,7 @@ export async function generatePromptBoilerplate({
175
174
  absoluteFilepath,
176
175
  filename,
177
176
  content,
178
- emojiTags,
177
+ emojiTag,
179
178
  number,
180
179
  });
181
180
  }
@@ -185,7 +184,7 @@ export async function generatePromptBoilerplate({
185
184
 
186
185
  for (const file of filesToCreate) {
187
186
  writeFileSync(file.absoluteFilepath, file.content, 'utf-8');
188
- console.info(colors.green(`✓ Created: ${file.filename} with ${file.emojiTags.join(' ')}`));
187
+ console.info(colors.green(`✓ Created: ${file.filename} with ${file.emojiTag}`));
189
188
  }
190
189
 
191
190
  console.info(
@@ -196,31 +195,32 @@ export async function generatePromptBoilerplate({
196
195
  }
197
196
 
198
197
  /**
199
- * Builds the markdown content of one generated prompt file with one prompt section per emoji tag.
198
+ * Builds the markdown content of one generated prompt file with one prompt section per prompt.
200
199
  *
201
- * Multiple prompts in one file are separated by the `---` separator, exactly like the prompt runner expects them.
200
+ * Multiple prompts in one file share the file emoji tag and are separated by the `---` separator,
201
+ * exactly like the prompt runner expects them.
202
202
  *
203
203
  * @private internal utility of `generatePromptBoilerplate` command
204
204
  */
205
205
  function buildBoilerplatePromptFileContent({
206
- emojiTags,
206
+ emojiTag,
207
+ promptsPerFileCount,
207
208
  title,
208
209
  body,
209
210
  }: {
210
- readonly emojiTags: ReadonlyArray<string>;
211
+ readonly emojiTag: string;
212
+ readonly promptsPerFileCount: number;
211
213
  readonly title: string;
212
214
  readonly body: string;
213
215
  }): string {
214
- return emojiTags
215
- .map((emojiTag) =>
216
- buildCoderPromptSection({
217
- statusLine: '[-]',
218
- emojiTag,
219
- title,
220
- body,
221
- }),
222
- )
223
- .join('\n\n---\n\n');
216
+ return Array.from({ length: promptsPerFileCount }, () =>
217
+ buildCoderPromptSection({
218
+ statusLine: '[-]',
219
+ emojiTag,
220
+ title,
221
+ body,
222
+ }),
223
+ ).join('\n\n---\n\n');
224
224
  }
225
225
 
226
226
  /**
@@ -4,12 +4,13 @@ import { DEFAULT_BOILERPLATE_COUNT_OPTION_VALUE } from './boilerplateCount';
4
4
  * Default npm scripts initialized by `ptbk coder init`.
5
5
  */
6
6
  const DEFAULT_CODER_PACKAGE_JSON_SCRIPTS = {
7
- 'coder:generate-boilerplates': `ptbk coder generate-boilerplates --count ${DEFAULT_BOILERPLATE_COUNT_OPTION_VALUE} --template ./prompts/templates/common.md`,
8
- 'coder:add': 'ptbk coder add --template ./prompts/templates/common.md',
7
+ // Note: Using NPX because `ptbk` can be installed globally or locally, and NPX will resolve it correctly in either case.
8
+ 'coder:generate-boilerplates': `npx ptbk coder generate-boilerplates --count ${DEFAULT_BOILERPLATE_COUNT_OPTION_VALUE} --template ./prompts/templates/common.md`,
9
+ 'coder:add': 'npx ptbk coder add --template ./prompts/templates/common.md',
9
10
  'coder:run':
10
- 'ptbk coder run --harness openai-codex --model gpt-5.6-terra --thinking-level max --agent agents/developer.book --context AGENTS.md --test-before yes-and-fix',
11
+ 'npx ptbk coder run --harness openai-codex --model gpt-5.6-terra --thinking-level max --agent agents/developer.book --context AGENTS.md --test-before yes-and-fix',
11
12
  // 'coder:find-refactor-candidates': 'npx ptbk coder find-refactor-candidates',
12
- 'coder:verify': 'ptbk coder verify',
13
+ 'coder:verify': 'npx ptbk coder verify',
13
14
  } as const satisfies Readonly<Record<string, string>>;
14
15
 
15
16
  /**
@@ -82,11 +82,11 @@ export function $initializeCoderInitCommand(program: Program): $side_effect {
82
82
  const projectPath = process.cwd();
83
83
 
84
84
  // Note: Import the git synchronization dynamically to keep the CLI fast for runs without `--commit`
85
- const { $commitCoderChanges, $pullCoderChanges } = await import(
85
+ const { $commitCoderChanges, $startCoderGitSync } = await import(
86
86
  '../../../../scripts/run-codex-prompts/git/coderGitSync'
87
87
  );
88
88
 
89
- await $pullCoderChanges({ gitSync, projectPath });
89
+ const commitScope = await $startCoderGitSync({ gitSync, projectPath });
90
90
 
91
91
  const summary = await initializeCoderProjectConfiguration(projectPath);
92
92
  printInitializationSummary(summary);
@@ -94,7 +94,7 @@ export function $initializeCoderInitCommand(program: Program): $side_effect {
94
94
 
95
95
  await $commitCoderChanges({
96
96
  gitSync,
97
- projectPath,
97
+ commitScope,
98
98
  commitMessage: 'Initialize Promptbook Coder',
99
99
  });
100
100
 
@@ -10,6 +10,7 @@ import { createNonNegativeIntegerOptionParser } from '../common/createNonNegativ
10
10
  import { createPositiveIntegerOptionParser } from '../common/createPositiveIntegerOptionParser';
11
11
  import { handleActionErrors } from '../common/handleActionErrors';
12
12
  import { $ensureHarnessInstallations } from '../common/harness/$ensureHarnessInstallations';
13
+ import { $ensurePromptbookCliInstallations } from '../common/promptbook-cli/$ensurePromptbookCliInstallations';
13
14
  import type { PromptRunnerCliOptions } from '../common/promptRunnerCliOptions';
14
15
  import {
15
16
  addPromptRunnerExecutionOptions,
@@ -41,12 +42,14 @@ export function $initializeCoderRunCommand(program: Program): $side_effect {
41
42
 
42
43
  Features:
43
44
  - Automatically stages and commits changes with agent identity unless --no-commit is used
45
+ - Commits only the prompt file and the files the coding agent has changed, leaving unrelated changes alone
44
46
  - Optional post-commit git push with explicit --auto-push opt-in
45
47
  - Optional pre-prompt git pull with explicit --auto-pull opt-in
46
48
  - Optional --isolate runs every prompt in its own temporary git worktree and merges it back when verified
47
49
  - Optional --preserve-logs keeps temp prompt/log artifacts after successful rounds
48
50
  - Optional --no-ui keeps plain streaming console output for logging and debugging
49
51
  - Checks that the selected harness is installed globally and up to date before the first prompt
52
+ - In interactive mode, checks local and global Promptbook CLI installations and offers to update them
50
53
  - Supports GPG signing of commits
51
54
  - Optional pre-coding test run that can stop or repair pre-existing failures
52
55
  - Optional post-prompt verification with test-feedback retries
@@ -196,8 +199,6 @@ export function $initializeCoderRunCommand(program: Program): $side_effect {
196
199
  isAgentRequired: !dryRun,
197
200
  });
198
201
 
199
- await $ensureHarnessInstallations([runnerOptions.agentName]);
200
-
201
202
  // [1] Parse the wait options and --no-auto:
202
203
  // default: run automatically through the queue (no waiting between prompts)
203
204
  // --no-auto: wait for user confirmation before each prompt (interactive mode)
@@ -205,6 +206,13 @@ export function $initializeCoderRunCommand(program: Program): $side_effect {
205
206
  // --wait-between-prompts: pace from start of one prompt to start of next
206
207
  // --wait-after-error: wait before retrying after an error (default 10m)
207
208
  const waitForUser = !auto;
209
+
210
+ if (waitForUser && (await $ensurePromptbookCliInstallations())) {
211
+ return process.exit(0);
212
+ }
213
+
214
+ await $ensureHarnessInstallations([runnerOptions.agentName]);
215
+
208
216
  const waitAfterPrompt = parseOptionalWaitDuration(waitAfterPromptValue, 0);
209
217
  const waitBetweenPrompts = parseOptionalWaitDuration(waitBetweenPromptsValue, 0);
210
218
  const waitAfterError = parseOptionalWaitDuration(waitAfterErrorValue, DEFAULT_WAIT_AFTER_ERROR_MS);
@@ -26,7 +26,7 @@ export type CoderGitSyncCliOptions = {
26
26
  export const CODER_GIT_SYNC_DESCRIPTION = spaceTrim(`
27
27
  Git synchronization:
28
28
  - --auto-pull pulls the latest changes before this command changes anything
29
- - --commit commits the changes made by this command
29
+ - --commit commits only the files this command has changed, unrelated changes stay in the working tree
30
30
  - --auto-push pushes the created commit to the remote repository
31
31
  `);
32
32
 
@@ -39,7 +39,11 @@ export const CODER_GIT_SYNC_DESCRIPTION = spaceTrim(`
39
39
  * @private internal utility of `promptbookCli`
40
40
  */
41
41
  export function addCoderGitSyncOptions(command: Program): void {
42
- command.option('--commit', 'Commit the changes made by this command with the coding-agent git identity', false);
42
+ command.option(
43
+ '--commit',
44
+ 'Commit the files changed by this command with the coding-agent git identity, leaving unrelated changes uncommitted',
45
+ false,
46
+ );
43
47
  command.option('--auto-push', 'Automatically git push the created commit, requires --commit', false);
44
48
  command.option(
45
49
  '--auto-pull',
@@ -1,5 +1,5 @@
1
1
  import colors from 'colors';
2
- import { $askForHarnessInstallationApproval } from './$askForHarnessInstallationApproval';
2
+ import { $askForNpmPackageInstallationApproval } from '../npm/$askForNpmPackageInstallationApproval';
3
3
  import { $installHarness } from './$installHarness';
4
4
  import { buildHarnessInstallCommand } from './buildHarnessInstallCommand';
5
5
  import type { HarnessInstallationStatus } from './HarnessInstallationStatus';
@@ -31,7 +31,7 @@ export async function $applyHarnessInstallationStatus(status: HarnessInstallatio
31
31
 
32
32
  console.warn(colors.yellow(formatHarnessInstallationWarning(status)));
33
33
 
34
- const isInstallationApproved = await $askForHarnessInstallationApproval(
34
+ const isInstallationApproved = await $askForNpmPackageInstallationApproval(
35
35
  installationState === 'not-installed'
36
36
  ? `Install ${definition.label} globally now?`
37
37
  : `Update ${definition.label} to ${latestVersion} now?`,
@@ -1,8 +1,8 @@
1
1
  import { $resolveInstalledHarnessVersion } from './$resolveInstalledHarnessVersion';
2
- import { $resolveLatestHarnessVersion } from './$resolveLatestHarnessVersion';
2
+ import { $resolveLatestNpmPackageVersion } from '../npm/$resolveLatestNpmPackageVersion';
3
3
  import type { HarnessDefinition } from './HarnessDefinition';
4
4
  import type { HarnessInstallationState, HarnessInstallationStatus } from './HarnessInstallationStatus';
5
- import { isHarnessVersionOutdated } from './isHarnessVersionOutdated';
5
+ import { isNpmPackageVersionOutdated } from '../npm/isNpmPackageVersionOutdated';
6
6
 
7
7
  /**
8
8
  * Detects whether one CLI coding harness is installed globally and whether it is up to date.
@@ -14,7 +14,7 @@ import { isHarnessVersionOutdated } from './isHarnessVersionOutdated';
14
14
  export async function $checkHarnessInstallation(definition: HarnessDefinition): Promise<HarnessInstallationStatus> {
15
15
  const [installedVersion, latestVersion] = await Promise.all([
16
16
  $resolveInstalledHarnessVersion(definition),
17
- $resolveLatestHarnessVersion(definition),
17
+ $resolveLatestNpmPackageVersion(definition.npmPackageName),
18
18
  ]);
19
19
 
20
20
  return {
@@ -40,7 +40,7 @@ function resolveHarnessInstallationState(
40
40
  return 'unknown';
41
41
  }
42
42
 
43
- return isHarnessVersionOutdated(installedVersion, latestVersion) ? 'outdated' : 'up-to-date';
43
+ return isNpmPackageVersionOutdated(installedVersion, latestVersion) ? 'outdated' : 'up-to-date';
44
44
  }
45
45
 
46
46
  // Note: [🟡] Code for CLI harness installation check [$checkHarnessInstallation](src/cli/cli-commands/common/harness/$checkHarnessInstallation.ts) should never be published outside of `@promptbook/cli`
@@ -1,5 +1,5 @@
1
1
  import { $execCommand } from '../../../../utils/execCommand/$execCommand';
2
- import { extractHarnessVersionFromOutput } from './extractHarnessVersionFromOutput';
2
+ import { extractNpmPackageVersionFromOutput } from '../npm/extractNpmPackageVersionFromOutput';
3
3
  import type { HarnessDefinition } from './HarnessDefinition';
4
4
 
5
5
  /**
@@ -23,7 +23,7 @@ export async function $resolveInstalledHarnessVersion(definition: HarnessDefinit
23
23
  isVerbose: false,
24
24
  }).catch(() => '');
25
25
 
26
- return extractHarnessVersionFromOutput(output);
26
+ return extractNpmPackageVersionFromOutput(output);
27
27
  }
28
28
 
29
29
  // Note: [🟡] Code for CLI harness version detection [$resolveInstalledHarnessVersion](src/cli/cli-commands/common/harness/$resolveInstalledHarnessVersion.ts) should never be published outside of `@promptbook/cli`
@@ -2,14 +2,14 @@ import colors from 'colors';
2
2
  import { createInterface } from 'readline';
3
3
 
4
4
  /**
5
- * Asks the user in the terminal whether the harness should be installed or updated right now.
5
+ * Asks the user in the terminal whether an npm package should be installed or updated now.
6
6
  *
7
7
  * Note: `$` is used to indicate that this function is not a pure function - it reads the answer from stdin
8
8
  *
9
9
  * @returns `true` when the user confirms, `false` when the user declines or the terminal is not interactive
10
10
  * @private internal utility of `promptbookCli`
11
11
  */
12
- export async function $askForHarnessInstallationApproval(question: string): Promise<boolean> {
12
+ export async function $askForNpmPackageInstallationApproval(question: string): Promise<boolean> {
13
13
  if (!process.stdin.isTTY) {
14
14
  // Note: In non-interactive environments like CI there is nobody who could confirm the installation
15
15
  return false;
@@ -28,4 +28,4 @@ export async function $askForHarnessInstallationApproval(question: string): Prom
28
28
  }
29
29
  }
30
30
 
31
- // Note: [🟡] Code for CLI harness installation approval [$askForHarnessInstallationApproval](src/cli/cli-commands/common/harness/$askForHarnessInstallationApproval.ts) should never be published outside of `@promptbook/cli`
31
+ // Note: [🟡] Code for CLI npm package installation approval [$askForNpmPackageInstallationApproval](src/cli/cli-commands/common/npm/$askForNpmPackageInstallationApproval.ts) should never be published outside of `@promptbook/cli`
@@ -0,0 +1,49 @@
1
+ import { $execCommand } from '../../../../utils/execCommand/$execCommand';
2
+ import { extractNpmPackageVersionFromOutput } from './extractNpmPackageVersionFromOutput';
3
+
4
+ /**
5
+ * Time limit for the whole `npm view` lookup of the newest published package version.
6
+ */
7
+ const NPM_PACKAGE_LATEST_VERSION_COMMAND_TIMEOUT_MS = 60 * 1000;
8
+
9
+ /**
10
+ * Time limit for one npm registry request, so an unreachable registry never blocks the command.
11
+ */
12
+ const NPM_REGISTRY_FETCH_TIMEOUT_MS = 20 * 1000;
13
+
14
+ /**
15
+ * Pattern matching npm's JSON-encoded package version result.
16
+ */
17
+ const NPM_VIEW_JSON_VERSION_PATTERN = /"(\d+\.\d+\.\d+(?:[-+][0-9A-Za-z.-]+)?)/u;
18
+
19
+ /**
20
+ * Reads the newest version of one npm package.
21
+ *
22
+ * Note: `$` is used to indicate that this function is not a pure function - it queries the npm registry
23
+ *
24
+ * @returns The newest published version or `null` when the registry could not be reached
25
+ * @private internal utility of `promptbookCli`
26
+ */
27
+ export async function $resolveLatestNpmPackageVersion(npmPackageName: string): Promise<string | null> {
28
+ const output = await $execCommand({
29
+ command: `npm view ${npmPackageName} version --json --loglevel=error --fetch-timeout=${NPM_REGISTRY_FETCH_TIMEOUT_MS} --fetch-retries=1`,
30
+ crashOnError: true,
31
+ timeout: NPM_PACKAGE_LATEST_VERSION_COMMAND_TIMEOUT_MS,
32
+ isVerbose: false,
33
+ }).catch(() => '');
34
+
35
+ return extractLatestNpmPackageVersionFromNpmViewOutput(output);
36
+ }
37
+
38
+ /**
39
+ * Extracts the version from npm's JSON result while tolerating warnings emitted before or after that result.
40
+ *
41
+ * @private internal utility of `$resolveLatestNpmPackageVersion`
42
+ */
43
+ function extractLatestNpmPackageVersionFromNpmViewOutput(output: string): string | null {
44
+ const jsonVersionMatch = NPM_VIEW_JSON_VERSION_PATTERN.exec(output);
45
+
46
+ return jsonVersionMatch?.[1] ?? extractNpmPackageVersionFromOutput(output, { isLastMatchPreferred: true });
47
+ }
48
+
49
+ // Note: [🟡] Code for CLI npm package registry lookup [$resolveLatestNpmPackageVersion](src/cli/cli-commands/common/npm/$resolveLatestNpmPackageVersion.ts) should never be published outside of `@promptbook/cli`
@@ -0,0 +1,25 @@
1
+ /**
2
+ * Pattern matching one `major.minor.patch` version anywhere in npm or CLI command output.
3
+ */
4
+ const NPM_PACKAGE_VERSION_PATTERN = /\b(\d+\.\d+\.\d+(?:[-+][0-9A-Za-z.-]+)?)/gu;
5
+
6
+ /**
7
+ * Extracts an npm package version from raw command output.
8
+ *
9
+ * Both npm and CLI commands may emit unrelated warnings before the version. CLI commands use the first matching token;
10
+ * npm registry commands can opt into the last matching token because npm warnings commonly precede their JSON output.
11
+ *
12
+ * @returns The parsed version or `null` when the output contains no version
13
+ * @private internal utility of `promptbookCli`
14
+ */
15
+ export function extractNpmPackageVersionFromOutput(
16
+ output: string,
17
+ { isLastMatchPreferred = false }: { readonly isLastMatchPreferred?: boolean } = {},
18
+ ): string | null {
19
+ const versionMatches = Array.from(output.matchAll(NPM_PACKAGE_VERSION_PATTERN));
20
+ const versionMatch = isLastMatchPreferred ? versionMatches[versionMatches.length - 1] : versionMatches[0];
21
+
22
+ return versionMatch?.[1] ?? null;
23
+ }
24
+
25
+ // Note: [🟡] Code for CLI npm package version parsing [extractNpmPackageVersionFromOutput](src/cli/cli-commands/common/npm/extractNpmPackageVersionFromOutput.ts) should never be published outside of `@promptbook/cli`
@@ -1,12 +1,12 @@
1
1
  /**
2
- * Compares the installed harness version with the newest version published to npm.
2
+ * Compares an installed npm package version with the newest published version.
3
3
  *
4
4
  * Only the numeric `major.minor.patch` segments are compared and pre-release suffixes are ignored,
5
- * so a harness installed from a pre-release build of the newest version is not reported as outdated.
5
+ * so a package installed from a pre-release build of the newest version is not reported as outdated.
6
6
  *
7
7
  * @private internal utility of `promptbookCli`
8
8
  */
9
- export function isHarnessVersionOutdated(installedVersion: string, latestVersion: string): boolean {
9
+ export function isNpmPackageVersionOutdated(installedVersion: string, latestVersion: string): boolean {
10
10
  const installedSegments = parseVersionSegments(installedVersion);
11
11
  const latestSegments = parseVersionSegments(latestVersion);
12
12
  const segmentCount = Math.max(installedSegments.length, latestSegments.length);
@@ -25,6 +25,8 @@ export function isHarnessVersionOutdated(installedVersion: string, latestVersion
25
25
 
26
26
  /**
27
27
  * Splits one version into its numeric segments, dropping the pre-release and build suffix.
28
+ *
29
+ * @private internal utility of `isNpmPackageVersionOutdated`
28
30
  */
29
31
  function parseVersionSegments(version: string): ReadonlyArray<number> {
30
32
  const [numericVersion = ''] = version.trim().split(/[-+]/u);
@@ -36,4 +38,4 @@ function parseVersionSegments(version: string): ReadonlyArray<number> {
36
38
  });
37
39
  }
38
40
 
39
- // Note: [🟡] Code for CLI harness version comparison [isHarnessVersionOutdated](src/cli/cli-commands/common/harness/isHarnessVersionOutdated.ts) should never be published outside of `@promptbook/cli`
41
+ // Note: [🟡] Code for CLI npm package version comparison [isNpmPackageVersionOutdated](src/cli/cli-commands/common/npm/isNpmPackageVersionOutdated.ts) should never be published outside of `@promptbook/cli`
@@ -1,5 +1,6 @@
1
1
  import { readFile, stat, writeFile } from 'fs/promises';
2
2
  import { join } from 'path';
3
+ import { spaceTrim } from 'spacetrim';
3
4
  import { escapeRegExp } from '../../../utils/chat/escapeRegExp';
4
5
 
5
6
  /**
@@ -118,7 +119,15 @@ export async function ensureProjectGitignoreFile({
118
119
  return 'unchanged';
119
120
  }
120
121
 
121
- const nextGitignoreContent = appendBlock(currentGitignoreContent || '', [blockHeader, ...missingRules].join('\n'));
122
+ const nextGitignoreContent = appendBlock(
123
+ currentGitignoreContent || '',
124
+ spaceTrim(
125
+ (block) => `
126
+ ${block(blockHeader)}
127
+ ${block(missingRules.join('\n'))}
128
+ `,
129
+ ),
130
+ );
122
131
  await writeFile(gitignorePath, nextGitignoreContent, 'utf-8');
123
132
  return currentGitignoreContent === undefined ? 'created' : 'updated';
124
133
  }
@@ -0,0 +1,73 @@
1
+ import { $resolveLatestNpmPackageVersion } from '../npm/$resolveLatestNpmPackageVersion';
2
+ import { isNpmPackageVersionOutdated } from '../npm/isNpmPackageVersionOutdated';
3
+ import type { PromptbookCliInstallation } from './PromptbookCliInstallation';
4
+ import type {
5
+ PromptbookCliInstallationState,
6
+ PromptbookCliInstallationStatus,
7
+ } from './PromptbookCliInstallationStatus';
8
+ import { $resolvePromptbookCliInstallations } from './$resolvePromptbookCliInstallations';
9
+
10
+ /**
11
+ * Checks every local and global Promptbook CLI installation against the newest npm version.
12
+ *
13
+ * Note: `$` is used to indicate that this function is not a pure function - it reads installed packages and queries npm
14
+ *
15
+ * @private internal utility of `promptbookCli`
16
+ */
17
+ export async function $checkPromptbookCliInstallations(): Promise<ReadonlyArray<PromptbookCliInstallationStatus>> {
18
+ const installations = await $resolvePromptbookCliInstallations();
19
+
20
+ if (installations.length === 0) {
21
+ return [];
22
+ }
23
+
24
+ const latestVersionsByNpmPackageName = await $resolveLatestVersionsByNpmPackageName(installations);
25
+
26
+ return installations.map((installation) => {
27
+ const latestVersion = latestVersionsByNpmPackageName.get(installation.npmPackageName) ?? null;
28
+
29
+ return {
30
+ installation,
31
+ installationState: resolvePromptbookCliInstallationState(installation.installedVersion, latestVersion),
32
+ latestVersion,
33
+ };
34
+ });
35
+ }
36
+
37
+ /**
38
+ * Resolves each package's newest version once, even when it is installed locally and globally.
39
+ *
40
+ * @private internal utility of `$checkPromptbookCliInstallations`
41
+ */
42
+ async function $resolveLatestVersionsByNpmPackageName(
43
+ installations: ReadonlyArray<PromptbookCliInstallation>,
44
+ ): Promise<ReadonlyMap<PromptbookCliInstallation['npmPackageName'], string | null>> {
45
+ const npmPackageNames = Array.from(new Set(installations.map(({ npmPackageName }) => npmPackageName)));
46
+ const latestVersionEntries = await Promise.all(
47
+ npmPackageNames.map(async (npmPackageName) => {
48
+ const latestVersion = await $resolveLatestNpmPackageVersion(npmPackageName);
49
+
50
+ return [npmPackageName, latestVersion] as const;
51
+ }),
52
+ );
53
+
54
+ return new Map(latestVersionEntries);
55
+ }
56
+
57
+ /**
58
+ * Derives the update state of one installed Promptbook CLI package.
59
+ *
60
+ * @private internal utility of `$checkPromptbookCliInstallations`
61
+ */
62
+ function resolvePromptbookCliInstallationState(
63
+ installedVersion: string,
64
+ latestVersion: string | null,
65
+ ): PromptbookCliInstallationState {
66
+ if (latestVersion === null) {
67
+ return 'unknown';
68
+ }
69
+
70
+ return isNpmPackageVersionOutdated(installedVersion, latestVersion) ? 'outdated' : 'up-to-date';
71
+ }
72
+
73
+ // Note: [🟡] Code for Promptbook CLI installation check [$checkPromptbookCliInstallations](src/cli/cli-commands/common/promptbook-cli/$checkPromptbookCliInstallations.ts) should never be published outside of `@promptbook/cli`