@promptbook/remote-server 0.114.0-4 → 0.114.0-41

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 (326) hide show
  1. package/README.md +9 -9
  2. package/esm/index.es.js +543 -115
  3. package/esm/index.es.js.map +1 -1
  4. package/esm/src/_packages/components.index.d.ts +4 -0
  5. package/esm/src/_packages/types.index.d.ts +4 -0
  6. package/esm/src/avatars/renderAvatarVisualTerminalText.d.ts +80 -0
  7. package/esm/src/avatars/types/AvatarVisualDefinition.d.ts +54 -0
  8. package/esm/src/book-2.0/agent-source/AgentReferenceResolutionIssue.d.ts +45 -0
  9. package/esm/src/book-2.0/agent-source/AgentSourceParseResult.d.ts +5 -0
  10. package/esm/src/book-2.0/agent-source/ParsedUnknownCommitment.d.ts +26 -0
  11. package/esm/src/book-2.0/agent-source/deduplicateSystemMessage.d.ts +14 -0
  12. package/esm/src/book-2.0/agent-source/explicitFromCommitment.d.ts +62 -0
  13. package/esm/src/book-2.0/agent-source/extractAgentReferenceTokens.d.ts +32 -0
  14. package/esm/src/book-2.0/agent-source/getBookCommitmentLineType.d.ts +19 -0
  15. package/esm/src/book-2.0/agent-source/parseAgentSourceWithCommitments.unknown.test.d.ts +1 -0
  16. package/esm/src/book-2.0/agent-source/resolveInheritedAgentSource.d.ts +73 -0
  17. package/esm/src/book-2.0/book-language-documentation/getSafeCodeBlock.d.ts +1 -1
  18. package/esm/src/book-3.0/AgentMessageRunReport.d.ts +46 -0
  19. package/esm/src/book-3.0/AgentPlannedMessagesSidecar.d.ts +127 -0
  20. package/esm/src/book-3.0/AgentPlannedMessagesSidecar.test.d.ts +1 -0
  21. package/esm/src/book-3.0/AgentTeamConversationWorkspace.d.ts +85 -0
  22. package/esm/src/book-3.0/cliAgentEnv.d.ts +3 -3
  23. package/esm/src/book-3.0/createAgentMessageSidecarBaseName.d.ts +13 -0
  24. package/esm/src/book-3.0/describeAgentPlannedMessageSchedule.d.ts +31 -0
  25. package/esm/src/book-components/BookEditor/createDeprecatedCommitmentDiagnostics.browser.d.ts +1 -9
  26. package/esm/src/book-components/BookEditor/createDuplicateFromCommitmentDiagnostics.d.ts +28 -0
  27. package/esm/src/book-components/BookEditor/createDuplicateFromCommitmentDiagnostics.test.d.ts +1 -0
  28. package/esm/src/book-components/BookEditor/createUnknownCommitmentDiagnostics.d.ts +28 -0
  29. package/esm/src/book-components/BookEditor/createUnknownCommitmentDiagnostics.test.d.ts +1 -0
  30. package/esm/src/book-components/Chat/Chat/ChatProps.d.ts +3 -2
  31. package/esm/src/book-components/Chat/Chat/renderAgentProjectDiff.d.ts +13 -0
  32. package/esm/src/book-components/Chat/Chat/renderAgentProjectToolCallDetails.d.ts +16 -0
  33. package/esm/src/book-components/Chat/MockedChat/MockedChat.test.d.ts +2 -0
  34. package/esm/src/book-components/Chat/utils/agentProjectToolCall.d.ts +85 -0
  35. package/esm/src/book-components/Chat/utils/agentProjectToolCall.test.d.ts +1 -0
  36. package/esm/src/book-components/Chat/utils/externalSourceToolCall.d.ts +38 -0
  37. package/esm/src/book-components/Chat/utils/renderMarkdown.d.ts +68 -3
  38. package/esm/src/book-components/Chat/utils/timeoutToolCallPresentation.d.ts +30 -0
  39. package/esm/src/cli/$initializePromptbookCliProgram.d.ts +8 -0
  40. package/esm/src/cli/cli-commands/coder/$ensureCoderHarnessGitignoreRules.d.ts +10 -0
  41. package/esm/src/cli/cli-commands/coder/$ensureCoderHarnessGitignoreRules.test.d.ts +1 -0
  42. package/esm/src/cli/cli-commands/coder/GitChangesMode.d.ts +28 -0
  43. package/esm/src/cli/cli-commands/coder/agentCliOptions.d.ts +21 -0
  44. package/esm/src/cli/cli-commands/coder/boilerplateCount.d.ts +1 -1
  45. package/esm/src/cli/cli-commands/coder/boilerplateTemplates.d.ts +8 -21
  46. package/esm/src/cli/cli-commands/coder/coderReferencedArtifacts.d.ts +33 -0
  47. package/esm/src/cli/cli-commands/coder/ensureCoderGitignoreFile.d.ts +14 -1
  48. package/esm/src/cli/cli-commands/coder/ensureCoderPackageJsonFile.d.ts +4 -2
  49. package/esm/src/cli/cli-commands/coder/ensureCoderVscodeSettingsFile.d.ts +2 -0
  50. package/esm/src/cli/cli-commands/coder/ensureDirectory.d.ts +6 -0
  51. package/esm/src/cli/cli-commands/coder/generate-boilerplates.d.ts +1 -1
  52. package/esm/src/cli/cli-commands/coder/getDefaultCoderPackageJsonScripts.d.ts +6 -0
  53. package/esm/src/cli/cli-commands/coder/init.test.d.ts +1 -0
  54. package/esm/src/cli/cli-commands/coder/initializeCoderProjectConfiguration.d.ts +8 -5
  55. package/esm/src/cli/cli-commands/coder/list.d.ts +10 -0
  56. package/esm/src/cli/cli-commands/coder/list.test.d.ts +1 -0
  57. package/esm/src/cli/cli-commands/coder/mergeStringRecordJsonFile.d.ts +19 -1
  58. package/esm/src/cli/cli-commands/coder/printCoderRunFailure.d.ts +6 -0
  59. package/esm/src/cli/cli-commands/coder/server.test.d.ts +1 -0
  60. package/esm/src/cli/cli-commands/coder/verify.d.ts +1 -1
  61. package/esm/src/cli/cli-commands/coder/waitOptions.d.ts +12 -0
  62. package/esm/src/cli/cli-commands/coder.d.ts +1 -0
  63. package/esm/src/cli/cli-commands/common/$askForConfirmation.d.ts +11 -0
  64. package/esm/src/cli/cli-commands/common/$askForConfirmation.test.d.ts +1 -0
  65. package/esm/src/cli/cli-commands/common/LocalAgentBookCollection.d.ts +46 -0
  66. package/esm/src/cli/cli-commands/common/createLocalAgentReferenceResolver.d.ts +8 -0
  67. package/esm/src/cli/cli-commands/common/disk-space/$assertSufficientFreeDiskSpace.d.ts +12 -0
  68. package/esm/src/cli/cli-commands/common/disk-space/$assertSufficientFreeDiskSpace.test.d.ts +1 -0
  69. package/esm/src/cli/cli-commands/common/disk-space/$readFreeDiskSpaceStatus.d.ts +11 -0
  70. package/esm/src/cli/cli-commands/common/disk-space/$readFreeDiskSpaceStatus.test.d.ts +1 -0
  71. package/esm/src/cli/cli-commands/common/disk-space/FreeDiskSpaceStatus.d.ts +33 -0
  72. package/esm/src/cli/cli-commands/common/disk-space/formatFreeDiskSpaceBytes.d.ts +6 -0
  73. package/esm/src/cli/cli-commands/common/disk-space/formatFreeDiskSpaceBytes.test.d.ts +1 -0
  74. package/esm/src/cli/cli-commands/common/disk-space/formatLowFreeDiskSpaceWarning.d.ts +10 -0
  75. package/esm/src/cli/cli-commands/common/disk-space/freeDiskSpaceConstants.d.ts +28 -0
  76. package/esm/src/cli/cli-commands/common/disk-space/resolveFreeDiskSpaceLevel.d.ts +7 -0
  77. package/esm/src/cli/cli-commands/common/disk-space/resolveFreeDiskSpaceLevel.test.d.ts +1 -0
  78. package/esm/src/cli/cli-commands/common/ensureAdamAgentBook.d.ts +12 -0
  79. package/esm/src/cli/cli-commands/common/harness/$applyHarnessInstallationStatus.d.ts +3 -2
  80. package/esm/src/cli/cli-commands/common/harness/$checkHarnessInstallation.d.ts +3 -3
  81. package/esm/src/cli/cli-commands/common/harness/$checkHarnessInstallation.test.d.ts +1 -0
  82. package/esm/src/cli/cli-commands/common/harness/$ensureHarnessInstallations.d.ts +4 -3
  83. package/esm/src/cli/cli-commands/common/harness/$resolveHarnessCommandPath.d.ts +14 -0
  84. package/esm/src/cli/cli-commands/common/harness/$resolveHarnessInstallationOrigin.d.ts +10 -0
  85. package/esm/src/cli/cli-commands/common/harness/$runHarnessInstallationCommand.d.ts +43 -0
  86. package/esm/src/cli/cli-commands/common/harness/HARNESS_DEFAULT_MODELS.d.ts +25 -0
  87. package/esm/src/cli/cli-commands/common/harness/HarnessDefinition.d.ts +62 -0
  88. package/esm/src/cli/cli-commands/common/harness/HarnessInstallationOrigin.d.ts +36 -0
  89. package/esm/src/cli/cli-commands/common/harness/HarnessInstallationStatus.d.ts +8 -2
  90. package/esm/src/cli/cli-commands/common/harness/HarnessUpdatePlan.d.ts +23 -0
  91. package/esm/src/cli/cli-commands/common/harness/buildHarnessInstallCommand.d.ts +4 -1
  92. package/esm/src/cli/cli-commands/common/harness/formatHarnessManualUpdateInstruction.d.ts +8 -0
  93. package/esm/src/cli/cli-commands/common/harness/formatHarnessManualUpdateInstruction.test.d.ts +1 -0
  94. package/esm/src/cli/cli-commands/common/harness/resolveHarnessInstallationMethodFromPaths.d.ts +31 -0
  95. package/esm/src/cli/cli-commands/common/harness/resolveHarnessInstallationMethodFromPaths.test.d.ts +1 -0
  96. package/esm/src/cli/cli-commands/common/harness/resolveHarnessUpdatePlan.d.ts +12 -0
  97. package/esm/src/cli/cli-commands/common/harness/resolveHarnessUpdatePlan.test.d.ts +1 -0
  98. package/esm/src/cli/cli-commands/common/npm/$askForNpmPackageInstallationApproval.d.ts +11 -0
  99. package/{umd/src/cli/cli-commands/common/harness/$resolveLatestHarnessVersion.d.ts → esm/src/cli/cli-commands/common/npm/$resolveLatestNpmPackageVersion.d.ts} +2 -3
  100. package/esm/src/cli/cli-commands/common/npm/$resolveLatestNpmPackageVersion.test.d.ts +1 -0
  101. package/esm/src/cli/cli-commands/common/npm/$resolveNpmGlobalPrefixPath.d.ts +9 -0
  102. package/esm/src/cli/cli-commands/common/npm/buildNpmPackageInstallCommand.d.ts +12 -0
  103. package/esm/src/cli/cli-commands/common/npm/buildNpmPackageInstallCommand.test.d.ts +1 -0
  104. package/esm/src/cli/cli-commands/common/npm/extractNpmPackageVersionFromOutput.d.ts +12 -0
  105. package/esm/src/cli/cli-commands/common/npm/extractNpmPackageVersionFromOutput.test.d.ts +1 -0
  106. package/esm/src/cli/cli-commands/common/npm/isNpmPackageVersionOutdated.d.ts +12 -0
  107. package/esm/src/cli/cli-commands/common/npm/isNpmPackageVersionOutdated.test.d.ts +1 -0
  108. package/esm/src/cli/cli-commands/common/projectInitialization.d.ts +6 -0
  109. package/esm/src/cli/cli-commands/common/promptPriorityCliOptions.d.ts +7 -0
  110. package/esm/src/cli/cli-commands/common/promptRunnerCliOptions.d.ts +17 -4
  111. package/esm/src/cli/cli-commands/common/promptbook-cli/$checkPromptbookCliInstallations.d.ts +9 -0
  112. package/esm/src/cli/cli-commands/common/promptbook-cli/$checkPromptbookCliInstallations.test.d.ts +1 -0
  113. package/esm/src/cli/cli-commands/common/promptbook-cli/$ensurePromptbookCliInstallations.d.ts +15 -0
  114. package/esm/src/cli/cli-commands/common/promptbook-cli/$ensurePromptbookCliInstallations.test.d.ts +1 -0
  115. package/esm/src/cli/cli-commands/common/promptbook-cli/$resolvePromptbookCliInstallations.d.ts +12 -0
  116. package/esm/src/cli/cli-commands/common/promptbook-cli/$resolvePromptbookCliInstallations.test.d.ts +1 -0
  117. package/esm/src/cli/cli-commands/common/promptbook-cli/$updatePromptbookCliInstallation.d.ts +10 -0
  118. package/esm/src/cli/cli-commands/common/promptbook-cli/$updatePromptbookCliInstallation.test.d.ts +1 -0
  119. package/esm/src/cli/cli-commands/common/promptbook-cli/PromptbookCliInstallation.d.ts +66 -0
  120. package/esm/src/cli/cli-commands/common/promptbook-cli/PromptbookCliInstallationStatus.d.ts +26 -0
  121. package/esm/src/cli/cli-commands/common/promptbook-cli/buildPromptbookCliInstallCommand.d.ts +7 -0
  122. package/esm/src/cli/cli-commands/common/promptbook-cli/formatPromptbookCliInstallationWarning.d.ts +7 -0
  123. package/esm/src/cli/cli-commands/common/questionsCliOptions.d.ts +45 -0
  124. package/esm/src/cli/cli-commands/common/questionsCliOptions.test.d.ts +1 -0
  125. package/esm/src/cli/cli-commands/common/resolveBundledAgentBookPath.d.ts +6 -0
  126. package/esm/src/cli/cli-commands/common/resolveLocalAgentSource.d.ts +19 -0
  127. package/esm/src/cli/common/$deprecateCliCommand.d.ts +3 -0
  128. package/esm/src/cli/common/$hideCliCommandFromHelp.d.ts +11 -0
  129. package/esm/src/cli/common/$hideCliCommandFromHelp.test.d.ts +1 -0
  130. package/esm/src/cli/common/$requireCliSubcommand.d.ts +18 -0
  131. package/esm/src/cli/common/$requireCliSubcommand.test.d.ts +1 -0
  132. package/esm/src/collection/agent-collection/constructors/agent-collection-in-supabase/AgentCollectionInSupabase.d.ts +15 -0
  133. package/esm/src/commitments/WRITING_RULES/WRITING_RULES.d.ts +14 -7
  134. package/esm/src/commitments/index.d.ts +1 -1
  135. package/esm/src/executables/platforms/locateAppOnWindows.d.ts +1 -1
  136. package/esm/src/executables/platforms/locateAppOnWindows.test.d.ts +1 -0
  137. package/esm/src/llm-providers/vercel/VercelExecutionToolsOptions.d.ts +5 -2
  138. package/esm/src/utils/agent-message-runtime/AgentMessageProjectChange.d.ts +76 -0
  139. package/esm/src/utils/agent-message-runtime/AgentMessageTouchedExternalSource.d.ts +45 -0
  140. package/esm/src/utils/agent-message-runtime/parseAgentMessageRuntimeLogEvents.d.ts +62 -0
  141. package/esm/src/utils/agent-message-runtime/resolveAgentMessageRuntimeActivity.d.ts +3 -3
  142. package/esm/src/utils/agent-message-runtime/resolveAgentMessageTouchedExternalSources.d.ts +18 -0
  143. package/esm/src/utils/agent-message-runtime/resolveAgentMessageTouchedExternalSources.test.d.ts +1 -0
  144. package/esm/src/utils/agent-message-runtime/resolveAgentMessageTouchedProjectNames.d.ts +19 -0
  145. package/esm/src/utils/agent-message-runtime/resolveAgentMessageTouchedProjectNames.test.d.ts +1 -0
  146. package/esm/src/utils/agents/terminalAgentAvatarVisual.d.ts +5 -2
  147. package/esm/src/utils/ascii-art/convertImageDataToAsciiArt.d.ts +6 -0
  148. package/esm/src/utils/ascii-art/createAnsiColorCode.d.ts +46 -0
  149. package/esm/src/utils/files/findFilesByGlob.d.ts +28 -0
  150. package/esm/src/utils/misc/debounce.d.ts +4 -2
  151. package/esm/src/utils/misc/debounce.test.d.ts +1 -0
  152. package/esm/src/utils/misc/emojis.d.ts +3 -2
  153. package/esm/src/utils/random/$generateBookBoilerplate.test.d.ts +1 -0
  154. package/esm/src/version.d.ts +1 -1
  155. package/package.json +4 -8
  156. package/umd/index.umd.js +541 -113
  157. package/umd/index.umd.js.map +1 -1
  158. package/umd/src/_packages/components.index.d.ts +4 -0
  159. package/umd/src/_packages/types.index.d.ts +4 -0
  160. package/umd/src/avatars/renderAvatarVisualTerminalText.d.ts +80 -0
  161. package/umd/src/avatars/renderAvatarVisualTerminalText.test.d.ts +1 -0
  162. package/umd/src/avatars/types/AvatarVisualDefinition.d.ts +54 -0
  163. package/umd/src/book-2.0/agent-source/AgentReferenceResolutionIssue.d.ts +45 -0
  164. package/umd/src/book-2.0/agent-source/AgentSourceParseResult.d.ts +5 -0
  165. package/umd/src/book-2.0/agent-source/ParsedUnknownCommitment.d.ts +26 -0
  166. package/umd/src/book-2.0/agent-source/createAgentModelRequirements.deduplication.test.d.ts +1 -0
  167. package/umd/src/book-2.0/agent-source/createAgentModelRequirementsWithCommitments.unknown.test.d.ts +1 -0
  168. package/umd/src/book-2.0/agent-source/deduplicateSystemMessage.d.ts +14 -0
  169. package/umd/src/book-2.0/agent-source/deduplicateSystemMessage.test.d.ts +1 -0
  170. package/umd/src/book-2.0/agent-source/explicitFromCommitment.d.ts +62 -0
  171. package/umd/src/book-2.0/agent-source/extractAgentReferenceTokens.d.ts +32 -0
  172. package/umd/src/book-2.0/agent-source/getBookCommitmentLineType.d.ts +19 -0
  173. package/umd/src/book-2.0/agent-source/parseAgentSourceWithCommitments.unknown.test.d.ts +1 -0
  174. package/umd/src/book-2.0/agent-source/resolveInheritedAgentSource.d.ts +73 -0
  175. package/umd/src/book-2.0/book-language-documentation/getSafeCodeBlock.d.ts +1 -1
  176. package/umd/src/book-3.0/AgentMessageRunReport.d.ts +46 -0
  177. package/umd/src/book-3.0/AgentPlannedMessagesSidecar.d.ts +127 -0
  178. package/umd/src/book-3.0/AgentPlannedMessagesSidecar.test.d.ts +1 -0
  179. package/umd/src/book-3.0/AgentTeamConversationWorkspace.d.ts +85 -0
  180. package/umd/src/book-3.0/cliAgentEnv.d.ts +3 -3
  181. package/umd/src/book-3.0/createAgentMessageSidecarBaseName.d.ts +13 -0
  182. package/umd/src/book-3.0/describeAgentPlannedMessageSchedule.d.ts +31 -0
  183. package/umd/src/book-components/BookEditor/createDeprecatedCommitmentDiagnostics.browser.d.ts +1 -9
  184. package/umd/src/book-components/BookEditor/createDuplicateFromCommitmentDiagnostics.d.ts +28 -0
  185. package/umd/src/book-components/BookEditor/createDuplicateFromCommitmentDiagnostics.test.d.ts +1 -0
  186. package/umd/src/book-components/BookEditor/createUnknownCommitmentDiagnostics.d.ts +28 -0
  187. package/umd/src/book-components/BookEditor/createUnknownCommitmentDiagnostics.test.d.ts +1 -0
  188. package/umd/src/book-components/Chat/Chat/ChatProps.d.ts +3 -2
  189. package/umd/src/book-components/Chat/Chat/renderAgentProjectDiff.d.ts +13 -0
  190. package/umd/src/book-components/Chat/Chat/renderAgentProjectToolCallDetails.d.ts +16 -0
  191. package/umd/src/book-components/Chat/MockedChat/MockedChat.test.d.ts +2 -0
  192. package/umd/src/book-components/Chat/utils/agentProjectToolCall.d.ts +85 -0
  193. package/umd/src/book-components/Chat/utils/agentProjectToolCall.test.d.ts +1 -0
  194. package/umd/src/book-components/Chat/utils/externalSourceToolCall.d.ts +38 -0
  195. package/umd/src/book-components/Chat/utils/renderMarkdown.d.ts +68 -3
  196. package/umd/src/book-components/Chat/utils/timeoutToolCallPresentation.d.ts +30 -0
  197. package/umd/src/cli/$initializePromptbookCliProgram.d.ts +8 -0
  198. package/umd/src/cli/cli-commands/coder/$ensureCoderHarnessGitignoreRules.d.ts +10 -0
  199. package/umd/src/cli/cli-commands/coder/$ensureCoderHarnessGitignoreRules.test.d.ts +1 -0
  200. package/umd/src/cli/cli-commands/coder/GitChangesMode.d.ts +28 -0
  201. package/umd/src/cli/cli-commands/coder/agentCliOptions.d.ts +21 -0
  202. package/umd/src/cli/cli-commands/coder/boilerplateCount.d.ts +1 -1
  203. package/umd/src/cli/cli-commands/coder/boilerplateTemplates.d.ts +8 -21
  204. package/umd/src/cli/cli-commands/coder/coderReferencedArtifacts.d.ts +33 -0
  205. package/umd/src/cli/cli-commands/coder/ensureCoderGitignoreFile.d.ts +14 -1
  206. package/umd/src/cli/cli-commands/coder/ensureCoderPackageJsonFile.d.ts +4 -2
  207. package/umd/src/cli/cli-commands/coder/ensureCoderVscodeSettingsFile.d.ts +2 -0
  208. package/umd/src/cli/cli-commands/coder/ensureDirectory.d.ts +6 -0
  209. package/umd/src/cli/cli-commands/coder/generate-boilerplates.d.ts +1 -1
  210. package/umd/src/cli/cli-commands/coder/getDefaultCoderPackageJsonScripts.d.ts +6 -0
  211. package/umd/src/cli/cli-commands/coder/init.test.d.ts +1 -0
  212. package/umd/src/cli/cli-commands/coder/initializeCoderProjectConfiguration.d.ts +8 -5
  213. package/umd/src/cli/cli-commands/coder/list.d.ts +10 -0
  214. package/umd/src/cli/cli-commands/coder/list.test.d.ts +1 -0
  215. package/umd/src/cli/cli-commands/coder/mergeStringRecordJsonFile.d.ts +19 -1
  216. package/umd/src/cli/cli-commands/coder/printCoderRunFailure.d.ts +6 -0
  217. package/umd/src/cli/cli-commands/coder/server.test.d.ts +1 -0
  218. package/umd/src/cli/cli-commands/coder/verify.d.ts +1 -1
  219. package/umd/src/cli/cli-commands/coder/waitOptions.d.ts +12 -0
  220. package/umd/src/cli/cli-commands/coder.d.ts +1 -0
  221. package/umd/src/cli/cli-commands/common/$askForConfirmation.d.ts +11 -0
  222. package/umd/src/cli/cli-commands/common/$askForConfirmation.test.d.ts +1 -0
  223. package/umd/src/cli/cli-commands/common/LocalAgentBookCollection.d.ts +46 -0
  224. package/umd/src/cli/cli-commands/common/createLocalAgentReferenceResolver.d.ts +8 -0
  225. package/umd/src/cli/cli-commands/common/disk-space/$assertSufficientFreeDiskSpace.d.ts +12 -0
  226. package/umd/src/cli/cli-commands/common/disk-space/$assertSufficientFreeDiskSpace.test.d.ts +1 -0
  227. package/umd/src/cli/cli-commands/common/disk-space/$readFreeDiskSpaceStatus.d.ts +11 -0
  228. package/umd/src/cli/cli-commands/common/disk-space/$readFreeDiskSpaceStatus.test.d.ts +1 -0
  229. package/umd/src/cli/cli-commands/common/disk-space/FreeDiskSpaceStatus.d.ts +33 -0
  230. package/umd/src/cli/cli-commands/common/disk-space/formatFreeDiskSpaceBytes.d.ts +6 -0
  231. package/umd/src/cli/cli-commands/common/disk-space/formatFreeDiskSpaceBytes.test.d.ts +1 -0
  232. package/umd/src/cli/cli-commands/common/disk-space/formatLowFreeDiskSpaceWarning.d.ts +10 -0
  233. package/umd/src/cli/cli-commands/common/disk-space/freeDiskSpaceConstants.d.ts +28 -0
  234. package/umd/src/cli/cli-commands/common/disk-space/resolveFreeDiskSpaceLevel.d.ts +7 -0
  235. package/umd/src/cli/cli-commands/common/disk-space/resolveFreeDiskSpaceLevel.test.d.ts +1 -0
  236. package/umd/src/cli/cli-commands/common/ensureAdamAgentBook.d.ts +12 -0
  237. package/umd/src/cli/cli-commands/common/harness/$applyHarnessInstallationStatus.d.ts +3 -2
  238. package/umd/src/cli/cli-commands/common/harness/$checkHarnessInstallation.d.ts +3 -3
  239. package/umd/src/cli/cli-commands/common/harness/$checkHarnessInstallation.test.d.ts +1 -0
  240. package/umd/src/cli/cli-commands/common/harness/$ensureHarnessInstallations.d.ts +4 -3
  241. package/umd/src/cli/cli-commands/common/harness/$resolveHarnessCommandPath.d.ts +14 -0
  242. package/umd/src/cli/cli-commands/common/harness/$resolveHarnessInstallationOrigin.d.ts +10 -0
  243. package/umd/src/cli/cli-commands/common/harness/$runHarnessInstallationCommand.d.ts +43 -0
  244. package/umd/src/cli/cli-commands/common/harness/HARNESS_DEFAULT_MODELS.d.ts +25 -0
  245. package/umd/src/cli/cli-commands/common/harness/HarnessDefinition.d.ts +62 -0
  246. package/umd/src/cli/cli-commands/common/harness/HarnessInstallationOrigin.d.ts +36 -0
  247. package/umd/src/cli/cli-commands/common/harness/HarnessInstallationStatus.d.ts +8 -2
  248. package/umd/src/cli/cli-commands/common/harness/HarnessUpdatePlan.d.ts +23 -0
  249. package/umd/src/cli/cli-commands/common/harness/buildHarnessInstallCommand.d.ts +4 -1
  250. package/umd/src/cli/cli-commands/common/harness/formatHarnessManualUpdateInstruction.d.ts +8 -0
  251. package/umd/src/cli/cli-commands/common/harness/formatHarnessManualUpdateInstruction.test.d.ts +1 -0
  252. package/umd/src/cli/cli-commands/common/harness/resolveHarnessInstallationMethodFromPaths.d.ts +31 -0
  253. package/umd/src/cli/cli-commands/common/harness/resolveHarnessInstallationMethodFromPaths.test.d.ts +1 -0
  254. package/umd/src/cli/cli-commands/common/harness/resolveHarnessUpdatePlan.d.ts +12 -0
  255. package/umd/src/cli/cli-commands/common/harness/resolveHarnessUpdatePlan.test.d.ts +1 -0
  256. package/umd/src/cli/cli-commands/common/npm/$askForNpmPackageInstallationApproval.d.ts +11 -0
  257. package/{esm/src/cli/cli-commands/common/harness/$resolveLatestHarnessVersion.d.ts → umd/src/cli/cli-commands/common/npm/$resolveLatestNpmPackageVersion.d.ts} +2 -3
  258. package/umd/src/cli/cli-commands/common/npm/$resolveLatestNpmPackageVersion.test.d.ts +1 -0
  259. package/umd/src/cli/cli-commands/common/npm/$resolveNpmGlobalPrefixPath.d.ts +9 -0
  260. package/umd/src/cli/cli-commands/common/npm/buildNpmPackageInstallCommand.d.ts +12 -0
  261. package/umd/src/cli/cli-commands/common/npm/buildNpmPackageInstallCommand.test.d.ts +1 -0
  262. package/umd/src/cli/cli-commands/common/npm/extractNpmPackageVersionFromOutput.d.ts +12 -0
  263. package/umd/src/cli/cli-commands/common/npm/extractNpmPackageVersionFromOutput.test.d.ts +1 -0
  264. package/umd/src/cli/cli-commands/common/npm/isNpmPackageVersionOutdated.d.ts +12 -0
  265. package/umd/src/cli/cli-commands/common/npm/isNpmPackageVersionOutdated.test.d.ts +1 -0
  266. package/umd/src/cli/cli-commands/common/projectInitialization.d.ts +6 -0
  267. package/umd/src/cli/cli-commands/common/promptPriorityCliOptions.d.ts +7 -0
  268. package/umd/src/cli/cli-commands/common/promptRunnerCliOptions.d.ts +17 -4
  269. package/umd/src/cli/cli-commands/common/promptbook-cli/$checkPromptbookCliInstallations.d.ts +9 -0
  270. package/umd/src/cli/cli-commands/common/promptbook-cli/$checkPromptbookCliInstallations.test.d.ts +1 -0
  271. package/umd/src/cli/cli-commands/common/promptbook-cli/$ensurePromptbookCliInstallations.d.ts +15 -0
  272. package/umd/src/cli/cli-commands/common/promptbook-cli/$ensurePromptbookCliInstallations.test.d.ts +1 -0
  273. package/umd/src/cli/cli-commands/common/promptbook-cli/$resolvePromptbookCliInstallations.d.ts +12 -0
  274. package/umd/src/cli/cli-commands/common/promptbook-cli/$resolvePromptbookCliInstallations.test.d.ts +1 -0
  275. package/umd/src/cli/cli-commands/common/promptbook-cli/$updatePromptbookCliInstallation.d.ts +10 -0
  276. package/umd/src/cli/cli-commands/common/promptbook-cli/$updatePromptbookCliInstallation.test.d.ts +1 -0
  277. package/umd/src/cli/cli-commands/common/promptbook-cli/PromptbookCliInstallation.d.ts +66 -0
  278. package/umd/src/cli/cli-commands/common/promptbook-cli/PromptbookCliInstallationStatus.d.ts +26 -0
  279. package/umd/src/cli/cli-commands/common/promptbook-cli/buildPromptbookCliInstallCommand.d.ts +7 -0
  280. package/umd/src/cli/cli-commands/common/promptbook-cli/formatPromptbookCliInstallationWarning.d.ts +7 -0
  281. package/umd/src/cli/cli-commands/common/questionsCliOptions.d.ts +45 -0
  282. package/umd/src/cli/cli-commands/common/questionsCliOptions.test.d.ts +1 -0
  283. package/umd/src/cli/cli-commands/common/resolveBundledAgentBookPath.d.ts +6 -0
  284. package/umd/src/cli/cli-commands/common/resolveLocalAgentSource.d.ts +19 -0
  285. package/umd/src/cli/common/$deprecateCliCommand.d.ts +3 -0
  286. package/umd/src/cli/common/$hideCliCommandFromHelp.d.ts +11 -0
  287. package/umd/src/cli/common/$hideCliCommandFromHelp.test.d.ts +1 -0
  288. package/umd/src/cli/common/$requireCliSubcommand.d.ts +18 -0
  289. package/umd/src/cli/common/$requireCliSubcommand.test.d.ts +1 -0
  290. package/umd/src/collection/agent-collection/constructors/agent-collection-in-supabase/AgentCollectionInSupabase.d.ts +15 -0
  291. package/umd/src/commitments/WRITING_RULES/WRITING_RULES.d.ts +14 -7
  292. package/umd/src/commitments/index.d.ts +1 -1
  293. package/umd/src/executables/platforms/locateAppOnWindows.d.ts +1 -1
  294. package/umd/src/executables/platforms/locateAppOnWindows.test.d.ts +1 -0
  295. package/umd/src/llm-providers/vercel/VercelExecutionToolsOptions.d.ts +5 -2
  296. package/umd/src/utils/agent-message-runtime/AgentMessageProjectChange.d.ts +76 -0
  297. package/umd/src/utils/agent-message-runtime/AgentMessageTouchedExternalSource.d.ts +45 -0
  298. package/umd/src/utils/agent-message-runtime/parseAgentMessageRuntimeLogEvents.d.ts +62 -0
  299. package/umd/src/utils/agent-message-runtime/resolveAgentMessageRuntimeActivity.d.ts +3 -3
  300. package/umd/src/utils/agent-message-runtime/resolveAgentMessageTouchedExternalSources.d.ts +18 -0
  301. package/umd/src/utils/agent-message-runtime/resolveAgentMessageTouchedExternalSources.test.d.ts +1 -0
  302. package/umd/src/utils/agent-message-runtime/resolveAgentMessageTouchedProjectNames.d.ts +19 -0
  303. package/umd/src/utils/agent-message-runtime/resolveAgentMessageTouchedProjectNames.test.d.ts +1 -0
  304. package/umd/src/utils/agents/terminalAgentAvatarVisual.d.ts +5 -2
  305. package/umd/src/utils/ascii-art/convertImageDataToAsciiArt.d.ts +6 -0
  306. package/umd/src/utils/ascii-art/createAnsiColorCode.d.ts +46 -0
  307. package/umd/src/utils/files/findFilesByGlob.d.ts +28 -0
  308. package/umd/src/utils/misc/debounce.d.ts +4 -2
  309. package/umd/src/utils/misc/debounce.test.d.ts +1 -0
  310. package/umd/src/utils/misc/emojis.d.ts +3 -2
  311. package/umd/src/utils/random/$generateBookBoilerplate.test.d.ts +1 -0
  312. package/umd/src/version.d.ts +1 -1
  313. package/esm/src/cli/cli-commands/coder/agentCodingFile.d.ts +0 -13
  314. package/esm/src/cli/cli-commands/common/harness/$askForHarnessInstallationApproval.d.ts +0 -9
  315. package/esm/src/cli/cli-commands/common/harness/$installHarness.d.ts +0 -13
  316. package/esm/src/cli/cli-commands/common/harness/extractHarnessVersionFromOutput.d.ts +0 -11
  317. package/esm/src/cli/cli-commands/common/harness/isHarnessVersionOutdated.d.ts +0 -9
  318. package/umd/src/cli/cli-commands/coder/agentCodingFile.d.ts +0 -13
  319. package/umd/src/cli/cli-commands/common/harness/$askForHarnessInstallationApproval.d.ts +0 -9
  320. package/umd/src/cli/cli-commands/common/harness/$installHarness.d.ts +0 -13
  321. package/umd/src/cli/cli-commands/common/harness/extractHarnessVersionFromOutput.d.ts +0 -11
  322. package/umd/src/cli/cli-commands/common/harness/isHarnessVersionOutdated.d.ts +0 -9
  323. /package/esm/src/{cli/cli-commands/common/harness/extractHarnessVersionFromOutput.test.d.ts → avatars/renderAvatarVisualTerminalText.test.d.ts} +0 -0
  324. /package/esm/src/{cli/cli-commands/common/harness/isHarnessVersionOutdated.test.d.ts → book-2.0/agent-source/createAgentModelRequirements.deduplication.test.d.ts} +0 -0
  325. /package/{umd/src/cli/cli-commands/common/harness/extractHarnessVersionFromOutput.test.d.ts → esm/src/book-2.0/agent-source/createAgentModelRequirementsWithCommitments.unknown.test.d.ts} +0 -0
  326. /package/{umd/src/cli/cli-commands/common/harness/isHarnessVersionOutdated.test.d.ts → esm/src/book-2.0/agent-source/deduplicateSystemMessage.test.d.ts} +0 -0
package/esm/index.es.js CHANGED
@@ -1,4 +1,4 @@
1
- import { join, basename, dirname, isAbsolute } from 'path';
1
+ import { join, basename, dirname, isAbsolute, delimiter } from 'path';
2
2
  import { spawn } from 'child_process';
3
3
  import colors from 'colors';
4
4
  import _spaceTrim, { spaceTrim as spaceTrim$1 } from 'spacetrim';
@@ -34,7 +34,7 @@ const BOOK_LANGUAGE_VERSION = '2.0.0';
34
34
  * @generated
35
35
  * @see https://github.com/webgptorg/promptbook
36
36
  */
37
- const PROMPTBOOK_ENGINE_VERSION = '0.114.0-4';
37
+ const PROMPTBOOK_ENGINE_VERSION = '0.114.0-41';
38
38
  /**
39
39
  * TODO: string_promptbook_version should be constrained to the all versions of Promptbook engine
40
40
  * Note: [💞] Ignore a discrepancy between file name and entity name
@@ -8721,23 +8721,27 @@ async function locateAppOnMacOs({ macOsName, }) {
8721
8721
  // TODO: [🧠][♿] Maybe export through `@promptbook/node`
8722
8722
 
8723
8723
  /**
8724
- * Attempts to locate the specified application on a Windows system by searching common installation directories.
8724
+ * Attempts to locate the specified application on a Windows system by searching PATH and common installation directories.
8725
8725
  * Returns the path to the executable if found, or null otherwise.
8726
8726
  *
8727
8727
  * @private within the repository
8728
8728
  */
8729
8729
  async function locateAppOnWindows({ appName, windowsSuffix, }) {
8730
8730
  try {
8731
- const prefixes = [
8731
+ const EXECUTABLE_FILENAME = windowsSuffix.replace(/^.*[\\/]/, '');
8732
+ const PATH_EXECUTABLE_PATHS = (process.env.PATH || '')
8733
+ .split(delimiter)
8734
+ .filter(Boolean)
8735
+ .map((pathPrefix) => join(pathPrefix, EXECUTABLE_FILENAME));
8736
+ const INSTALLATION_EXECUTABLE_PATHS = [
8732
8737
  process.env.LOCALAPPDATA,
8733
8738
  join(process.env.LOCALAPPDATA || '', 'Programs'),
8734
8739
  process.env.PROGRAMFILES,
8735
8740
  process.env['PROGRAMFILES(X86)'],
8736
- ];
8737
- for (const prefix of prefixes) {
8738
- const path = prefix + windowsSuffix;
8739
- if (await isExecutable(path, $provideFilesystemForNode())) {
8740
- return path;
8741
+ ].map((pathPrefix) => pathPrefix + windowsSuffix);
8742
+ for (const executablePath of [...PATH_EXECUTABLE_PATHS, ...INSTALLATION_EXECUTABLE_PATHS]) {
8743
+ if (await isExecutable(executablePath, $provideFilesystemForNode())) {
8744
+ return executablePath;
8741
8745
  }
8742
8746
  }
8743
8747
  throw new Error(`Can not locate app ${appName} on Windows.`);
@@ -10435,6 +10439,12 @@ class FromCommitmentDefinition extends BaseCommitmentDefinition {
10435
10439
 
10436
10440
  Inherits agent source from another agent.
10437
10441
 
10442
+ Every agent inherits from the core agent \`@Adam\` unless it says otherwise, so writing no ${this.type} at all
10443
+ is the same as writing \`${this.type} @Adam\`. Write \`${this.type} @Null\` to inherit from nothing.
10444
+
10445
+ An agent has exactly one parent, so when ${this.type} is written more than once, the last one wins and
10446
+ overrides every earlier one.
10447
+
10438
10448
  ## Examples
10439
10449
 
10440
10450
  \`\`\`book
@@ -10443,6 +10453,13 @@ class FromCommitmentDefinition extends BaseCommitmentDefinition {
10443
10453
  FROM https://s6.ptbk.io/benjamin-white
10444
10454
  RULE Speak only in English.
10445
10455
  \`\`\`
10456
+
10457
+ \`\`\`book
10458
+ My Standalone Agent
10459
+
10460
+ FROM @Null
10461
+ RULE Speak only in English.
10462
+ \`\`\`
10446
10463
  `);
10447
10464
  }
10448
10465
  applyToAgentModelRequirements(requirements, content) {
@@ -11575,6 +11592,13 @@ function darken(amount) {
11575
11592
  }
11576
11593
 
11577
11594
  /* eslint-disable no-magic-numbers */
11595
+ // Note: [💞] Ignore a discrepancy between file name and entity name
11596
+ /**
11597
+ * Default square size used by avatar renderers.
11598
+ *
11599
+ * @private utility of the avatar rendering system
11600
+ */
11601
+ const DEFAULT_AVATAR_SIZE = 192;
11578
11602
  /**
11579
11603
  * Corner radius ratio used for the common rounded card frame.
11580
11604
  *
@@ -11945,6 +11969,15 @@ const OUTLINE_GLYPHS = ['#', '%', '@'];
11945
11969
  * @private helper of `asciiOctopusAvatarVisual`
11946
11970
  */
11947
11971
  const ATMOSPHERE_GLYPHS = ['.', ':', "'", '`'];
11972
+ /**
11973
+ * Coordinate space the octopus layout is generated in when it is painted into a terminal.
11974
+ *
11975
+ * The terminal renderer has its own character grid, so the geometry only needs one stable
11976
+ * square coordinate space which the grid is then sampled from.
11977
+ *
11978
+ * @private helper of `asciiOctopusAvatarVisual`
11979
+ */
11980
+ const TERMINAL_ASCII_OCTOPUS_LAYOUT_SIZE = DEFAULT_AVATAR_SIZE;
11948
11981
  /**
11949
11982
  * AsciiOctopus avatar visual.
11950
11983
  *
@@ -11961,41 +11994,115 @@ const asciiOctopusAvatarVisual = {
11961
11994
  const staticRandom = createRandom('ascii-octopus-static');
11962
11995
  const gridMetrics = createAsciiGridMetrics(size, gridRandom);
11963
11996
  const layout = createAsciiOctopusLayout(size, timeMs, createRandom, staticRandom, interaction);
11997
+ const glyphGrid = createAsciiOctopusGlyphGrid({
11998
+ sampleGrid: gridMetrics,
11999
+ layout,
12000
+ palette,
12001
+ cellRandom: createRandom('ascii-octopus-cells'),
12002
+ timeMs,
12003
+ });
11964
12004
  drawAvatarFrame(context, size, palette);
11965
12005
  drawAsciiBackdrop(context, size, palette, layout, timeMs);
11966
12006
  context.save();
11967
12007
  context.font = `600 ${gridMetrics.fontSize}px monospace`;
11968
12008
  context.textAlign = 'center';
11969
12009
  context.textBaseline = 'middle';
11970
- // The ASCII renderer samples the morphing octopus field on a low-resolution grid so the shape stays organic
11971
- // while the glyph layout remains deterministic for the same avatar input.
11972
- const cellRandom = createRandom('ascii-octopus-cells');
11973
12010
  for (let rowIndex = 0; rowIndex < gridMetrics.rowCount; rowIndex++) {
11974
12011
  for (let columnIndex = 0; columnIndex < gridMetrics.columnCount; columnIndex++) {
11975
- const point = {
11976
- x: gridMetrics.offsetX + columnIndex * gridMetrics.cellWidth,
11977
- y: gridMetrics.offsetY + rowIndex * gridMetrics.cellHeight,
11978
- };
11979
- const noise = cellRandom();
11980
- const glyphDescriptor = resolveAsciiGlyph({
11981
- point,
11982
- layout,
11983
- palette,
11984
- cellWidth: gridMetrics.cellWidth,
11985
- cellHeight: gridMetrics.cellHeight,
11986
- noise,
11987
- timeMs,
11988
- });
12012
+ const glyphDescriptor = glyphGrid[rowIndex][columnIndex];
11989
12013
  if (!glyphDescriptor) {
11990
12014
  continue;
11991
12015
  }
12016
+ const point = resolveAsciiSampleGridPoint(gridMetrics, columnIndex, rowIndex);
11992
12017
  context.fillStyle = glyphDescriptor.color;
11993
12018
  context.fillText(glyphDescriptor.character, point.x, point.y);
11994
12019
  }
11995
12020
  }
11996
12021
  context.restore();
11997
12022
  },
12023
+ renderTerminalText({ columns, rows, palette, createRandom, timeMs, interaction }) {
12024
+ const staticRandom = createRandom('ascii-octopus-static');
12025
+ const layout = createAsciiOctopusLayout(TERMINAL_ASCII_OCTOPUS_LAYOUT_SIZE, timeMs, createRandom, staticRandom, interaction);
12026
+ return createAsciiOctopusGlyphGrid({
12027
+ sampleGrid: createAsciiTerminalSampleGrid(columns, rows),
12028
+ layout,
12029
+ palette,
12030
+ cellRandom: createRandom('ascii-octopus-cells'),
12031
+ timeMs,
12032
+ });
12033
+ },
11998
12034
  };
12035
+ /**
12036
+ * Resolves the geometry point sampled for one cell of the grid.
12037
+ *
12038
+ * @param sampleGrid Character-cell sampling grid.
12039
+ * @param columnIndex Zero-based cell column.
12040
+ * @param rowIndex Zero-based cell row.
12041
+ * @returns Sampled point in the octopus coordinate space.
12042
+ *
12043
+ * @private helper of `asciiOctopusAvatarVisual`
12044
+ */
12045
+ function resolveAsciiSampleGridPoint(sampleGrid, columnIndex, rowIndex) {
12046
+ return {
12047
+ x: sampleGrid.offsetX + columnIndex * sampleGrid.cellWidth,
12048
+ y: sampleGrid.offsetY + rowIndex * sampleGrid.cellHeight,
12049
+ };
12050
+ }
12051
+ /**
12052
+ * Builds the sampling grid used when the octopus is painted straight into terminal character cells.
12053
+ *
12054
+ * @param columns Available terminal columns.
12055
+ * @param rows Available terminal rows.
12056
+ * @returns Character-cell sampling grid covering the whole octopus coordinate space.
12057
+ *
12058
+ * @private helper of `asciiOctopusAvatarVisual`
12059
+ */
12060
+ function createAsciiTerminalSampleGrid(columns, rows) {
12061
+ const cellWidth = TERMINAL_ASCII_OCTOPUS_LAYOUT_SIZE / columns;
12062
+ const cellHeight = TERMINAL_ASCII_OCTOPUS_LAYOUT_SIZE / rows;
12063
+ return {
12064
+ cellWidth,
12065
+ cellHeight,
12066
+ columnCount: columns,
12067
+ rowCount: rows,
12068
+ offsetX: cellWidth / 2,
12069
+ offsetY: cellHeight / 2,
12070
+ };
12071
+ }
12072
+ /**
12073
+ * Samples the morphing octopus field into one deterministic grid of ASCII glyphs.
12074
+ *
12075
+ * The field is sampled on a low-resolution grid so the shape stays organic while the glyph
12076
+ * layout remains deterministic for the same avatar input. Both the canvas visual and the
12077
+ * terminal visual share this single sampling pass so they always describe the same octopus.
12078
+ *
12079
+ * @param options Sampling grid, prepared octopus layout, palette, per-cell noise, and animation time.
12080
+ * @returns Resolved glyph of every sampled cell, where `null` means an empty cell.
12081
+ *
12082
+ * @private helper of `asciiOctopusAvatarVisual`
12083
+ */
12084
+ function createAsciiOctopusGlyphGrid(options) {
12085
+ const { sampleGrid, layout, palette, cellRandom, timeMs } = options;
12086
+ const glyphGrid = [];
12087
+ for (let rowIndex = 0; rowIndex < sampleGrid.rowCount; rowIndex++) {
12088
+ const glyphRow = [];
12089
+ for (let columnIndex = 0; columnIndex < sampleGrid.columnCount; columnIndex++) {
12090
+ const point = resolveAsciiSampleGridPoint(sampleGrid, columnIndex, rowIndex);
12091
+ const noise = cellRandom();
12092
+ glyphRow.push(resolveAsciiGlyph({
12093
+ point,
12094
+ layout,
12095
+ palette,
12096
+ cellWidth: sampleGrid.cellWidth,
12097
+ cellHeight: sampleGrid.cellHeight,
12098
+ noise,
12099
+ timeMs,
12100
+ }));
12101
+ }
12102
+ glyphGrid.push(glyphRow);
12103
+ }
12104
+ return glyphGrid;
12105
+ }
11999
12106
  /**
12000
12107
  * Draws the dark terminal-like glow behind the ASCII octopus.
12001
12108
  *
@@ -24299,29 +24406,36 @@ class UseUserLocationCommitmentDefinition extends BaseCommitmentDefinition {
24299
24406
  /**
24300
24407
  * `WRITING RULES` commitment definition.
24301
24408
  *
24302
- * It adds constraints that apply strictly to writing style and presentation
24303
- * rather than task-solving behavior.
24409
+ * The `WRITING RULES`/`WRITING RULE` commitment adds constraints that apply strictly to writing style
24410
+ * and presentation rather than task-solving behavior.
24411
+ *
24412
+ * Example usage in agent source:
24413
+ *
24414
+ * ```book
24415
+ * WRITING RULES Keep every response under 120 words
24416
+ * WRITING RULE Always end the message with an emoji
24417
+ * ```
24304
24418
  *
24305
24419
  * @private [🪔] Maybe export the commitments through some package
24306
24420
  */
24307
24421
  class WritingRulesCommitmentDefinition extends BaseCommitmentDefinition {
24308
- constructor() {
24309
- super('WRITING RULES');
24422
+ constructor(type = 'WRITING RULES') {
24423
+ super(type);
24310
24424
  }
24311
24425
  /**
24312
- * Short one-line description of `WRITING RULES`.
24426
+ * Short one-line description of `WRITING RULES`/`WRITING RULE`.
24313
24427
  */
24314
24428
  get description() {
24315
24429
  return 'Add writing-only constraints such as tone, length, formatting, or emoji usage.';
24316
24430
  }
24317
24431
  /**
24318
- * Icon for `WRITING RULES`.
24432
+ * Icon for `WRITING RULES`/`WRITING RULE`.
24319
24433
  */
24320
24434
  get icon() {
24321
24435
  return '📝';
24322
24436
  }
24323
24437
  /**
24324
- * Markdown documentation for `WRITING RULES`.
24438
+ * Markdown documentation for `WRITING RULES`/`WRITING RULE` commitment.
24325
24439
  */
24326
24440
  get documentation() {
24327
24441
  return spaceTrim$1(`
@@ -24331,6 +24445,7 @@ class WritingRulesCommitmentDefinition extends BaseCommitmentDefinition {
24331
24445
 
24332
24446
  ## Key aspects
24333
24447
 
24448
+ - All writing rules are treated equally regardless of singular/plural form.
24334
24449
  - Use it for writing-only constraints such as tone, formatting, length, emoji usage, punctuation, or reading level.
24335
24450
  - Do **not** use it for problem-solving behavior, policy, tool usage, or decision-making logic. Use \`RULE\` for that.
24336
24451
  - Newer writing-rules blocks override conflicting earlier writing-rules blocks.
@@ -24529,7 +24644,8 @@ const COMMITMENT_REGISTRY = [
24529
24644
  new LanguageCommitmentDefinition('LANGUAGE'),
24530
24645
  new LanguageCommitmentDefinition('LANGUAGES'),
24531
24646
  new WritingSampleCommitmentDefinition(),
24532
- new WritingRulesCommitmentDefinition(),
24647
+ new WritingRulesCommitmentDefinition('WRITING RULES'),
24648
+ new WritingRulesCommitmentDefinition('WRITING RULE'),
24533
24649
  new SampleCommitmentDefinition('SAMPLE'),
24534
24650
  new SampleCommitmentDefinition('EXAMPLE'),
24535
24651
  new FormatCommitmentDefinition('FORMAT'),
@@ -28813,7 +28929,7 @@ function validateBook(source) {
28813
28929
  padBook(validateBook(spaceTrim$1(`
28814
28930
  AI Avatar
28815
28931
 
28816
- PERSONA A friendly AI assistant that helps you with your tasks
28932
+ GOAL Help users with their tasks as a friendly AI assistant.
28817
28933
  `)));
28818
28934
  // <- Note: Not using book`...` notation to avoid strange error in jest unit tests `TypeError: (0 , book_notation_1.book) is not a function`
28819
28935
  // <- TODO: [🐱‍🚀] `GENESIS_BOOK` / `ADAM_BOOK` in `/agents/adam.book`
@@ -29208,6 +29324,30 @@ function createDefaultAgentName(agentSource) {
29208
29324
  return normalizeAgentName(`Agent ${agentHash.substring(0, LIMITS.SHORT_NAME_LENGTH)}`);
29209
29325
  }
29210
29326
 
29327
+ /**
29328
+ * Pattern shared by Book parsing and editor highlighting for a commitment-like line.
29329
+ *
29330
+ * A Book commitment keyword consists of one or more all-uppercase words with at least
29331
+ * two characters each. This deliberately mirrors the Book editor syntax rule so an
29332
+ * unknown keyword starts a new source block everywhere it is interpreted.
29333
+ *
29334
+ * @private internal constant of `getBookCommitmentLineType`
29335
+ */
29336
+ const BOOK_COMMITMENT_LINE_TYPE_REGEX = /^\s*(?<type>[A-Z][A-Z0-9]+(?:\s+[A-Z][A-Z0-9]+)*)(?=\s|$)/;
29337
+ /**
29338
+ * Extracts the uppercase commitment type from a Book line, including types not registered by Promptbook.
29339
+ *
29340
+ * @param line - One raw Book source line.
29341
+ * @returns Matched commitment type or `null` when the line does not begin with commitment syntax.
29342
+ *
29343
+ * @private internal utility of Book parsing and `<BookEditor/>`
29344
+ */
29345
+ function getBookCommitmentLineType(line) {
29346
+ var _a;
29347
+ const match = BOOK_COMMITMENT_LINE_TYPE_REGEX.exec(line);
29348
+ return ((_a = match === null || match === void 0 ? void 0 : match.groups) === null || _a === void 0 ? void 0 : _a.type) || null;
29349
+ }
29350
+
29211
29351
  /**
29212
29352
  * Consumes the agent-name prelude from raw source.
29213
29353
  *
@@ -29265,13 +29405,15 @@ function parseAgentSourceWithCommitments(agentSource) {
29265
29405
  return {
29266
29406
  agentName: null,
29267
29407
  commitments: [],
29408
+ unknownCommitments: [],
29268
29409
  nonCommitmentLines: [],
29269
29410
  };
29270
29411
  }
29271
29412
  const { lines, agentName, agentNameLineIndex, agentNameLineNumber } = parseAgentSourcePrelude(agentSource);
29272
29413
  const commitments = [];
29414
+ const unknownCommitments = [];
29273
29415
  const nonCommitmentLines = agentNameLineIndex >= 0 ? [lines[agentNameLineIndex]] : [];
29274
- // Parse commitments with multiline support
29416
+ // Parse commitments with multiline support.
29275
29417
  let currentCommitment = null;
29276
29418
  // Process lines starting from after the agent name line
29277
29419
  const startIndex = agentNameLineIndex >= 0 ? agentNameLineIndex + 1 : 0;
@@ -29285,25 +29427,11 @@ function parseAgentSourceWithCommitments(agentSource) {
29285
29427
  // Check if this line starts or ends a code block
29286
29428
  if (trimmedLine.startsWith('```')) {
29287
29429
  isInsideCodeBlock = !isInsideCodeBlock;
29288
- if (currentCommitment) {
29289
- // If we are inside a commitment, the code block is part of it
29290
- currentCommitment.contentLines.push(line);
29291
- }
29292
- else {
29293
- // If we are not inside a commitment, the code block is non-commitment
29294
- nonCommitmentLines.push(line);
29295
- }
29430
+ appendLineToCurrentCommitmentOrNonCommitmentLines(currentCommitment, line, nonCommitmentLines);
29296
29431
  continue;
29297
29432
  }
29298
29433
  if (isInsideCodeBlock) {
29299
- if (currentCommitment) {
29300
- // If we are inside a commitment and a code block, the line is part of the commitment
29301
- currentCommitment.contentLines.push(line);
29302
- }
29303
- else {
29304
- // If we are inside a code block but not a commitment, the line is non-commitment
29305
- nonCommitmentLines.push(line);
29306
- }
29434
+ appendLineToCurrentCommitmentOrNonCommitmentLines(currentCommitment, line, nonCommitmentLines);
29307
29435
  continue;
29308
29436
  }
29309
29437
  // Check if this line starts a new commitment
@@ -29312,22 +29440,14 @@ function parseAgentSourceWithCommitments(agentSource) {
29312
29440
  const typeRegex = definition.createTypeRegex();
29313
29441
  const match = typeRegex.exec(line.trim());
29314
29442
  if (match && ((_a = match.groups) === null || _a === void 0 ? void 0 : _a.type)) {
29315
- // Save the previous commitment if it exists
29316
- if (currentCommitment) {
29317
- const fullContent = currentCommitment.contentLines.join('\n');
29318
- commitments.push({
29319
- type: currentCommitment.type,
29320
- content: spaceTrim$1(fullContent),
29321
- originalLine: currentCommitment.originalStartLine,
29322
- lineNumber: currentCommitment.startLineNumber,
29323
- });
29324
- }
29443
+ appendCurrentCommitment(currentCommitment, commitments, unknownCommitments);
29325
29444
  // Extract the initial content from the commitment line
29326
29445
  const fullRegex = definition.createRegex();
29327
29446
  const fullMatch = fullRegex.exec(line.trim());
29328
29447
  const initialContent = ((_b = fullMatch === null || fullMatch === void 0 ? void 0 : fullMatch.groups) === null || _b === void 0 ? void 0 : _b.contents) || '';
29329
29448
  // Start a new commitment
29330
29449
  currentCommitment = {
29450
+ kind: 'known',
29331
29451
  type: definition.type,
29332
29452
  startLineNumber: i + 1,
29333
29453
  originalStartLine: line,
@@ -29337,52 +29457,90 @@ function parseAgentSourceWithCommitments(agentSource) {
29337
29457
  break;
29338
29458
  }
29339
29459
  }
29460
+ if (foundNewCommitment) {
29461
+ continue;
29462
+ }
29463
+ const unknownCommitmentType = getBookCommitmentLineType(line);
29464
+ if (unknownCommitmentType) {
29465
+ appendCurrentCommitment(currentCommitment, commitments, unknownCommitments);
29466
+ currentCommitment = {
29467
+ kind: 'unknown',
29468
+ type: unknownCommitmentType,
29469
+ startLineNumber: i + 1,
29470
+ originalStartLine: line,
29471
+ sourceLines: [line],
29472
+ };
29473
+ continue;
29474
+ }
29340
29475
  // Check if this is a horizontal line (ends any current commitment)
29341
29476
  const isHorizontalLine = HORIZONTAL_LINE_PATTERN$1.test(line);
29342
29477
  if (isHorizontalLine) {
29343
- // Save the current commitment if it exists
29344
- if (currentCommitment) {
29345
- const fullContent = currentCommitment.contentLines.join('\n');
29346
- commitments.push({
29347
- type: currentCommitment.type,
29348
- content: spaceTrim$1(fullContent),
29349
- originalLine: currentCommitment.originalStartLine,
29350
- lineNumber: currentCommitment.startLineNumber,
29351
- });
29352
- currentCommitment = null;
29353
- }
29478
+ appendCurrentCommitment(currentCommitment, commitments, unknownCommitments);
29479
+ currentCommitment = null;
29354
29480
  // Add horizontal line to non-commitment lines
29355
29481
  nonCommitmentLines.push(line);
29356
29482
  continue;
29357
29483
  }
29358
- if (!foundNewCommitment) {
29359
- if (currentCommitment) {
29360
- // This line belongs to the current commitment
29361
- currentCommitment.contentLines.push(line);
29362
- }
29363
- else {
29364
- // This line is not part of any commitment
29365
- nonCommitmentLines.push(line);
29366
- }
29367
- }
29368
- }
29369
- // Don't forget to save the last commitment if it exists
29370
- if (currentCommitment) {
29371
- const fullContent = currentCommitment.contentLines.join('\n');
29372
- commitments.push({
29373
- type: currentCommitment.type,
29374
- content: spaceTrim$1(fullContent),
29375
- originalLine: currentCommitment.originalStartLine,
29376
- lineNumber: currentCommitment.startLineNumber,
29377
- });
29484
+ appendLineToCurrentCommitmentOrNonCommitmentLines(currentCommitment, line, nonCommitmentLines);
29378
29485
  }
29486
+ appendCurrentCommitment(currentCommitment, commitments, unknownCommitments);
29379
29487
  return {
29380
29488
  agentName,
29381
29489
  agentNameLineNumber,
29382
29490
  commitments,
29491
+ unknownCommitments,
29383
29492
  nonCommitmentLines,
29384
29493
  };
29385
29494
  }
29495
+ /**
29496
+ * Stores the current known or unknown commitment in its appropriate parsed collection.
29497
+ *
29498
+ * @param currentCommitment - Commitment-like block collected so far.
29499
+ * @param commitments - Parsed registered commitments to append to.
29500
+ * @param unknownCommitments - Parsed unregistered commitments to append to.
29501
+ *
29502
+ * @private internal utility of `parseAgentSourceWithCommitments`
29503
+ */
29504
+ function appendCurrentCommitment(currentCommitment, commitments, unknownCommitments) {
29505
+ if (!currentCommitment) {
29506
+ return;
29507
+ }
29508
+ if (currentCommitment.kind === 'unknown') {
29509
+ unknownCommitments.push({
29510
+ type: currentCommitment.type,
29511
+ originalLine: currentCommitment.originalStartLine,
29512
+ lineNumber: currentCommitment.startLineNumber,
29513
+ source: spaceTrim$1(currentCommitment.sourceLines.join('\n')),
29514
+ });
29515
+ return;
29516
+ }
29517
+ commitments.push({
29518
+ type: currentCommitment.type,
29519
+ content: spaceTrim$1(currentCommitment.contentLines.join('\n')),
29520
+ originalLine: currentCommitment.originalStartLine,
29521
+ lineNumber: currentCommitment.startLineNumber,
29522
+ });
29523
+ }
29524
+ /**
29525
+ * Adds one source line to the active commitment-like block, or to plain source content when none is active.
29526
+ *
29527
+ * @param currentCommitment - Commitment-like block currently being collected.
29528
+ * @param line - Source line to append.
29529
+ * @param nonCommitmentLines - Plain source lines to append to when no block is active.
29530
+ *
29531
+ * @private internal utility of `parseAgentSourceWithCommitments`
29532
+ */
29533
+ function appendLineToCurrentCommitmentOrNonCommitmentLines(currentCommitment, line, nonCommitmentLines) {
29534
+ if (!currentCommitment) {
29535
+ nonCommitmentLines.push(line);
29536
+ return;
29537
+ }
29538
+ if (currentCommitment.kind === 'unknown') {
29539
+ currentCommitment.sourceLines.push(line);
29540
+ return;
29541
+ }
29542
+ currentCommitment.contentLines.push(line);
29543
+ }
29386
29544
 
29387
29545
  /**
29388
29546
  * Parses parameters from text using both supported notations:
@@ -30475,7 +30633,8 @@ async function augmentAgentModelRequirementsFromSource(requirements, parseResult
30475
30633
  requirements = await importReferencedFiles(requirements);
30476
30634
  requirements = appendMcpServers(requirements, agentSource);
30477
30635
  requirements = appendNonCommitmentContent(requirements, parseResult);
30478
- return appendExampleInteractions(requirements, parseResult);
30636
+ requirements = appendExampleInteractions(requirements, parseResult);
30637
+ return appendUnknownCommitmentContent(requirements, parseResult);
30479
30638
  }
30480
30639
  /**
30481
30640
  * Imports text files referenced by IMPORT commitments and appends their transformed content to the system message.
@@ -30597,6 +30756,36 @@ function appendNonCommitmentContent(requirements, parseResult) {
30597
30756
  }
30598
30757
  return appendSystemMessageSection(requirements, nonCommitmentContent);
30599
30758
  }
30759
+ /**
30760
+ * Appends unknown commitment blocks as final extra context without applying commitment side effects.
30761
+ *
30762
+ * @param requirements - Current requirements snapshot.
30763
+ * @param parseResult - Parsed source including unknown commitment blocks.
30764
+ * @returns Requirements with unknown commitment context appended at the end of the system message.
30765
+ *
30766
+ * @private internal utility of `augmentAgentModelRequirementsFromSource`
30767
+ */
30768
+ function appendUnknownCommitmentContent(requirements, parseResult) {
30769
+ const unknownCommitmentContent = getUnknownCommitmentContent(parseResult);
30770
+ if (!unknownCommitmentContent) {
30771
+ return requirements;
30772
+ }
30773
+ return appendSystemMessageSection(requirements, unknownCommitmentContent);
30774
+ }
30775
+ /**
30776
+ * Joins unknown commitment blocks into their final extra-context representation.
30777
+ *
30778
+ * @param parseResult - Parsed source including unknown commitment blocks.
30779
+ * @returns Unknown commitment source blocks in their original order.
30780
+ *
30781
+ * @private internal utility of `appendUnknownCommitmentContent`
30782
+ */
30783
+ function getUnknownCommitmentContent(parseResult) {
30784
+ return parseResult.unknownCommitments
30785
+ .map((commitment) => commitment.source)
30786
+ .filter(Boolean)
30787
+ .join('\n\n');
30788
+ }
30600
30789
  /**
30601
30790
  * Collects plain-text lines that were not parsed as commitments and should still become part of the final system message.
30602
30791
  *
@@ -30924,6 +31113,245 @@ function stripInlineKnowledgeMetadata(metadata) {
30924
31113
  return Object.keys(rest).length > 0 ? rest : undefined;
30925
31114
  }
30926
31115
 
31116
+ /**
31117
+ * Pattern matching a markdown section heading (`## Title`) that separates system-message sections
31118
+ *
31119
+ * @private internal constant of `deduplicateSystemMessage`
31120
+ */
31121
+ const SYSTEM_MESSAGE_SECTION_HEADING_PATTERN = /^##(?!#)\s*(.+?)\s*$/;
31122
+ /**
31123
+ * Pattern matching a fenced code block delimiter which suspends section and block splitting
31124
+ *
31125
+ * @private internal constant of `deduplicateSystemMessage`
31126
+ */
31127
+ const CODE_FENCE_PATTERN = /^\s*(?:```|~~~)/;
31128
+ /**
31129
+ * Pattern matching a markdown list item which keeps merged bullet lists visually compact
31130
+ *
31131
+ * @private internal constant of `deduplicateSystemMessage`
31132
+ */
31133
+ const LIST_ITEM_PATTERN = /^\s*(?:[-*+]|\d+[.)])\s/;
31134
+ /**
31135
+ * Removes duplicated instructions from a generated system message
31136
+ *
31137
+ * Commitments are applied one by one, so a commitment used multiple times in one book repeats its whole
31138
+ * section, including the shared guidance preamble. For example two `WRITING RULES` commitments emit the
31139
+ * `## Writing rules` heading and its guidance paragraph twice. This function merges all sections sharing
31140
+ * one heading into the position of their first occurrence and keeps every identical block only once.
31141
+ *
31142
+ * @param systemMessage The assembled system message which may contain repeated sections and blocks
31143
+ * @returns The system message where each section heading and each identical block appears exactly once
31144
+ *
31145
+ * @private internal utility of `createAgentModelRequirementsWithCommitments`
31146
+ */
31147
+ function deduplicateSystemMessage(systemMessage) {
31148
+ if (!systemMessage.trim()) {
31149
+ return systemMessage;
31150
+ }
31151
+ return splitSystemMessageIntoRegions(systemMessage)
31152
+ .reduce(mergeRegionSharingHeading, [])
31153
+ .map(removeDuplicateBlocksFromRegion)
31154
+ .map(renderRegion)
31155
+ .filter((renderedRegion) => renderedRegion !== '')
31156
+ .join('\n\n');
31157
+ }
31158
+ /**
31159
+ * Splits the system message into the intro region and one region per `## Title` section
31160
+ *
31161
+ * @param systemMessage The system message to split
31162
+ * @returns Regions in their original order, without empty ones
31163
+ *
31164
+ * @private internal utility of `deduplicateSystemMessage`
31165
+ */
31166
+ function splitSystemMessageIntoRegions(systemMessage) {
31167
+ const regions = [];
31168
+ let headingLine = null;
31169
+ let bodyLines = [];
31170
+ let isInsideCodeFence = false;
31171
+ for (const line of systemMessage.split(/\r?\n/)) {
31172
+ if (CODE_FENCE_PATTERN.test(line)) {
31173
+ isInsideCodeFence = !isInsideCodeFence;
31174
+ }
31175
+ if (isInsideCodeFence || !SYSTEM_MESSAGE_SECTION_HEADING_PATTERN.test(line)) {
31176
+ bodyLines.push(line);
31177
+ continue;
31178
+ }
31179
+ regions.push(createRegion(headingLine, bodyLines));
31180
+ headingLine = line;
31181
+ bodyLines = [];
31182
+ }
31183
+ regions.push(createRegion(headingLine, bodyLines));
31184
+ return regions.filter((region) => region.headingLine !== null || region.blocks.length > 0);
31185
+ }
31186
+ /**
31187
+ * Creates one region from its heading line and its raw body lines
31188
+ *
31189
+ * @param headingLine The original `## Title` line, or `null` for the intro before the first heading
31190
+ * @param bodyLines The raw lines following the heading line
31191
+ * @returns The region with its body already split into blocks
31192
+ *
31193
+ * @private internal utility of `splitSystemMessageIntoRegions`
31194
+ */
31195
+ function createRegion(headingLine, bodyLines) {
31196
+ return {
31197
+ titleKey: headingLine === null ? null : normalizeSectionTitle(headingLine),
31198
+ headingLine,
31199
+ isBodySeparatedByBlankLine: bodyLines[0] !== undefined && bodyLines[0].trim() === '',
31200
+ blocks: splitBodyIntoBlocks(bodyLines),
31201
+ };
31202
+ }
31203
+ /**
31204
+ * Normalizes a heading line into a key usable for matching sections which belong together
31205
+ *
31206
+ * @param headingLine The original `## Title` line
31207
+ * @returns Lowercased title without the markdown heading prefix
31208
+ *
31209
+ * @private internal utility of `createRegion`
31210
+ */
31211
+ function normalizeSectionTitle(headingLine) {
31212
+ var _a, _b;
31213
+ return ((_b = (_a = SYSTEM_MESSAGE_SECTION_HEADING_PATTERN.exec(headingLine)) === null || _a === void 0 ? void 0 : _a[1]) !== null && _b !== void 0 ? _b : headingLine).toLowerCase();
31214
+ }
31215
+ /**
31216
+ * Splits raw body lines into blocks separated by blank lines while keeping fenced code blocks intact
31217
+ *
31218
+ * @param bodyLines The raw lines of one region body
31219
+ * @returns Non-empty blocks in their original order
31220
+ *
31221
+ * @private internal utility of `createRegion`
31222
+ */
31223
+ function splitBodyIntoBlocks(bodyLines) {
31224
+ const blockTexts = [];
31225
+ let blockLines = [];
31226
+ let isInsideCodeFence = false;
31227
+ for (const line of bodyLines) {
31228
+ if (CODE_FENCE_PATTERN.test(line)) {
31229
+ isInsideCodeFence = !isInsideCodeFence;
31230
+ }
31231
+ if (!isInsideCodeFence && line.trim() === '') {
31232
+ blockTexts.push(blockLines.join('\n'));
31233
+ blockLines = [];
31234
+ continue;
31235
+ }
31236
+ blockLines.push(line);
31237
+ }
31238
+ blockTexts.push(blockLines.join('\n'));
31239
+ return blockTexts
31240
+ .filter((blockText) => blockText.trim() !== '')
31241
+ .map((blockText) => ({ text: blockText, isOpeningMergedSection: false }));
31242
+ }
31243
+ /**
31244
+ * Appends one region to the already merged regions, merging it into an earlier region with the same heading
31245
+ *
31246
+ * @param mergedRegions Regions merged so far, used as the reducer accumulator
31247
+ * @param region The next region in original order
31248
+ * @returns The accumulator with the region either appended or merged into its earlier twin
31249
+ *
31250
+ * @private internal utility of `deduplicateSystemMessage`
31251
+ */
31252
+ function mergeRegionSharingHeading(mergedRegions, region) {
31253
+ const existingRegionIndex = mergedRegions.findIndex((mergedRegion) => region.titleKey !== null && mergedRegion.titleKey === region.titleKey);
31254
+ if (existingRegionIndex === -1) {
31255
+ return [...mergedRegions, region];
31256
+ }
31257
+ return mergedRegions.map((mergedRegion, index) => index !== existingRegionIndex
31258
+ ? mergedRegion
31259
+ : {
31260
+ ...mergedRegion,
31261
+ blocks: [...mergedRegion.blocks, ...markFirstBlockAsOpeningMergedSection(region.blocks)],
31262
+ });
31263
+ }
31264
+ /**
31265
+ * Marks the first block of a merged section occurrence so the merge seam can be rendered as one list
31266
+ *
31267
+ * @param blocks The blocks of the section occurrence being merged into an earlier section
31268
+ * @returns The same blocks with the first one marked as opening a merged section
31269
+ *
31270
+ * @private internal utility of `mergeRegionSharingHeading`
31271
+ */
31272
+ function markFirstBlockAsOpeningMergedSection(blocks) {
31273
+ return blocks.map((block, index) => (index === 0 ? { ...block, isOpeningMergedSection: true } : block));
31274
+ }
31275
+ /**
31276
+ * Keeps only the first occurrence of every identical block inside one region
31277
+ *
31278
+ * @param region The region whose blocks may repeat
31279
+ * @returns The region without repeated blocks
31280
+ *
31281
+ * @private internal utility of `deduplicateSystemMessage`
31282
+ */
31283
+ function removeDuplicateBlocksFromRegion(region) {
31284
+ const alreadyRenderedTexts = new Set();
31285
+ const uniqueBlocks = [];
31286
+ let isMergeSeamPending = false;
31287
+ for (const block of region.blocks) {
31288
+ if (alreadyRenderedTexts.has(block.text)) {
31289
+ // Note: A removed block must still hand its merge seam over to the next block which survives
31290
+ isMergeSeamPending = isMergeSeamPending || block.isOpeningMergedSection;
31291
+ continue;
31292
+ }
31293
+ alreadyRenderedTexts.add(block.text);
31294
+ uniqueBlocks.push({
31295
+ text: block.text,
31296
+ isOpeningMergedSection: block.isOpeningMergedSection || isMergeSeamPending,
31297
+ });
31298
+ isMergeSeamPending = false;
31299
+ }
31300
+ return { ...region, blocks: uniqueBlocks };
31301
+ }
31302
+ /**
31303
+ * Renders one region back into its markdown representation
31304
+ *
31305
+ * @param region The region to render
31306
+ * @returns The heading line together with its joined blocks
31307
+ *
31308
+ * @private internal utility of `deduplicateSystemMessage`
31309
+ */
31310
+ function renderRegion(region) {
31311
+ const body = joinBlocks(region.blocks);
31312
+ if (region.headingLine === null) {
31313
+ return body;
31314
+ }
31315
+ if (body === '') {
31316
+ return region.headingLine;
31317
+ }
31318
+ return `${region.headingLine}${region.isBodySeparatedByBlankLine ? '\n\n' : '\n'}${body}`;
31319
+ }
31320
+ /**
31321
+ * Joins blocks of one region back together
31322
+ *
31323
+ * @param blocks The blocks to join in their original order
31324
+ * @returns The joined body of one region
31325
+ *
31326
+ * @private internal utility of `renderRegion`
31327
+ */
31328
+ function joinBlocks(blocks) {
31329
+ return blocks
31330
+ .map((block, index) => index === 0 ? block.text : `${createBlockSeparator(blocks[index - 1], block)}${block.text}`)
31331
+ .join('');
31332
+ }
31333
+ /**
31334
+ * Chooses the separator between two neighboring blocks
31335
+ *
31336
+ * Blocks are normally separated by a blank line, exactly as they were written. Only where two sections were
31337
+ * merged together their lists are joined into one compact list instead of two separate ones.
31338
+ *
31339
+ * @param previousBlock The block rendered before the separator
31340
+ * @param nextBlock The block rendered after the separator
31341
+ * @returns Either a single or a double newline
31342
+ *
31343
+ * @private internal utility of `joinBlocks`
31344
+ */
31345
+ function createBlockSeparator(previousBlock, nextBlock) {
31346
+ if (!nextBlock.isOpeningMergedSection) {
31347
+ return '\n\n';
31348
+ }
31349
+ const previousBlockLines = previousBlock.text.split('\n');
31350
+ const isListContinuing = LIST_ITEM_PATTERN.test(previousBlockLines[previousBlockLines.length - 1]) &&
31351
+ LIST_ITEM_PATTERN.test(nextBlock.text.split('\n')[0]);
31352
+ return isListContinuing ? '\n' : '\n\n';
31353
+ }
31354
+
30927
31355
  /**
30928
31356
  * Removes single-hash comment lines (`# Comment`) from a system message
30929
31357
  * This is used to clean up the final system message before sending it to the AI model
@@ -30997,14 +31425,14 @@ function createInitialAgentModelRequirements(agentName, modelName) {
30997
31425
  * Performs the final system-message cleanup pass after all other augmentation steps are complete.
30998
31426
  *
30999
31427
  * @param requirements - Fully built requirements before final cleanup.
31000
- * @returns Requirements with comment lines removed from the final system message.
31428
+ * @returns Requirements with comment lines removed and repeated instructions deduplicated in the final system message.
31001
31429
  *
31002
31430
  * @private internal utility of `createAgentModelRequirementsWithCommitments`
31003
31431
  */
31004
31432
  function finalizeRequirements(requirements) {
31005
31433
  return {
31006
31434
  ...requirements,
31007
- systemMessage: removeCommentsFromSystemMessage(requirements.systemMessage),
31435
+ systemMessage: deduplicateSystemMessage(removeCommentsFromSystemMessage(requirements.systemMessage)),
31008
31436
  };
31009
31437
  }
31010
31438
 
@@ -31667,28 +32095,28 @@ function parseToolExecutionEnvelope(rawValue) {
31667
32095
  */
31668
32096
  function buildToolInvocationScript(options) {
31669
32097
  const { functionName, functionArgsExpression } = options;
31670
- return `
31671
- const args = ${functionArgsExpression};
31672
- const runtimeContextRaw =
31673
- typeof ${TOOL_RUNTIME_CONTEXT_PARAMETER} === 'undefined'
31674
- ? undefined
31675
- : ${TOOL_RUNTIME_CONTEXT_PARAMETER};
31676
-
31677
- if (runtimeContextRaw !== undefined && args && typeof args === 'object' && !Array.isArray(args)) {
31678
- args.${TOOL_RUNTIME_CONTEXT_ARGUMENT} = runtimeContextRaw;
31679
- }
32098
+ return spaceTrim$1((block) => `
32099
+ const args = ${block(functionArgsExpression)};
32100
+ const runtimeContextRaw =
32101
+ typeof ${TOOL_RUNTIME_CONTEXT_PARAMETER} === 'undefined'
32102
+ ? undefined
32103
+ : ${TOOL_RUNTIME_CONTEXT_PARAMETER};
32104
+
32105
+ if (runtimeContextRaw !== undefined && args && typeof args === 'object' && !Array.isArray(args)) {
32106
+ args.${TOOL_RUNTIME_CONTEXT_ARGUMENT} = runtimeContextRaw;
32107
+ }
31680
32108
 
31681
- const toolProgressTokenRaw =
31682
- typeof ${TOOL_PROGRESS_TOKEN_PARAMETER} === 'undefined'
31683
- ? undefined
31684
- : ${TOOL_PROGRESS_TOKEN_PARAMETER};
32109
+ const toolProgressTokenRaw =
32110
+ typeof ${TOOL_PROGRESS_TOKEN_PARAMETER} === 'undefined'
32111
+ ? undefined
32112
+ : ${TOOL_PROGRESS_TOKEN_PARAMETER};
31685
32113
 
31686
- if (toolProgressTokenRaw !== undefined && args && typeof args === 'object' && !Array.isArray(args)) {
31687
- args.${TOOL_PROGRESS_TOKEN_ARGUMENT} = toolProgressTokenRaw;
31688
- }
32114
+ if (toolProgressTokenRaw !== undefined && args && typeof args === 'object' && !Array.isArray(args)) {
32115
+ args.${TOOL_PROGRESS_TOKEN_ARGUMENT} = toolProgressTokenRaw;
32116
+ }
31689
32117
 
31690
- return await ${functionName}(args);
31691
- `;
32118
+ return await ${functionName}(args);
32119
+ `);
31692
32120
  }
31693
32121
 
31694
32122
  /**