@promptbook/cli 0.114.0-1 → 0.114.0-3

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 (199) hide show
  1. package/README.md +16 -15
  2. package/apps/agents-server/next.config.ts +11 -0
  3. package/apps/agents-server/package.json +6 -4
  4. package/apps/agents-server/playwright.config.ts +28 -38
  5. package/apps/agents-server/scripts/build-agents-server.js +62 -0
  6. package/apps/agents-server/scripts/build-e2e.js +38 -0
  7. package/apps/agents-server/scripts/ensure-root-dependencies.js +86 -0
  8. package/apps/agents-server/scripts/prerender-homepage.js +1 -1
  9. package/apps/agents-server/scripts/run-e2e-tests.js +34 -0
  10. package/apps/agents-server/scripts/run-npm.js +42 -0
  11. package/apps/agents-server/src/app/admin/email-server/page.tsx +14 -6
  12. package/apps/agents-server/src/app/api/elevenlabs/tts/route.ts +3 -3
  13. package/apps/agents-server/src/app/api/onboarding/book/route.ts +7 -6
  14. package/apps/agents-server/src/app/layout.tsx +6 -0
  15. package/apps/agents-server/src/app/superadmin/servers/ServersRegistryTable.tsx +105 -102
  16. package/apps/agents-server/src/app/superadmin/servers/useServersRegistryState.ts +15 -7
  17. package/apps/agents-server/src/components/AgentProjectDnsInstructions/AgentProjectDnsInstructions.tsx +11 -11
  18. package/apps/agents-server/src/components/NewAgentDialog/ManGoNewAgentWizard/components/ManGoBookEditor.tsx +82 -0
  19. package/apps/agents-server/src/components/NewAgentDialog/ManGoNewAgentWizard/components/WizardShell.tsx +2 -2
  20. package/apps/agents-server/src/components/NewAgentDialog/ManGoNewAgentWizard/components/steps/BookStep.tsx +13 -16
  21. package/apps/agents-server/src/components/NewAgentDialog/ManGoNewAgentWizard/components/steps/ZadaniStep.tsx +4 -4
  22. package/apps/agents-server/src/components/NewAgentDialog/ManGoNewAgentWizard/config/bookSections.ts +23 -16
  23. package/apps/agents-server/src/components/NewAgentDialog/ManGoNewAgentWizard/lib/bookSource.ts +54 -0
  24. package/apps/agents-server/src/components/NewAgentDialog/ManGoNewAgentWizard/services/bookService.ts +15 -8
  25. package/apps/agents-server/src/components/NewAgentDialog/ManGoNewAgentWizard/services/createManGoAgentSource.ts +3 -37
  26. package/apps/agents-server/src/components/NewAgentDialog/ManGoNewAgentWizard/services/createManGoOpenEditorRequest.ts +1 -1
  27. package/apps/agents-server/src/components/NewAgentDialog/ManGoNewAgentWizard/state/OnboardingProvider.tsx +2 -2
  28. package/apps/agents-server/src/components/UsersList/CreateUserDialog.tsx +13 -22
  29. package/apps/agents-server/src/components/UsersList/PasswordGeneratorDialog.tsx +216 -0
  30. package/apps/agents-server/src/components/UsersList/UsersList.tsx +16 -11
  31. package/apps/agents-server/src/components/UsersList/generateSecurePassword.ts +112 -24
  32. package/apps/agents-server/src/components/UsersList/userDialogClassNames.ts +11 -0
  33. package/apps/agents-server/src/languages/ServerTranslationKeys.ts +11 -0
  34. package/apps/agents-server/src/languages/translations/czech.yaml +11 -0
  35. package/apps/agents-server/src/languages/translations/english.yaml +11 -0
  36. package/apps/agents-server/src/utils/agentProjects/agentProjectHrefs.ts +11 -0
  37. package/apps/agents-server/src/utils/agentProjects/createAgentProjectDnsRecords.ts +53 -7
  38. package/apps/agents-server/src/utils/agentProjects/createAgentProjectMarkdownReferences.ts +37 -27
  39. package/apps/agents-server/src/utils/manGoOnboarding/manGoOnboardingAgentBooks.ts +2 -13
  40. package/apps/agents-server/src/utils/manGoOnboarding/manGoOnboardingAgentRuntime.ts +21 -73
  41. package/apps/agents-server/src/utils/stalwart/createEmailDnsInstructions.ts +9 -5
  42. package/apps/agents-server/src/utils/stalwart/readStalwartEmailSnapshot.ts +23 -5
  43. package/apps/agents-server/src/utils/stalwart/stalwartBootstrap.ts +2 -1
  44. package/apps/agents-server/src/utils/stalwart/stalwartMailBridge.ts +7 -0
  45. package/apps/agents-server/tests/e2e/e2eEnvironment.cjs +49 -0
  46. package/esm/index.es.js +1105 -273
  47. package/esm/index.es.js.map +1 -1
  48. package/esm/scripts/run-codex-prompts/common/runGoScript/scriptExecutionLog.d.ts +7 -0
  49. package/esm/scripts/run-codex-prompts/git/coderGitSync.d.ts +43 -0
  50. package/esm/scripts/run-codex-prompts/git/commitChanges.d.ts +3 -0
  51. package/esm/scripts/run-codex-prompts/main/resolvePromptRunner.d.ts +8 -1
  52. package/esm/scripts/run-codex-prompts/ping/buildCoderPingPrompt.d.ts +20 -0
  53. package/esm/scripts/run-codex-prompts/ping/extractCoderPingAnswer.d.ts +9 -0
  54. package/esm/scripts/run-codex-prompts/ping/pingCoderHarness.d.ts +23 -0
  55. package/esm/scripts/run-codex-prompts/ping/printCoderPingResult.d.ts +5 -0
  56. package/esm/scripts/run-codex-prompts/prompts/findNextTodoPrompt.d.ts +2 -1
  57. package/esm/scripts/run-codex-prompts/prompts/isPromptCompatibleWithRunner.d.ts +27 -0
  58. package/esm/scripts/run-codex-prompts/prompts/listRunnablePrompts.d.ts +2 -1
  59. package/esm/scripts/run-codex-prompts/prompts/listUpcomingTasks.d.ts +2 -1
  60. package/esm/scripts/run-codex-prompts/prompts/replacePromptTodoStatusLine.d.ts +7 -0
  61. package/esm/scripts/run-codex-prompts/testing/TestBeforeMode.d.ts +16 -0
  62. package/esm/scripts/run-codex-prompts/testing/createTestBeforeRepairPrompt.d.ts +9 -0
  63. package/esm/scripts/run-codex-prompts/testing/limitTestOutput.d.ts +4 -0
  64. package/esm/scripts/run-codex-prompts/testing/runPromptTestCommand.d.ts +1 -2
  65. package/esm/scripts/run-codex-prompts/testing/runTestBefore.d.ts +24 -0
  66. package/esm/scripts/run-codex-prompts/ui/buildRunUiFrameShared.d.ts +1 -0
  67. package/esm/scripts/verify-prompts/verify-prompts.d.ts +5 -0
  68. package/esm/src/book-2.0/book-language-documentation/BookLanguageManualDictionary.d.ts +1 -15
  69. package/esm/src/book-2.0/book-language-documentation/getBookLanguageManualCommitmentGroups.d.ts +1 -1
  70. package/esm/src/book-2.0/book-language-documentation/renderCommitmentCatalogSection.d.ts +0 -4
  71. package/esm/src/book-components/Chat/utils/$provideServerDomWindow.d.ts +11 -0
  72. package/esm/src/book-components/Chat/utils/renderMarkdown.d.ts +7 -0
  73. package/esm/src/cli/cli-commands/agents-server/buildAgentsServer/createAgentsServerRuntimeEnvironment.d.ts +7 -0
  74. package/esm/src/cli/cli-commands/coder/agentCodingFile.d.ts +2 -3
  75. package/esm/src/cli/cli-commands/coder/ping.d.ts +10 -0
  76. package/esm/src/cli/cli-commands/coder/ping.test.d.ts +1 -0
  77. package/esm/src/cli/cli-commands/coder.d.ts +1 -0
  78. package/esm/src/cli/cli-commands/common/coderGitSyncCliOptions.d.ts +34 -0
  79. package/esm/src/cli/cli-commands/common/coderGitSyncCliOptions.test.d.ts +1 -0
  80. package/esm/src/cli/common/loadPromptsModule.d.ts +16 -0
  81. package/esm/src/llm-providers/anthropic-claude/AnthropicClaudeExecutionTools.d.ts +1 -1
  82. package/esm/src/llm-providers/azure-openai/AzureOpenAiExecutionTools.d.ts +1 -1
  83. package/esm/src/llm-providers/openai/OpenAiAgentKitExecutionTools.d.ts +1 -1
  84. package/esm/src/llm-providers/openai/OpenAiAgentKitExecutionToolsToolBuilder.d.ts +1 -1
  85. package/esm/src/llm-providers/openai/OpenAiAssistantExecutionToolsStreamRunner.d.ts +1 -1
  86. package/esm/src/llm-providers/openai/OpenAiAssistantExecutionToolsToolRunner.d.ts +1 -1
  87. package/esm/src/llm-providers/openai/OpenAiCompatibleNonChatPromptCaller.d.ts +1 -1
  88. package/esm/src/llm-providers/openai/OpenAiCompatibleRequestManager.d.ts +1 -1
  89. package/esm/src/llm-providers/openai/utils/callOpenAiCompatibleChatModel.d.ts +1 -1
  90. package/esm/src/llm-providers/openai/utils/loadOpenAiAgentsModule.d.ts +203 -0
  91. package/esm/src/llm-providers/openai/utils/uploadFilesToOpenAi.d.ts +1 -1
  92. package/esm/src/utils/misc/createLazyModuleLoader.d.ts +14 -0
  93. package/esm/src/version.d.ts +1 -1
  94. package/package.json +1 -1
  95. package/src/book-2.0/book-language-documentation/BookLanguageManualDictionary.ts +1 -15
  96. package/src/book-2.0/book-language-documentation/bookLanguageDocumentationExamples.ts +1 -2
  97. package/src/book-2.0/book-language-documentation/createStandaloneBookLanguageMarkdown.ts +92 -32
  98. package/src/book-2.0/book-language-documentation/czechBookLanguageManualDictionary.ts +16 -39
  99. package/src/book-2.0/book-language-documentation/englishBookLanguageManualDictionary.ts +16 -36
  100. package/src/book-2.0/book-language-documentation/getBookLanguageManualCommitmentGroups.ts +9 -1
  101. package/src/book-2.0/book-language-documentation/renderCommitmentCatalogSection.ts +4 -51
  102. package/src/book-2.0/book-language-documentation/renderGroupedCommitmentDocumentationMarkdown.ts +291 -4
  103. package/src/book-3.0/LiteAgent.ts +11 -9
  104. package/src/book-components/Chat/utils/$provideServerDomWindow.ts +77 -0
  105. package/src/book-components/Chat/utils/renderMarkdown.ts +135 -32
  106. package/src/cli/cli-commands/agents-server/buildAgentsServer/createAgentsServerRuntimeEnvironment.ts +14 -0
  107. package/src/cli/cli-commands/agents-server/buildAgentsServer/ensureAgentsServerBuild.ts +1 -0
  108. package/src/cli/cli-commands/agents-server/startAgentsServer/createLocalAgentRunOptions.ts +1 -0
  109. package/src/cli/cli-commands/coder/add.ts +40 -12
  110. package/src/cli/cli-commands/coder/agentCodingFile.ts +6 -129
  111. package/src/cli/cli-commands/coder/generate-boilerplates.ts +31 -5
  112. package/src/cli/cli-commands/coder/getDefaultCoderPackageJsonScripts.ts +1 -1
  113. package/src/cli/cli-commands/coder/init.ts +27 -1
  114. package/src/cli/cli-commands/coder/initializeCoderProjectConfiguration.ts +1 -4
  115. package/src/cli/cli-commands/coder/ping.ts +72 -0
  116. package/src/cli/cli-commands/coder/run.ts +25 -2
  117. package/src/cli/cli-commands/coder/verify.ts +27 -12
  118. package/src/cli/cli-commands/coder.ts +4 -0
  119. package/src/cli/cli-commands/common/coderGitSyncCliOptions.ts +78 -0
  120. package/src/cli/cli-commands/run/prepareRunCommandResources.ts +2 -1
  121. package/src/cli/cli-commands/run/resolveRunInputParameters.ts +2 -1
  122. package/src/cli/cli-commands/runInteractiveChatbot.ts +2 -1
  123. package/src/cli/common/$provideLlmToolsForCli.ts +2 -1
  124. package/src/cli/common/loadPromptsModule.ts +13 -0
  125. package/src/conversion/archive/loadArchive.ts +2 -1
  126. package/src/conversion/archive/loadJsZipModule.ts +10 -0
  127. package/src/conversion/archive/saveArchive.ts +2 -1
  128. package/src/llm-providers/anthropic-claude/AnthropicClaudeExecutionTools.ts +13 -1
  129. package/src/llm-providers/azure-openai/AzureOpenAiExecutionTools.ts +13 -1
  130. package/src/llm-providers/openai/OpenAiAgentKitExecutionTools.ts +6 -2
  131. package/src/llm-providers/openai/OpenAiAgentKitExecutionToolsToolBuilder.ts +7 -5
  132. package/src/llm-providers/openai/OpenAiAssistantExecutionTools.ts +1 -1
  133. package/src/llm-providers/openai/OpenAiAssistantExecutionToolsStreamRunner.ts +1 -1
  134. package/src/llm-providers/openai/OpenAiAssistantExecutionToolsToolRunner.ts +1 -1
  135. package/src/llm-providers/openai/OpenAiCompatibleNonChatPromptCaller.ts +1 -1
  136. package/src/llm-providers/openai/OpenAiCompatibleRequestManager.ts +12 -1
  137. package/src/llm-providers/openai/utils/callOpenAiCompatibleChatModel.ts +1 -1
  138. package/src/llm-providers/openai/utils/loadOpenAiAgentsModule.ts +11 -0
  139. package/src/llm-providers/openai/utils/uploadFilesToOpenAi.ts +1 -1
  140. package/src/other/templates/getTemplatesPipelineCollection.ts +731 -923
  141. package/src/remote-server/createRemoteClient.ts +12 -1
  142. package/src/scrapers/website/WebsiteScraper.ts +22 -2
  143. package/src/utils/agent-message-runtime/resolveAgentMessageRuntimeActivity.ts +101 -0
  144. package/src/utils/misc/createLazyModuleLoader.ts +27 -0
  145. package/src/version.ts +2 -2
  146. package/src/versions.txt +2 -1
  147. package/umd/index.umd.js +1180 -342
  148. package/umd/index.umd.js.map +1 -1
  149. package/umd/scripts/run-codex-prompts/common/runGoScript/scriptExecutionLog.d.ts +7 -0
  150. package/umd/scripts/run-codex-prompts/git/coderGitSync.d.ts +43 -0
  151. package/umd/scripts/run-codex-prompts/git/commitChanges.d.ts +3 -0
  152. package/umd/scripts/run-codex-prompts/main/resolvePromptRunner.d.ts +8 -1
  153. package/umd/scripts/run-codex-prompts/ping/buildCoderPingPrompt.d.ts +20 -0
  154. package/umd/scripts/run-codex-prompts/ping/extractCoderPingAnswer.d.ts +9 -0
  155. package/umd/scripts/run-codex-prompts/ping/pingCoderHarness.d.ts +23 -0
  156. package/umd/scripts/run-codex-prompts/ping/printCoderPingResult.d.ts +5 -0
  157. package/umd/scripts/run-codex-prompts/prompts/findNextTodoPrompt.d.ts +2 -1
  158. package/umd/scripts/run-codex-prompts/prompts/isPromptCompatibleWithRunner.d.ts +27 -0
  159. package/umd/scripts/run-codex-prompts/prompts/listRunnablePrompts.d.ts +2 -1
  160. package/umd/scripts/run-codex-prompts/prompts/listUpcomingTasks.d.ts +2 -1
  161. package/umd/scripts/run-codex-prompts/prompts/replacePromptTodoStatusLine.d.ts +7 -0
  162. package/umd/scripts/run-codex-prompts/testing/TestBeforeMode.d.ts +16 -0
  163. package/umd/scripts/run-codex-prompts/testing/createTestBeforeRepairPrompt.d.ts +9 -0
  164. package/umd/scripts/run-codex-prompts/testing/limitTestOutput.d.ts +4 -0
  165. package/umd/scripts/run-codex-prompts/testing/runPromptTestCommand.d.ts +1 -2
  166. package/umd/scripts/run-codex-prompts/testing/runTestBefore.d.ts +24 -0
  167. package/umd/scripts/run-codex-prompts/ui/buildRunUiFrameShared.d.ts +1 -0
  168. package/umd/scripts/verify-prompts/verify-prompts.d.ts +5 -0
  169. package/umd/src/book-2.0/book-language-documentation/BookLanguageManualDictionary.d.ts +1 -15
  170. package/umd/src/book-2.0/book-language-documentation/getBookLanguageManualCommitmentGroups.d.ts +1 -1
  171. package/umd/src/book-2.0/book-language-documentation/renderCommitmentCatalogSection.d.ts +0 -4
  172. package/umd/src/book-components/Chat/utils/$provideServerDomWindow.d.ts +11 -0
  173. package/umd/src/book-components/Chat/utils/renderMarkdown.d.ts +7 -0
  174. package/umd/src/cli/cli-commands/agents-server/buildAgentsServer/createAgentsServerRuntimeEnvironment.d.ts +7 -0
  175. package/umd/src/cli/cli-commands/coder/agentCodingFile.d.ts +2 -3
  176. package/umd/src/cli/cli-commands/coder/ping.d.ts +10 -0
  177. package/umd/src/cli/cli-commands/coder/ping.test.d.ts +1 -0
  178. package/umd/src/cli/cli-commands/coder.d.ts +1 -0
  179. package/umd/src/cli/cli-commands/common/coderGitSyncCliOptions.d.ts +34 -0
  180. package/umd/src/cli/cli-commands/common/coderGitSyncCliOptions.test.d.ts +1 -0
  181. package/umd/src/cli/common/loadPromptsModule.d.ts +16 -0
  182. package/umd/src/llm-providers/anthropic-claude/AnthropicClaudeExecutionTools.d.ts +1 -1
  183. package/umd/src/llm-providers/azure-openai/AzureOpenAiExecutionTools.d.ts +1 -1
  184. package/umd/src/llm-providers/openai/OpenAiAgentKitExecutionTools.d.ts +1 -1
  185. package/umd/src/llm-providers/openai/OpenAiAgentKitExecutionToolsToolBuilder.d.ts +1 -1
  186. package/umd/src/llm-providers/openai/OpenAiAssistantExecutionToolsStreamRunner.d.ts +1 -1
  187. package/umd/src/llm-providers/openai/OpenAiAssistantExecutionToolsToolRunner.d.ts +1 -1
  188. package/umd/src/llm-providers/openai/OpenAiCompatibleNonChatPromptCaller.d.ts +1 -1
  189. package/umd/src/llm-providers/openai/OpenAiCompatibleRequestManager.d.ts +1 -1
  190. package/umd/src/llm-providers/openai/utils/callOpenAiCompatibleChatModel.d.ts +1 -1
  191. package/umd/src/llm-providers/openai/utils/loadOpenAiAgentsModule.d.ts +203 -0
  192. package/umd/src/llm-providers/openai/utils/uploadFilesToOpenAi.d.ts +1 -1
  193. package/umd/src/utils/misc/createLazyModuleLoader.d.ts +14 -0
  194. package/umd/src/version.d.ts +1 -1
  195. package/apps/agents-server/src/app/api/onboarding/draft/route.ts +0 -23
  196. package/apps/agents-server/src/components/NewAgentDialog/ManGoNewAgentWizard/components/BookLanguagePanel.tsx +0 -125
  197. package/apps/agents-server/src/components/NewAgentDialog/ManGoNewAgentWizard/components/MarkdownBookEditor.tsx +0 -154
  198. package/apps/agents-server/src/components/NewAgentDialog/ManGoNewAgentWizard/components/MarkdownPreview.tsx +0 -188
  199. package/apps/agents-server/src/components/NewAgentDialog/ManGoNewAgentWizard/services/draftService.ts +0 -32
@@ -9,6 +9,7 @@ import type { Converter as ShowdownConverter } from 'showdown';
9
9
  import showdown from 'showdown';
10
10
  import type { string_html, string_markdown } from '../../../types/string_markdown';
11
11
  import { TODO_USE } from '../../../utils/organization/TODO_USE';
12
+ import { $provideServerDomWindow } from './$provideServerDomWindow';
12
13
  import { createCitationMarkerRegex, parseCitationMarker } from './parseCitationMarker';
13
14
 
14
15
  /**
@@ -218,13 +219,6 @@ let browserMarkdownSanitizer: DomPurifyInstance | null = null;
218
219
  */
219
220
  let serverMarkdownSanitizer: DomPurifyInstance | null = null;
220
221
 
221
- /**
222
- * Shared JSDOM window backing the server-side DOMPurify instance.
223
- *
224
- * @private utility of `renderMarkdown`
225
- */
226
- let serverMarkdownSanitizerWindow: DomPurifyWindowLike | null = null;
227
-
228
222
  /**
229
223
  * Pattern matching CODE FENCE.
230
224
  */
@@ -272,6 +266,16 @@ const DETAILS_PLACEHOLDER_WRAPPED_REGEX = new RegExp(`<p>\\s*(${DETAILS_PLACEHOL
272
266
  */
273
267
  const INLINE_REFERENCE_REGEX = /\[\[([^\]\r\n]+?)\]\]/g;
274
268
 
269
+ /**
270
+ * Pattern matching ordinary markdown links that can be promoted to inline reference chips.
271
+ *
272
+ * Images are intentionally captured separately and left unchanged by the replacement helper.
273
+ *
274
+ * @private utility of `renderMarkdown`
275
+ */
276
+ const MARKDOWN_INLINE_REFERENCE_LINK_REGEX =
277
+ /(!?)\[([^\]\r\n]*)\]\(\s*(<[^>\r\n]+>|[^)\s]+)(?:\s+(?:"[^"\r\n]*"|'[^'\r\n]*'|\([^)]*\)))?\s*\)/g;
278
+
275
279
  /**
276
280
  * Markdown patterns that are strong enough to identify content as markdown.
277
281
  */
@@ -339,6 +343,14 @@ export type MarkdownInlineReference = {
339
343
  */
340
344
  readonly href: string;
341
345
 
346
+ /**
347
+ * Markdown link destination prefixes that should render as this reference as well.
348
+ *
349
+ * This supports legacy links such as an Agents Server project file URL while keeping
350
+ * `reference` as the canonical `[[project]]` token.
351
+ */
352
+ readonly sourceHrefPrefixes?: ReadonlyArray<string>;
353
+
342
354
  /**
343
355
  * Optional hover title for the rendered reference.
344
356
  */
@@ -528,21 +540,6 @@ function createMarkdownSanitizer(sanitizerWindow: DomPurifyWindowLike): DomPurif
528
540
  return markdownSanitizer;
529
541
  }
530
542
 
531
- /**
532
- * Lazily creates the JSDOM window used by server-side markdown sanitization.
533
- *
534
- * @private utility of `renderMarkdown`
535
- */
536
- function getServerMarkdownSanitizerWindow(): DomPurifyWindowLike {
537
- if (!serverMarkdownSanitizerWindow) {
538
- // eslint-disable-next-line @typescript-eslint/no-var-requires
539
- const { JSDOM } = require('jsdom') as typeof import('jsdom');
540
- serverMarkdownSanitizerWindow = new JSDOM('').window as unknown as DomPurifyWindowLike;
541
- }
542
-
543
- return serverMarkdownSanitizerWindow;
544
- }
545
-
546
543
  /**
547
544
  * Returns the shared DOMPurify instance appropriate for the current runtime.
548
545
  *
@@ -555,7 +552,7 @@ function getMarkdownSanitizer(): DomPurifyInstance {
555
552
  return browserMarkdownSanitizer;
556
553
  }
557
554
 
558
- serverMarkdownSanitizer ??= createMarkdownSanitizer(getServerMarkdownSanitizerWindow());
555
+ serverMarkdownSanitizer ??= createMarkdownSanitizer($provideServerDomWindow());
559
556
 
560
557
  return serverMarkdownSanitizer;
561
558
  }
@@ -699,11 +696,12 @@ const CHAT_MARKDOWN_CONVERTER = createChatMarkdownConverter();
699
696
  * outer `<details>` and optional `<summary>` markup untouched.
700
697
  *
701
698
  * @param detailsBlock - Raw `<details>...</details>` HTML captured from markdown.
699
+ * @param options - Markdown rendering options to reuse for the details body.
702
700
  * @returns `<details>` HTML whose body has been converted from markdown to HTML.
703
701
  *
704
702
  * @private utility of `renderMarkdown`
705
703
  */
706
- function renderDetailsBlock(detailsBlock: string): string_html {
704
+ function renderDetailsBlock(detailsBlock: string, options?: RenderMarkdownOptions): string_html {
707
705
  const openTagMatch = detailsBlock.match(/^<details\b[^>]*>/i);
708
706
  const closeTagMatch = detailsBlock.match(/<\/details\s*>$/i);
709
707
 
@@ -717,7 +715,7 @@ function renderDetailsBlock(detailsBlock: string): string_html {
717
715
  const summaryMatch = innerContent.match(/^(\s*<summary\b[^>]*>[\s\S]*?<\/summary\s*>)([\s\S]*)$/i);
718
716
  const summaryHtml = summaryMatch?.[1] ?? '';
719
717
  const bodyMarkdown = (summaryMatch?.[2] ?? innerContent) as string_markdown;
720
- const renderedBody = renderMarkdown(bodyMarkdown);
718
+ const renderedBody = renderMarkdown(bodyMarkdown, options);
721
719
 
722
720
  return `${openTag}${summaryHtml}${renderedBody}${closeTag}` as string_html;
723
721
  }
@@ -761,17 +759,18 @@ function maskMarkdownCodeSegments(markdown: string_markdown): MaskedCodeSegments
761
759
  * processes their content.
762
760
  *
763
761
  * @param markdown - Markdown text that may contain raw HTML `<details>` blocks.
762
+ * @param options - Markdown rendering options to reuse for the details body.
764
763
  * @returns Masked markdown and a restore helper that returns `string_html`.
765
764
  *
766
765
  * @private utility of `renderMarkdown`
767
766
  */
768
- function maskDetailsBlocks(markdown: string_markdown): MaskedDetailsBlocksResult {
767
+ function maskDetailsBlocks(markdown: string_markdown, options?: RenderMarkdownOptions): MaskedDetailsBlocksResult {
769
768
  const blocks: string_html[] = [];
770
769
 
771
770
  DETAILS_BLOCK_REGEX.lastIndex = 0;
772
771
  const masked = markdown.replace(DETAILS_BLOCK_REGEX, (match) => {
773
772
  const placeholder = `${DETAILS_PLACEHOLDER_PREFIX}${blocks.length}__`;
774
- blocks.push(renderDetailsBlock(match));
773
+ blocks.push(renderDetailsBlock(match, options));
775
774
  return placeholder;
776
775
  }) as string_markdown;
777
776
 
@@ -885,6 +884,93 @@ function createMarkdownInlineReferenceByKey(
885
884
  return referenceByKey;
886
885
  }
887
886
 
887
+ /**
888
+ * Returns whether a href starts with a configured source href prefix.
889
+ *
890
+ * @param href - Markdown link destination.
891
+ * @param sourceHrefPrefix - Configured source href prefix.
892
+ * @returns Whether the href belongs to the source prefix.
893
+ *
894
+ * @private utility of `renderMarkdown`
895
+ */
896
+ function doesHrefStartWithSourceHrefPrefix(href: string, sourceHrefPrefix: string): boolean {
897
+ if (href === sourceHrefPrefix) {
898
+ return true;
899
+ }
900
+
901
+ const normalizedSourceHrefPrefix = sourceHrefPrefix.endsWith('/') ? sourceHrefPrefix : `${sourceHrefPrefix}/`;
902
+
903
+ return href.startsWith(normalizedSourceHrefPrefix);
904
+ }
905
+
906
+ /**
907
+ * Returns a comparable path for an absolute href when the configured source prefix is relative.
908
+ *
909
+ * @param href - Href to normalize.
910
+ * @returns Absolute URL pathname or the original href when it is relative/invalid.
911
+ *
912
+ * @private utility of `renderMarkdown`
913
+ */
914
+ function resolveAbsoluteHrefPath(href: string): string {
915
+ try {
916
+ return new URL(href).pathname;
917
+ } catch {
918
+ return href;
919
+ }
920
+ }
921
+
922
+ /**
923
+ * Returns whether one markdown link destination belongs to one inline reference.
924
+ *
925
+ * Relative project paths also match absolute URLs on the current server, which keeps
926
+ * server-generated relative links and model-generated absolute links consistent.
927
+ *
928
+ * @param reference - Candidate inline reference.
929
+ * @param href - Markdown link destination.
930
+ * @returns Whether the href should render as the reference chip.
931
+ *
932
+ * @private utility of `renderMarkdown`
933
+ */
934
+ function doesMarkdownInlineReferenceMatchHref(reference: MarkdownInlineReference, href: string): boolean {
935
+ const normalizedHref = href.trim();
936
+
937
+ return (reference.sourceHrefPrefixes || []).some((sourceHrefPrefix) => {
938
+ const normalizedSourceHrefPrefix = sourceHrefPrefix.trim();
939
+ if (!normalizedSourceHrefPrefix) {
940
+ return false;
941
+ }
942
+
943
+ if (doesHrefStartWithSourceHrefPrefix(normalizedHref, normalizedSourceHrefPrefix)) {
944
+ return true;
945
+ }
946
+
947
+ const isRelativeSourceHrefPrefix = !/^[a-z][a-z0-9+.-]*:/i.test(normalizedSourceHrefPrefix);
948
+ const isAbsoluteHref = /^[a-z][a-z0-9+.-]*:/i.test(normalizedHref);
949
+
950
+ return (
951
+ isRelativeSourceHrefPrefix &&
952
+ isAbsoluteHref &&
953
+ doesHrefStartWithSourceHrefPrefix(resolveAbsoluteHrefPath(normalizedHref), normalizedSourceHrefPrefix)
954
+ );
955
+ });
956
+ }
957
+
958
+ /**
959
+ * Finds the inline reference represented by a markdown link destination.
960
+ *
961
+ * @param references - Inline references available to the markdown renderer.
962
+ * @param href - Markdown link destination.
963
+ * @returns Matching reference or `undefined` when the href is unrelated.
964
+ *
965
+ * @private utility of `renderMarkdown`
966
+ */
967
+ function findMarkdownInlineReferenceByHref(
968
+ references: ReadonlyArray<MarkdownInlineReference>,
969
+ href: string,
970
+ ): MarkdownInlineReference | undefined {
971
+ return references.find((reference) => doesMarkdownInlineReferenceMatchHref(reference, href));
972
+ }
973
+
888
974
  /**
889
975
  * Renders one inline reference as raw HTML that is sanitized by the shared markdown sanitizer.
890
976
  *
@@ -977,11 +1063,28 @@ function applyMarkdownInlineReferences(markdown: string_markdown, options?: Rend
977
1063
  return markdown;
978
1064
  }
979
1065
 
980
- return markdown.replace(INLINE_REFERENCE_REGEX, (match, rawReference: string) => {
981
- const reference = referenceByKey.get(normalizeMarkdownInlineReferenceKey(rawReference));
1066
+ const markdownWithInlineReferenceTokens = markdown.replace(
1067
+ INLINE_REFERENCE_REGEX,
1068
+ (match, rawReference: string) => {
1069
+ const reference = referenceByKey.get(normalizeMarkdownInlineReferenceKey(rawReference));
982
1070
 
983
- return reference ? renderMarkdownInlineReferenceHtml(reference, className) : match;
984
- }) as string_markdown;
1071
+ return reference ? renderMarkdownInlineReferenceHtml(reference, className) : match;
1072
+ },
1073
+ );
1074
+
1075
+ return markdownWithInlineReferenceTokens.replace(
1076
+ MARKDOWN_INLINE_REFERENCE_LINK_REGEX,
1077
+ (match, imageMarker: string, _linkLabel: string, rawHref: string) => {
1078
+ if (imageMarker) {
1079
+ return match;
1080
+ }
1081
+
1082
+ const href = rawHref.replace(/^<|>$/g, '');
1083
+ const reference = findMarkdownInlineReferenceByHref(references, href);
1084
+
1085
+ return reference ? renderMarkdownInlineReferenceHtml(reference, className) : match;
1086
+ },
1087
+ ) as string_markdown;
985
1088
  }
986
1089
 
987
1090
  /**
@@ -1026,7 +1129,7 @@ export function renderMarkdown(markdown: string_markdown, options?: RenderMarkdo
1026
1129
 
1027
1130
  try {
1028
1131
  const normalizedMarkdown = normalizeMarkdownSublists(markdown);
1029
- const { masked: maskedMarkdown, restore: restoreDetails } = maskDetailsBlocks(normalizedMarkdown);
1132
+ const { masked: maskedMarkdown, restore: restoreDetails } = maskDetailsBlocks(normalizedMarkdown, options);
1030
1133
  const { masked: codeMaskedMarkdown, restore: restoreCode } = maskMarkdownCodeSegments(maskedMarkdown);
1031
1134
  const referencedMarkdown = applyMarkdownInlineReferences(codeMaskedMarkdown, options);
1032
1135
  const inlineReferenceMarkdown = restoreCode(referencedMarkdown);
@@ -22,6 +22,14 @@ export const PTBK_AGENTS_SERVER_BUILD_WORKER_COUNT_ENV = 'PTBK_AGENTS_SERVER_BUI
22
22
  */
23
23
  export const PTBK_AGENTS_SERVER_IGNORE_NEXT_VALIDATION_ENV = 'PTBK_AGENTS_SERVER_IGNORE_NEXT_VALIDATION';
24
24
 
25
+ /**
26
+ * Environment variable that disables throwaway webpack filesystem caches for CLI-owned production builds.
27
+ *
28
+ * @private internal constant of `buildAgentsServer`
29
+ */
30
+ export const PTBK_AGENTS_SERVER_DISABLE_WEBPACK_FILESYSTEM_CACHE_ENV =
31
+ 'PTBK_AGENTS_SERVER_DISABLE_WEBPACK_FILESYSTEM_CACHE';
32
+
25
33
  /**
26
34
  * Conservative Next.js build worker count used by CLI-owned Agents Server production builds.
27
35
  *
@@ -41,6 +49,7 @@ export function createAgentsServerRuntimeEnvironment(
41
49
  nodeModulesPath: string,
42
50
  options: {
43
51
  readonly isNextValidationIgnored?: boolean;
52
+ readonly isWebpackFilesystemCacheDisabled?: boolean;
44
53
  } = {},
45
54
  ): NodeJS.ProcessEnv {
46
55
  return {
@@ -54,6 +63,11 @@ export function createAgentsServerRuntimeEnvironment(
54
63
  [PTBK_AGENTS_SERVER_IGNORE_NEXT_VALIDATION_ENV]: 'true',
55
64
  }
56
65
  : {}),
66
+ ...(options.isWebpackFilesystemCacheDisabled
67
+ ? {
68
+ [PTBK_AGENTS_SERVER_DISABLE_WEBPACK_FILESYSTEM_CACHE_ENV]: 'true',
69
+ }
70
+ : {}),
57
71
  };
58
72
  }
59
73
 
@@ -30,6 +30,7 @@ export async function ensureAgentsServerBuild(
30
30
  });
31
31
  const buildEnvironment = createAgentsServerRuntimeEnvironment(environment, preparedRuntime.nodeModulesPath, {
32
32
  isNextValidationIgnored: preparedRuntime.isAppPathMaterialized,
33
+ isWebpackFilesystemCacheDisabled: true,
33
34
  });
34
35
 
35
36
  if (
@@ -25,5 +25,6 @@ export function createLocalAgentRunOptions(
25
25
  autoClone: false,
26
26
  maxMessageProcessingFailures: localAgentRunnerLimits.maxFailedAttempts,
27
27
  maxParallelMessages: localAgentRunnerLimits.maxParallelMessages,
28
+ isMachineReadableProgressEnabled: true,
28
29
  };
29
30
  }
@@ -4,12 +4,18 @@ import type {
4
4
  } from 'commander';
5
5
  import { mkdirSync, writeFileSync } from 'fs';
6
6
  import { join } from 'path';
7
- import prompts from 'prompts';
8
7
  import { spaceTrim } from 'spacetrim';
9
8
  import { NotAllowed } from '../../../errors/NotAllowed';
10
9
  import { ParseError } from '../../../errors/ParseError';
11
10
  import { normalizeToKebabCase } from '../../../utils/normalization/normalize-to-kebab-case';
12
11
  import type { $side_effect } from '../../../utils/organization/$side_effect';
12
+ import { loadPromptsModule } from '../../common/loadPromptsModule';
13
+ import type { CoderGitSyncCliOptions } from '../common/coderGitSyncCliOptions';
14
+ import {
15
+ addCoderGitSyncOptions,
16
+ CODER_GIT_SYNC_DESCRIPTION,
17
+ normalizeCoderGitSyncCliOptions,
18
+ } from '../common/coderGitSyncCliOptions';
13
19
  import { handleActionErrors } from '../common/handleActionErrors';
14
20
  import {
15
21
  buildCoderPromptSection,
@@ -49,15 +55,19 @@ const FALLBACK_PROMPT_SLUG = 'prompt';
49
55
  export function $initializeCoderAddCommand(program: Program): $side_effect {
50
56
  const command = program.command('add');
51
57
  command.description(
52
- spaceTrim(`
53
- Add one ready-to-run prompt file to the queue
58
+ spaceTrim(
59
+ (block) => `
60
+ Add one ready-to-run prompt file to the queue
54
61
 
55
- Provide the description as an argument, pipe it through stdin, or run without arguments to type it interactively:
56
- - \`ptbk coder add "some new feature"\`
57
- - \`ptbk coder add --priority 1 "some new feature"\`
58
- - \`ptbk coder add <<EOF ... EOF\`
59
- - \`ptbk coder add\`
60
- `),
62
+ Provide the description as an argument, pipe it through stdin, or run without arguments to type it interactively:
63
+ - \`ptbk coder add "some new feature"\`
64
+ - \`ptbk coder add --priority 1 "some new feature"\`
65
+ - \`ptbk coder add <<EOF ... EOF\`
66
+ - \`ptbk coder add\`
67
+
68
+ ${block(CODER_GIT_SYNC_DESCRIPTION)}
69
+ `,
70
+ ),
61
71
  );
62
72
 
63
73
  command.argument('[description]', 'Plain-language description of the feature or task to implement');
@@ -77,22 +87,39 @@ export function $initializeCoderAddCommand(program: Program): $side_effect {
77
87
  .join(', ')}) or a markdown file path relative to the current project root.
78
88
  `),
79
89
  );
90
+ addCoderGitSyncOptions(command);
80
91
 
81
92
  command.action(
82
93
  handleActionErrors(async (descriptionArgument: string | undefined, cliOptions) => {
83
94
  const { priority, template: templateOption } = cliOptions as {
84
95
  readonly priority: number;
85
96
  readonly template?: string;
86
- };
97
+ } & CoderGitSyncCliOptions;
98
+
99
+ const gitSync = normalizeCoderGitSyncCliOptions(cliOptions as CoderGitSyncCliOptions);
100
+ const projectPath = process.cwd();
87
101
 
88
102
  const description = await resolveCoderPromptDescription(descriptionArgument);
89
103
 
90
- await addCoderPrompt({
91
- projectPath: process.cwd(),
104
+ // Note: Import the git synchronization dynamically to keep the CLI fast for runs without `--commit`
105
+ const { $commitCoderChanges, $pullCoderChanges } = await import(
106
+ '../../../../scripts/run-codex-prompts/git/coderGitSync'
107
+ );
108
+
109
+ await $pullCoderChanges({ gitSync, projectPath });
110
+
111
+ const { /* filePath,*/ emojiTag } = await addCoderPrompt({
112
+ projectPath,
92
113
  description,
93
114
  priority,
94
115
  templateOption,
95
116
  });
117
+
118
+ await $commitCoderChanges({
119
+ gitSync,
120
+ projectPath,
121
+ commitMessage: `${emojiTag} Add prompt`,
122
+ });
96
123
  }),
97
124
  );
98
125
  }
@@ -216,6 +243,7 @@ async function resolveCoderPromptDescription(descriptionArgument: string | undef
216
243
  return standardInputDescription;
217
244
  }
218
245
 
246
+ const { default: prompts } = await loadPromptsModule();
219
247
  const response = await prompts({
220
248
  type: 'text',
221
249
  name: 'description',
@@ -1,13 +1,5 @@
1
1
  import { spaceTrim } from 'spacetrim';
2
- import { AGENTS_FILE_PATH } from './agentsFile';
3
- import {
4
- getDefaultCoderProjectPromptTemplateDefinitions,
5
- getDefaultCoderPromptTemplateDefinitions,
6
- PROMPTS_DIRECTORY_PATH,
7
- PROMPTS_DONE_DIRECTORY_PATH,
8
- PROMPTS_TEMPLATES_DIRECTORY_PATH,
9
- } from './boilerplateTemplates';
10
- import { formatDisplayPath } from './formatDisplayPath';
2
+ import { string_markdown } from '../../../types/typeAliases';
11
3
 
12
4
  /**
13
5
  * Relative path to the Promptbook Coder quick-reference file initialized in project roots.
@@ -21,127 +13,12 @@ export const AGENT_CODING_FILE_PATH = 'AGENT_CODING.md';
21
13
  *
22
14
  * @private internal utility of `ptbk coder`
23
15
  */
24
- export function getDefaultCoderAgentCodingFileContent({
25
- packageJsonScripts,
26
- }: {
27
- readonly packageJsonScripts: Readonly<Record<string, string>>;
28
- }): string {
29
- return spaceTrim(
30
- (block) => `
31
- # Promptbook Coder quick reference
16
+ export function getDefaultCoderAgentCodingFileContent(): string_markdown {
17
+ return spaceTrim(`
18
+ # ✨ Promptbook Coder agent coding
32
19
 
33
- This project is prepared for the \`ptbk coder\` workflow. Promptbook Coder does not create a new model on its own; it orchestrates coding agents such as GitHub Copilot, OpenAI Codex, Claude Code, Opencode, Cline, and Gemini CLI through prompt files in \`${formatDisplayPath(
34
- PROMPTS_DIRECTORY_PATH,
35
- )}/\`.
36
-
37
- ## Workflow
38
- 1. Put repository-wide coding rules into \`${AGENTS_FILE_PATH}\`. The default \`npm run coder:run\` script already passes \`--context ${AGENTS_FILE_PATH}\`.
39
- 2. Create or customize prompt templates in \`${formatDisplayPath(
40
- PROMPTS_TEMPLATES_DIRECTORY_PATH,
41
- )}/\`. ${buildStarterTemplateSentence()}
42
- 3. Generate prompt files with \`npm run coder:generate-boilerplates\` or \`ptbk coder generate-boilerplates --template <template> --count <count>\`. To append a single ready-to-run prompt straight from a description, use \`npm run coder:add\` or \`ptbk coder add "some new feature"\`.
43
- 4. Replace every \`@@@\`, keep drafts as \`[-]\`, and switch prompts to \`[ ]\` when they are ready to run. Completed prompts are marked \`[x]\`.
44
- 5. Run \`npm run coder:run\` to execute the next ready prompt with the configured coding agent.
45
- 6. Use \`npm run coder:verify\` to archive finished prompts into \`${formatDisplayPath(
46
- PROMPTS_DONE_DIRECTORY_PATH,
47
- )}/\` and append repair follow-up prompts when more work is needed.
48
- 7. Use \`ptbk coder find-refactor-candidates\` when you want Promptbook to suggest refactor prompts automatically.
49
-
50
- ## Templates
51
- - Project-owned templates created by \`ptbk coder init\`: ${formatInlineCodeList(
52
- getDefaultCoderProjectPromptTemplateDefinitions().map(({ relativeFilePath }) =>
53
- formatDisplayPath(relativeFilePath),
54
- ),
55
- )}
56
- - Built-in \`--template\` aliases: ${formatInlineCodeList(
57
- getDefaultCoderPromptTemplateDefinitions().map(({ id }) => id),
58
- )}
59
- - To add a custom template, create a markdown file such as \`${formatDisplayPath(
60
- PROMPTS_TEMPLATES_DIRECTORY_PATH,
61
- )}/backend.md\`.
62
- - To use a project template, run \`ptbk coder generate-boilerplates --template ${formatDisplayPath(
63
- PROMPTS_TEMPLATES_DIRECTORY_PATH,
64
- )}/backend.md\`.
65
- - Keep shared repository rules in \`${AGENTS_FILE_PATH}\` and recurring task-family rules in template files so individual prompt files stay focused on the actual task.
66
-
67
- ## Created npm scripts
68
- | Script | Purpose |
69
- | --- | --- |
70
- ${block(buildPackageJsonScriptTableLines(packageJsonScripts).join('\n'))}
71
-
72
- ## Customizing the workflow
73
- - Edit \`package.json\` if you want \`npm run coder:run\` to use another coding agent, model, thinking level, context file, or wait mode.
74
- - Use direct CLI commands when you need one-off flags such as \`--min-priority\`, \`--max-priority\`, \`--ignore-git-changes\`, \`--no-commit\`, \`--dry-run\`, \`--test\`, \`--allow-credits\`, or \`--auto-migrate\`.
75
- - Use \`ptbk coder --help\` and \`ptbk coder <command> --help\` for the full CLI reference.
76
- `,
77
- );
78
- }
79
-
80
- /**
81
- * Builds the sentence describing the starter templates created during initialization.
82
- */
83
- function buildStarterTemplateSentence(): string {
84
- const starterTemplatePaths = getDefaultCoderProjectPromptTemplateDefinitions().map(({ relativeFilePath }) =>
85
- formatDisplayPath(relativeFilePath),
86
- );
87
-
88
- if (starterTemplatePaths.length === 1) {
89
- return `The starter project template created by \`ptbk coder init\` is \`${starterTemplatePaths[0]}\`.`;
90
- }
91
-
92
- return `The starter project templates created by \`ptbk coder init\` are ${formatInlineCodeList(
93
- starterTemplatePaths,
94
- )}.`;
95
- }
96
-
97
- /**
98
- * Builds the markdown table rows describing the initialized npm scripts.
99
- */
100
- function buildPackageJsonScriptTableLines(packageJsonScripts: Readonly<Record<string, string>>): Array<string> {
101
- return Object.entries(packageJsonScripts).map(
102
- ([scriptName, scriptCommand]) =>
103
- `| \`npm run ${scriptName}\` | ${describeDefaultCoderPackageJsonScript(scriptName, scriptCommand)} |`,
104
- );
105
- }
106
-
107
- /**
108
- * Describes one initialized npm script in human-readable terms.
109
- */
110
- function describeDefaultCoderPackageJsonScript(scriptName: string, scriptCommand: string): string {
111
- if (scriptName === 'coder:generate-boilerplates') {
112
- return `Runs \`${scriptCommand}\` to create new prompt files in \`${formatDisplayPath(
113
- PROMPTS_DIRECTORY_PATH,
114
- )}/\`.`;
115
- }
116
-
117
- if (scriptName === 'coder:add') {
118
- return `Runs \`${scriptCommand}\` to add one ready-to-run prompt file to \`${formatDisplayPath(
119
- PROMPTS_DIRECTORY_PATH,
120
- )}/\` from a plain-language description.`;
121
- }
122
-
123
- if (scriptName === 'coder:run') {
124
- return `Runs \`${scriptCommand}\` to execute the next ready prompt with shared repository context from \`${AGENTS_FILE_PATH}\`.`;
125
- }
126
-
127
- if (scriptName === 'coder:find-refactor-candidates') {
128
- return `Runs \`${scriptCommand}\` to generate prompt candidates for large or crowded files.`;
129
- }
130
-
131
- if (scriptName === 'coder:verify') {
132
- return `Runs \`${scriptCommand}\` to archive verified prompts into \`${formatDisplayPath(
133
- PROMPTS_DONE_DIRECTORY_PATH,
134
- )}/\` and append repair prompts when needed.`;
135
- }
136
-
137
- return `Runs \`${scriptCommand}\`.`;
138
- }
139
-
140
- /**
141
- * Formats one inline code list for human-readable markdown.
142
- */
143
- function formatInlineCodeList(values: ReadonlyArray<string>): string {
144
- return values.map((value) => `\`${value}\``).join(', ');
20
+ This project is using [Promptbook Coder](https://coder.ptbk.io) or run \`ptbk coder\`!
21
+ `);
145
22
  }
146
23
 
147
24
  // Note: [🟡] Code for coder AGENT_CODING file boilerplate [agentCodingFile](src/cli/cli-commands/coder/agentCodingFile.ts) should never be published outside of `@promptbook/cli`
@@ -6,6 +6,12 @@ import { mkdirSync, writeFileSync } from 'fs';
6
6
  import { join } from 'path';
7
7
  import { spaceTrim } from 'spacetrim';
8
8
  import type { $side_effect } from '../../../utils/organization/$side_effect';
9
+ import type { CoderGitSyncCliOptions } from '../common/coderGitSyncCliOptions';
10
+ import {
11
+ addCoderGitSyncOptions,
12
+ CODER_GIT_SYNC_DESCRIPTION,
13
+ normalizeCoderGitSyncCliOptions,
14
+ } from '../common/coderGitSyncCliOptions';
9
15
  import { handleActionErrors } from '../common/handleActionErrors';
10
16
  import {
11
17
  buildCoderPromptSection,
@@ -24,9 +30,13 @@ import {
24
30
  export function $initializeCoderGenerateBoilerplatesCommand(program: Program): $side_effect {
25
31
  const command = program.command('generate-boilerplates');
26
32
  command.description(
27
- spaceTrim(`
28
- Generate prompt boilerplate files with unique emoji tags
29
- `),
33
+ spaceTrim(
34
+ (block) => `
35
+ Generate prompt boilerplate files with unique emoji tags
36
+
37
+ ${block(CODER_GIT_SYNC_DESCRIPTION)}
38
+ `,
39
+ ),
30
40
  );
31
41
 
32
42
  command.option('--count <count>', `Number of prompt boilerplate files to generate`, '5');
@@ -40,22 +50,38 @@ export function $initializeCoderGenerateBoilerplatesCommand(program: Program): $
40
50
  .join(', ')}) or a markdown file path relative to the current project root.
41
51
  `),
42
52
  );
53
+ addCoderGitSyncOptions(command);
43
54
 
44
55
  command.action(
45
56
  handleActionErrors(async (cliOptions) => {
46
57
  const { count: countOption, template: templateOption } = cliOptions as {
47
58
  readonly count: string;
48
59
  readonly template?: string;
49
- };
60
+ } & CoderGitSyncCliOptions;
50
61
 
51
62
  const filesCount = parseFilesCount(countOption);
63
+ const gitSync = normalizeCoderGitSyncCliOptions(cliOptions as CoderGitSyncCliOptions);
64
+ const projectPath = process.cwd();
65
+
66
+ // Note: Import the git synchronization dynamically to keep the CLI fast for runs without `--commit`
67
+ const { $commitCoderChanges, $pullCoderChanges } = await import(
68
+ '../../../../scripts/run-codex-prompts/git/coderGitSync'
69
+ );
70
+
71
+ await $pullCoderChanges({ gitSync, projectPath });
52
72
 
53
73
  await generatePromptBoilerplate({
54
- projectPath: process.cwd(),
74
+ projectPath,
55
75
  filesCount,
56
76
  templateOption,
57
77
  });
58
78
 
79
+ await $commitCoderChanges({
80
+ gitSync,
81
+ projectPath,
82
+ commitMessage: `Prompts ${filesCount}x`,
83
+ });
84
+
59
85
  return process.exit(0);
60
86
  }),
61
87
  );
@@ -5,7 +5,7 @@ const DEFAULT_CODER_PACKAGE_JSON_SCRIPTS = {
5
5
  'coder:generate-boilerplates': 'ptbk coder generate-boilerplates --template ./prompts/templates/common.md',
6
6
  'coder:add': 'ptbk coder add --template ./prompts/templates/common.md',
7
7
  'coder:run':
8
- 'ptbk coder run --harness openai-codex --model gpt-5.5 --thinking-level xhigh --agent agents/developer.book --context AGENTS.md',
8
+ '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',
9
9
  // 'coder:find-refactor-candidates': 'npx ptbk coder find-refactor-candidates',
10
10
  'coder:verify': 'ptbk coder verify',
11
11
  } as const satisfies Readonly<Record<string, string>>;