@promptbook/cli 0.114.0-42 → 0.114.0-48

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 (264) hide show
  1. package/agents/default/copywriter.book +15 -0
  2. package/agents/default/developer.book +3 -0
  3. package/agents/default/lawyer.book +14 -0
  4. package/agents/default/planner.book +16 -0
  5. package/esm/index.es.js +4769 -809
  6. package/esm/index.es.js.map +1 -1
  7. package/esm/scripts/find-fresh-emoji-tags/find-fresh-emoji-tags.d.ts +1 -1
  8. package/esm/scripts/find-refactor-candidates/find-refactor-candidates.d.ts +2 -0
  9. package/esm/scripts/find-refactor-candidates/resolveRefactorCandidateProject.d.ts +3 -1
  10. package/esm/scripts/run-codex-prompts/common/CoderRunControlFeedback.d.ts +1 -1
  11. package/esm/scripts/run-codex-prompts/common/buildCoderRunControlKeyBadge.d.ts +1 -1
  12. package/esm/scripts/run-codex-prompts/common/listenForCoderRunControls.d.ts +3 -2
  13. package/esm/scripts/run-codex-prompts/common/resolveCoderAgent.d.ts +15 -5
  14. package/esm/scripts/run-codex-prompts/common/runGoScript/$spawnLoggedBashScript.d.ts +2 -0
  15. package/esm/scripts/run-codex-prompts/common/runGoScript/captureLiveScriptOutput.d.ts +9 -0
  16. package/esm/scripts/run-codex-prompts/common/runGoScript/createScriptOutputLineReader.d.ts +4 -0
  17. package/esm/scripts/run-codex-prompts/common/runGoScript/resolveShellHereDocumentDelimiter.d.ts +2 -0
  18. package/esm/scripts/run-codex-prompts/common/runGoScript/scriptExecutionLog.d.ts +2 -0
  19. package/esm/scripts/run-codex-prompts/git/coderCommitScope.d.ts +4 -1
  20. package/esm/scripts/run-codex-prompts/git/coderGitSync.d.ts +5 -0
  21. package/esm/scripts/run-codex-prompts/git/commitInitializedAgentBooks.d.ts +2 -1
  22. package/esm/scripts/run-codex-prompts/git/ensureWorkingTreeClean.d.ts +1 -1
  23. package/esm/scripts/run-codex-prompts/isolation/copyCoderIsolationEnvironment.d.ts +1 -1
  24. package/esm/scripts/run-codex-prompts/isolation/createCoderIsolationWorktree.d.ts +2 -0
  25. package/esm/scripts/run-codex-prompts/main/findUnwrittenPrompts.d.ts +2 -0
  26. package/esm/scripts/run-codex-prompts/main/listCoderPrompts.d.ts +2 -0
  27. package/esm/scripts/run-codex-prompts/main/resolvePromptRunner.d.ts +11 -0
  28. package/esm/scripts/run-codex-prompts/prompts/loadPromptFiles.d.ts +10 -2
  29. package/esm/scripts/run-codex-prompts/runners/claude-code/ClaudeCodeRunner.d.ts +2 -0
  30. package/esm/scripts/run-codex-prompts/runners/cline/ClineRunner.d.ts +2 -0
  31. package/esm/scripts/run-codex-prompts/runners/gemini/GeminiRunner.d.ts +2 -0
  32. package/esm/scripts/run-codex-prompts/runners/github-copilot/GitHubCopilotRunner.d.ts +2 -0
  33. package/esm/scripts/run-codex-prompts/runners/openai-codex/OpenAiCodexRunner.d.ts +2 -0
  34. package/esm/scripts/run-codex-prompts/runners/opencode/OpencodeRunner.d.ts +2 -0
  35. package/esm/scripts/run-codex-prompts/runners/qwen-code/QwenCodeRunner.d.ts +2 -0
  36. package/esm/scripts/run-codex-prompts/server/runCoderHttpServer.d.ts +3 -0
  37. package/esm/scripts/run-codex-prompts/team/CoderTeamRuntime.d.ts +87 -0
  38. package/esm/scripts/run-codex-prompts/team/coderTeamProtocol.d.ts +6 -0
  39. package/esm/scripts/run-codex-prompts/team/compileCoderTeamAgent.d.ts +4 -0
  40. package/esm/scripts/run-codex-prompts/team/createCoderTeamPromptRunner.d.ts +9 -0
  41. package/esm/scripts/run-codex-prompts/team/startCoderTeamBridge.d.ts +14 -0
  42. package/esm/scripts/run-codex-prompts/ui/CoderRunUiState.d.ts +16 -1
  43. package/esm/scripts/run-codex-prompts/ui/buildCoderRunUiFrame.d.ts +6 -0
  44. package/esm/scripts/run-codex-prompts/ui/buildCoderRunUiViewport.d.ts +5 -0
  45. package/esm/scripts/run-codex-prompts/ui/buildRunUiFrameShared.d.ts +4 -1
  46. package/esm/scripts/run-codex-prompts/ui/coderRunUiText.d.ts +4 -0
  47. package/esm/scripts/run-codex-prompts/ui/output/CoderOutputEvent.d.ts +20 -0
  48. package/esm/scripts/run-codex-prompts/ui/output/CoderRunOutput.d.ts +48 -0
  49. package/esm/scripts/run-codex-prompts/ui/output/buildCoderOutputLines.d.ts +18 -0
  50. package/esm/scripts/run-codex-prompts/ui/output/normalizeCoderOutputRecord.d.ts +10 -0
  51. package/esm/scripts/utils/emojiTags/scanEmojiTagUsage.d.ts +2 -0
  52. package/esm/scripts/utils/prompts/isPromptDocumentationFile.d.ts +5 -0
  53. package/esm/scripts/utils/prompts/promptEmojiTags.d.ts +2 -0
  54. package/esm/scripts/verify-prompts/verify-prompts.d.ts +3 -0
  55. package/esm/src/book-2.0/agent-source/CreateAgentModelRequirementsOptions.d.ts +2 -0
  56. package/esm/src/cli/cli-commands/coder/add.d.ts +16 -0
  57. package/esm/src/cli/cli-commands/coder/agentCliOptions.d.ts +3 -2
  58. package/esm/src/cli/cli-commands/coder/augmentCoderAgentTeam.d.ts +7 -0
  59. package/esm/src/cli/cli-commands/coder/coderAgentRole.d.ts +16 -0
  60. package/esm/src/cli/cli-commands/coder/coderReferencedArtifacts.d.ts +8 -7
  61. package/esm/src/cli/cli-commands/coder/ensureCoderDefaultAgentFiles.d.ts +8 -0
  62. package/esm/src/cli/cli-commands/coder/ensureCoderDefaultAgentFiles.test.d.ts +1 -0
  63. package/esm/src/cli/cli-commands/coder/ensureCoderRoleAgentFile.d.ts +12 -0
  64. package/esm/src/cli/cli-commands/coder/generate-boilerplates.d.ts +1 -1
  65. package/esm/src/cli/cli-commands/coder/getCoderInitializationCommitPaths.d.ts +9 -0
  66. package/esm/src/cli/cli-commands/coder/initializeCoderProjectConfiguration.d.ts +7 -5
  67. package/esm/src/cli/cli-commands/coder/plan.d.ts +7 -0
  68. package/esm/src/cli/cli-commands/coder/planning/assertPlanningCommitSafe.d.ts +6 -0
  69. package/esm/src/cli/cli-commands/coder/planning/assertPlanningPrdCommitScope.d.ts +7 -0
  70. package/esm/src/cli/cli-commands/coder/planning/assertPlanningRuntimePath.d.ts +6 -0
  71. package/esm/src/cli/cli-commands/coder/planning/createPlanningTerminal.d.ts +8 -0
  72. package/esm/src/cli/cli-commands/coder/planning/createPlanningTerminal.test.d.ts +1 -0
  73. package/esm/src/cli/cli-commands/coder/planning/createPlanningWorkspace.d.ts +11 -0
  74. package/esm/src/cli/cli-commands/coder/planning/discussPlanningTurn.d.ts +15 -0
  75. package/esm/src/cli/cli-commands/coder/planning/fixtures/snapshotPlanningProject.d.ts +5 -0
  76. package/esm/src/cli/cli-commands/coder/planning/planningGitSync.test.d.ts +1 -0
  77. package/esm/src/cli/cli-commands/coder/planning/planningPackagedCli.test.d.ts +1 -0
  78. package/esm/src/cli/cli-commands/coder/planning/planningProtocol.d.ts +152 -0
  79. package/esm/src/cli/cli-commands/coder/planning/planningTeam.test.d.ts +1 -0
  80. package/esm/src/cli/cli-commands/coder/planning/preparePlanningChanges.d.ts +16 -0
  81. package/esm/src/cli/cli-commands/coder/planning/readPlanningContext.d.ts +6 -0
  82. package/esm/src/cli/cli-commands/coder/planning/resolvePlanningPath.d.ts +7 -0
  83. package/esm/src/cli/cli-commands/coder/planning/runPlanningHarness.d.ts +30 -0
  84. package/esm/src/cli/cli-commands/coder/planning/runPlanningHarness.test.d.ts +1 -0
  85. package/esm/src/cli/cli-commands/coder/planning/runPlanningSession.d.ts +21 -0
  86. package/esm/src/cli/cli-commands/coder/planning/runPlanningSession.test.d.ts +1 -0
  87. package/esm/src/cli/cli-commands/coder/planning/savePlanningChanges.d.ts +7 -0
  88. package/esm/src/cli/cli-commands/coder/printInitializationSummary.d.ts +2 -1
  89. package/esm/src/cli/cli-commands/coder/promptsReadmeTemplate.d.ts +13 -0
  90. package/esm/src/cli/cli-commands/coder/promptsReadmeTemplate.test.d.ts +1 -0
  91. package/esm/src/cli/cli-commands/coder/readCoderAgentBook.d.ts +8 -0
  92. package/esm/src/cli/cli-commands/coder/workspacePreflight.test.d.ts +1 -0
  93. package/esm/src/cli/cli-commands/coder.d.ts +1 -0
  94. package/esm/src/cli/cli-commands/common/LocalAgentBookCollection.d.ts +4 -2
  95. package/esm/src/cli/cli-commands/common/coderGitSyncCliOptions.d.ts +1 -1
  96. package/esm/src/cli/cli-commands/common/resolveLocalAgentSource.d.ts +8 -1
  97. package/esm/src/cli/cli-commands/common/validateCoderRunOptions.d.ts +6 -0
  98. package/esm/src/cli/cli-commands/common/workspaceRepository.d.ts +36 -0
  99. package/esm/src/cli/cli-commands/common/workspaceRepository.test.d.ts +1 -0
  100. package/esm/src/cli/cli-commands/common/workspaceRepositoryCliOptions.d.ts +11 -0
  101. package/esm/src/commitments/TEAM/TEAM.test.d.ts +1 -0
  102. package/esm/src/conversion/archive/loadJsZipModule.d.ts +10 -0
  103. package/esm/src/version.d.ts +1 -1
  104. package/package.json +4 -3
  105. package/src/book-2.0/agent-source/CreateAgentModelRequirementsOptions.ts +2 -0
  106. package/src/book-2.0/agent-source/createAgentModelRequirementsWithCommitments/applyCommitmentsToAgentModelRequirements.ts +8 -3
  107. package/src/book-2.0/agent-source/createAgentModelRequirementsWithCommitments.ts +6 -0
  108. package/src/cli/$initializePromptbookCliProgram.ts +2 -0
  109. package/src/cli/cli-commands/coder/add.ts +44 -14
  110. package/src/cli/cli-commands/coder/agentCliOptions.ts +9 -3
  111. package/src/cli/cli-commands/coder/augmentCoderAgentTeam.ts +152 -0
  112. package/src/cli/cli-commands/coder/coderAgentRole.ts +22 -0
  113. package/src/cli/cli-commands/coder/coderReferencedArtifacts.ts +9 -12
  114. package/src/cli/cli-commands/coder/ensureCoderDefaultAgentFiles.ts +90 -0
  115. package/src/cli/cli-commands/coder/ensureCoderDeveloperAgentFile.ts +2 -21
  116. package/src/cli/cli-commands/coder/ensureCoderRoleAgentFile.ts +36 -0
  117. package/src/cli/cli-commands/coder/find-fresh-emoji-tags.ts +11 -2
  118. package/src/cli/cli-commands/coder/find-refactor-candidates.ts +10 -1
  119. package/src/cli/cli-commands/coder/find-unwritten.ts +10 -1
  120. package/src/cli/cli-commands/coder/generate-boilerplates.ts +12 -3
  121. package/src/cli/cli-commands/coder/getCoderInitializationCommitPaths.ts +42 -0
  122. package/src/cli/cli-commands/coder/getDefaultCoderPackageJsonScripts.ts +7 -2
  123. package/src/cli/cli-commands/coder/init.ts +88 -26
  124. package/src/cli/cli-commands/coder/initializeCoderProjectConfiguration.ts +67 -21
  125. package/src/cli/cli-commands/coder/list.ts +7 -1
  126. package/src/cli/cli-commands/coder/ping.ts +8 -1
  127. package/src/cli/cli-commands/coder/plan.ts +127 -0
  128. package/src/cli/cli-commands/coder/planning/README.md +37 -0
  129. package/src/cli/cli-commands/coder/planning/assertPlanningCommitSafe.ts +23 -0
  130. package/src/cli/cli-commands/coder/planning/assertPlanningPrdCommitScope.ts +57 -0
  131. package/src/cli/cli-commands/coder/planning/assertPlanningRuntimePath.ts +34 -0
  132. package/src/cli/cli-commands/coder/planning/createPlanningTerminal.ts +57 -0
  133. package/src/cli/cli-commands/coder/planning/createPlanningWorkspace.ts +36 -0
  134. package/src/cli/cli-commands/coder/planning/discussPlanningTurn.ts +61 -0
  135. package/src/cli/cli-commands/coder/planning/fixtures/codex.cjs +54 -0
  136. package/src/cli/cli-commands/coder/planning/fixtures/conversation.json +70 -0
  137. package/src/cli/cli-commands/coder/planning/fixtures/snapshotPlanningProject.ts +17 -0
  138. package/src/cli/cli-commands/coder/planning/fixtures/terminal.cjs +26 -0
  139. package/src/cli/cli-commands/coder/planning/planningProtocol.ts +132 -0
  140. package/src/cli/cli-commands/coder/planning/preparePlanningChanges.ts +178 -0
  141. package/src/cli/cli-commands/coder/planning/readPlanningContext.ts +108 -0
  142. package/src/cli/cli-commands/coder/planning/resolvePlanningPath.ts +72 -0
  143. package/src/cli/cli-commands/coder/planning/runPlanningHarness.ts +249 -0
  144. package/src/cli/cli-commands/coder/planning/runPlanningSession.ts +243 -0
  145. package/src/cli/cli-commands/coder/planning/savePlanningChanges.ts +107 -0
  146. package/src/cli/cli-commands/coder/printInitializationSummary.ts +26 -3
  147. package/src/cli/cli-commands/coder/promptsReadmeTemplate.ts +358 -0
  148. package/src/cli/cli-commands/coder/readCoderAgentBook.ts +62 -0
  149. package/src/cli/cli-commands/coder/run.ts +37 -15
  150. package/src/cli/cli-commands/coder/server.ts +31 -10
  151. package/src/cli/cli-commands/coder/verify.ts +18 -1
  152. package/src/cli/cli-commands/coder.ts +7 -0
  153. package/src/cli/cli-commands/common/LocalAgentBookCollection.ts +56 -18
  154. package/src/cli/cli-commands/common/coderGitSyncCliOptions.ts +1 -1
  155. package/src/cli/cli-commands/common/createLocalAgentReferenceResolver.ts +7 -0
  156. package/src/cli/cli-commands/common/resolveLocalAgentSource.ts +39 -19
  157. package/src/cli/cli-commands/common/validateCoderRunOptions.ts +91 -0
  158. package/src/cli/cli-commands/common/workspaceRepository.md +46 -0
  159. package/src/cli/cli-commands/common/workspaceRepository.ts +265 -0
  160. package/src/cli/cli-commands/common/workspaceRepositoryCliOptions.ts +29 -0
  161. package/src/commitments/TEAM/TEAM.ts +26 -4
  162. package/src/conversion/archive/loadJsZipModule.ts +3 -1
  163. package/src/other/templates/getTemplatesPipelineCollection.ts +1104 -781
  164. package/src/version.ts +2 -2
  165. package/src/versions.txt +6 -0
  166. package/umd/index.umd.js +4767 -809
  167. package/umd/index.umd.js.map +1 -1
  168. package/umd/scripts/find-fresh-emoji-tags/find-fresh-emoji-tags.d.ts +1 -1
  169. package/umd/scripts/find-refactor-candidates/find-refactor-candidates.d.ts +2 -0
  170. package/umd/scripts/find-refactor-candidates/resolveRefactorCandidateProject.d.ts +3 -1
  171. package/umd/scripts/run-codex-prompts/common/CoderRunControlFeedback.d.ts +1 -1
  172. package/umd/scripts/run-codex-prompts/common/buildCoderRunControlKeyBadge.d.ts +1 -1
  173. package/umd/scripts/run-codex-prompts/common/listenForCoderRunControls.d.ts +3 -2
  174. package/umd/scripts/run-codex-prompts/common/resolveCoderAgent.d.ts +15 -5
  175. package/umd/scripts/run-codex-prompts/common/runGoScript/$spawnLoggedBashScript.d.ts +2 -0
  176. package/umd/scripts/run-codex-prompts/common/runGoScript/captureLiveScriptOutput.d.ts +9 -0
  177. package/umd/scripts/run-codex-prompts/common/runGoScript/createScriptOutputLineReader.d.ts +4 -0
  178. package/umd/scripts/run-codex-prompts/common/runGoScript/resolveShellHereDocumentDelimiter.d.ts +2 -0
  179. package/umd/scripts/run-codex-prompts/common/runGoScript/scriptExecutionLog.d.ts +2 -0
  180. package/umd/scripts/run-codex-prompts/git/coderCommitScope.d.ts +4 -1
  181. package/umd/scripts/run-codex-prompts/git/coderGitSync.d.ts +5 -0
  182. package/umd/scripts/run-codex-prompts/git/commitInitializedAgentBooks.d.ts +2 -1
  183. package/umd/scripts/run-codex-prompts/git/ensureWorkingTreeClean.d.ts +1 -1
  184. package/umd/scripts/run-codex-prompts/isolation/copyCoderIsolationEnvironment.d.ts +1 -1
  185. package/umd/scripts/run-codex-prompts/isolation/createCoderIsolationWorktree.d.ts +2 -0
  186. package/umd/scripts/run-codex-prompts/main/findUnwrittenPrompts.d.ts +2 -0
  187. package/umd/scripts/run-codex-prompts/main/listCoderPrompts.d.ts +2 -0
  188. package/umd/scripts/run-codex-prompts/main/resolvePromptRunner.d.ts +11 -0
  189. package/umd/scripts/run-codex-prompts/prompts/loadPromptFiles.d.ts +10 -2
  190. package/umd/scripts/run-codex-prompts/runners/claude-code/ClaudeCodeRunner.d.ts +2 -0
  191. package/umd/scripts/run-codex-prompts/runners/cline/ClineRunner.d.ts +2 -0
  192. package/umd/scripts/run-codex-prompts/runners/gemini/GeminiRunner.d.ts +2 -0
  193. package/umd/scripts/run-codex-prompts/runners/github-copilot/GitHubCopilotRunner.d.ts +2 -0
  194. package/umd/scripts/run-codex-prompts/runners/openai-codex/OpenAiCodexRunner.d.ts +2 -0
  195. package/umd/scripts/run-codex-prompts/runners/opencode/OpencodeRunner.d.ts +2 -0
  196. package/umd/scripts/run-codex-prompts/runners/qwen-code/QwenCodeRunner.d.ts +2 -0
  197. package/umd/scripts/run-codex-prompts/server/runCoderHttpServer.d.ts +3 -0
  198. package/umd/scripts/run-codex-prompts/team/CoderTeamRuntime.d.ts +87 -0
  199. package/umd/scripts/run-codex-prompts/team/coderTeamProtocol.d.ts +6 -0
  200. package/umd/scripts/run-codex-prompts/team/compileCoderTeamAgent.d.ts +4 -0
  201. package/umd/scripts/run-codex-prompts/team/createCoderTeamPromptRunner.d.ts +9 -0
  202. package/umd/scripts/run-codex-prompts/team/startCoderTeamBridge.d.ts +14 -0
  203. package/umd/scripts/run-codex-prompts/ui/CoderRunUiState.d.ts +16 -1
  204. package/umd/scripts/run-codex-prompts/ui/buildCoderRunUiFrame.d.ts +6 -0
  205. package/umd/scripts/run-codex-prompts/ui/buildCoderRunUiViewport.d.ts +5 -0
  206. package/umd/scripts/run-codex-prompts/ui/buildRunUiFrameShared.d.ts +4 -1
  207. package/umd/scripts/run-codex-prompts/ui/coderRunUiText.d.ts +4 -0
  208. package/umd/scripts/run-codex-prompts/ui/output/CoderOutputEvent.d.ts +20 -0
  209. package/umd/scripts/run-codex-prompts/ui/output/CoderRunOutput.d.ts +48 -0
  210. package/umd/scripts/run-codex-prompts/ui/output/buildCoderOutputLines.d.ts +18 -0
  211. package/umd/scripts/run-codex-prompts/ui/output/normalizeCoderOutputRecord.d.ts +10 -0
  212. package/umd/scripts/utils/emojiTags/scanEmojiTagUsage.d.ts +2 -0
  213. package/umd/scripts/utils/prompts/isPromptDocumentationFile.d.ts +5 -0
  214. package/umd/scripts/utils/prompts/promptEmojiTags.d.ts +2 -0
  215. package/umd/scripts/verify-prompts/verify-prompts.d.ts +3 -0
  216. package/umd/src/book-2.0/agent-source/CreateAgentModelRequirementsOptions.d.ts +2 -0
  217. package/umd/src/cli/cli-commands/coder/add.d.ts +16 -0
  218. package/umd/src/cli/cli-commands/coder/agentCliOptions.d.ts +3 -2
  219. package/umd/src/cli/cli-commands/coder/augmentCoderAgentTeam.d.ts +7 -0
  220. package/umd/src/cli/cli-commands/coder/coderAgentRole.d.ts +16 -0
  221. package/umd/src/cli/cli-commands/coder/coderReferencedArtifacts.d.ts +8 -7
  222. package/umd/src/cli/cli-commands/coder/ensureCoderDefaultAgentFiles.d.ts +8 -0
  223. package/umd/src/cli/cli-commands/coder/ensureCoderDefaultAgentFiles.test.d.ts +1 -0
  224. package/umd/src/cli/cli-commands/coder/ensureCoderRoleAgentFile.d.ts +12 -0
  225. package/umd/src/cli/cli-commands/coder/generate-boilerplates.d.ts +1 -1
  226. package/umd/src/cli/cli-commands/coder/getCoderInitializationCommitPaths.d.ts +9 -0
  227. package/umd/src/cli/cli-commands/coder/initializeCoderProjectConfiguration.d.ts +7 -5
  228. package/umd/src/cli/cli-commands/coder/plan.d.ts +7 -0
  229. package/umd/src/cli/cli-commands/coder/planning/assertPlanningCommitSafe.d.ts +6 -0
  230. package/umd/src/cli/cli-commands/coder/planning/assertPlanningPrdCommitScope.d.ts +7 -0
  231. package/umd/src/cli/cli-commands/coder/planning/assertPlanningRuntimePath.d.ts +6 -0
  232. package/umd/src/cli/cli-commands/coder/planning/createPlanningTerminal.d.ts +8 -0
  233. package/umd/src/cli/cli-commands/coder/planning/createPlanningTerminal.test.d.ts +1 -0
  234. package/umd/src/cli/cli-commands/coder/planning/createPlanningWorkspace.d.ts +11 -0
  235. package/umd/src/cli/cli-commands/coder/planning/discussPlanningTurn.d.ts +15 -0
  236. package/umd/src/cli/cli-commands/coder/planning/fixtures/snapshotPlanningProject.d.ts +5 -0
  237. package/umd/src/cli/cli-commands/coder/planning/planningGitSync.test.d.ts +1 -0
  238. package/umd/src/cli/cli-commands/coder/planning/planningPackagedCli.test.d.ts +1 -0
  239. package/umd/src/cli/cli-commands/coder/planning/planningProtocol.d.ts +152 -0
  240. package/umd/src/cli/cli-commands/coder/planning/planningTeam.test.d.ts +1 -0
  241. package/umd/src/cli/cli-commands/coder/planning/preparePlanningChanges.d.ts +16 -0
  242. package/umd/src/cli/cli-commands/coder/planning/readPlanningContext.d.ts +6 -0
  243. package/umd/src/cli/cli-commands/coder/planning/resolvePlanningPath.d.ts +7 -0
  244. package/umd/src/cli/cli-commands/coder/planning/runPlanningHarness.d.ts +30 -0
  245. package/umd/src/cli/cli-commands/coder/planning/runPlanningHarness.test.d.ts +1 -0
  246. package/umd/src/cli/cli-commands/coder/planning/runPlanningSession.d.ts +21 -0
  247. package/umd/src/cli/cli-commands/coder/planning/runPlanningSession.test.d.ts +1 -0
  248. package/umd/src/cli/cli-commands/coder/planning/savePlanningChanges.d.ts +7 -0
  249. package/umd/src/cli/cli-commands/coder/printInitializationSummary.d.ts +2 -1
  250. package/umd/src/cli/cli-commands/coder/promptsReadmeTemplate.d.ts +13 -0
  251. package/umd/src/cli/cli-commands/coder/promptsReadmeTemplate.test.d.ts +1 -0
  252. package/umd/src/cli/cli-commands/coder/readCoderAgentBook.d.ts +8 -0
  253. package/umd/src/cli/cli-commands/coder/workspacePreflight.test.d.ts +1 -0
  254. package/umd/src/cli/cli-commands/coder.d.ts +1 -0
  255. package/umd/src/cli/cli-commands/common/LocalAgentBookCollection.d.ts +4 -2
  256. package/umd/src/cli/cli-commands/common/coderGitSyncCliOptions.d.ts +1 -1
  257. package/umd/src/cli/cli-commands/common/resolveLocalAgentSource.d.ts +8 -1
  258. package/umd/src/cli/cli-commands/common/validateCoderRunOptions.d.ts +6 -0
  259. package/umd/src/cli/cli-commands/common/workspaceRepository.d.ts +36 -0
  260. package/umd/src/cli/cli-commands/common/workspaceRepository.test.d.ts +1 -0
  261. package/umd/src/cli/cli-commands/common/workspaceRepositoryCliOptions.d.ts +11 -0
  262. package/umd/src/commitments/TEAM/TEAM.test.d.ts +1 -0
  263. package/umd/src/conversion/archive/loadJsZipModule.d.ts +10 -0
  264. package/umd/src/version.d.ts +1 -1
@@ -0,0 +1,152 @@
1
+ import { randomUUID } from 'crypto';
2
+ import { readFile, rename, stat, unlink, writeFile } from 'fs/promises';
3
+ import { join } from 'path';
4
+ import { spaceTrim } from 'spacetrim';
5
+ import { createTeamToolName } from '../../../book-2.0/agent-source/createTeamToolName';
6
+ import { filterCommitmentsForAgentModelRequirements } from '../../../book-2.0/agent-source/createAgentModelRequirementsWithCommitments/filterCommitmentsForAgentModelRequirements';
7
+ import { parseAgentSourceWithCommitments } from '../../../book-2.0/agent-source/parseAgentSourceWithCommitments';
8
+ import { parseTeamCommitmentContent } from '../../../book-2.0/agent-source/parseTeamCommitment';
9
+ import type { string_book } from '../../../book-2.0/agent-source/string_book';
10
+ import { ParseError } from '../../../errors/ParseError';
11
+ import { createLocalAgentReferenceResolver } from '../common/createLocalAgentReferenceResolver';
12
+ import { LocalAgentBookCollection } from '../common/LocalAgentBookCollection';
13
+ import { resolveBundledAgentBookPath } from '../common/resolveBundledAgentBookPath';
14
+ import { readCoderAgentBook } from './readCoderAgentBook';
15
+
16
+ /**
17
+ * Adds only missing bundled TEAM commitments using canonical local Book identities.
18
+ * Role instructions come from the bundled Book, not from a harness or a second template here.
19
+ *
20
+ * @private internal utility of `coder init`
21
+ */
22
+ export async function augmentCoderAgentTeam(
23
+ projectPath: string,
24
+ role: 'developer' | 'planner',
25
+ ): Promise<'augmented' | 'unchanged'> {
26
+ const filePath = join(projectPath, 'agents', `${role}.book`);
27
+ const source = await readCoderAgentBook(filePath);
28
+ const collection = new LocalAgentBookCollection(join(projectPath, 'agents'), projectPath, false);
29
+ await collection.initialize();
30
+ const book = await collection.readBook(filePath);
31
+ const resolver = createLocalAgentReferenceResolver(collection, book);
32
+
33
+ /** Resolves active TEAM commitments without fetching remote profiles or executing any tools. */
34
+ async function resolveTeamUrls(agentSource: string_book): Promise<Set<string>> {
35
+ const urls = new Set<string>();
36
+ const commitments = filterCommitmentsForAgentModelRequirements(
37
+ parseAgentSourceWithCommitments(agentSource).commitments,
38
+ );
39
+ for (const commitment of commitments.filter(({ type }) => type === 'TEAM')) {
40
+ const content = await resolver.resolveCommitmentContent('TEAM', commitment.content);
41
+ const teammates = parseTeamCommitmentContent(content);
42
+ if (teammates.length === 0) {
43
+ throw new ParseError(
44
+ spaceTrim(
45
+ `Cannot resolve \`TEAM ${commitment.content}\` on line ${commitment.lineNumber}. Use a supported agent reference such as \`{./lawyer.book}\`.`,
46
+ ),
47
+ );
48
+ }
49
+ teammates.forEach(({ url }) => urls.add(url));
50
+ }
51
+ return urls;
52
+ }
53
+
54
+ const existingUrls = await resolveTeamUrls(source);
55
+ const bundledSource = (await readFile(
56
+ await resolveBundledAgentBookPath(`agents/default/${role}.book`),
57
+ 'utf-8',
58
+ )) as string_book;
59
+ const defaultTeams = parseAgentSourceWithCommitments(bundledSource).commitments.filter(
60
+ ({ type }) => type === 'TEAM',
61
+ );
62
+ const additions: string[] = [];
63
+ const requiredUrls = new Set<string>();
64
+ for (const commitment of defaultTeams) {
65
+ const content = await resolver.resolveCommitmentContent('TEAM', commitment.content);
66
+ const teammates = parseTeamCommitmentContent(content);
67
+ // Each bundled default declares one helper. Refuse a mixed declaration rather than duplicating a teammate.
68
+ if (teammates.length !== 1) {
69
+ throw new ParseError(spaceTrim('A bundled default TEAM commitment must reference exactly one helper.'));
70
+ }
71
+ for (const { url } of teammates) requiredUrls.add(url);
72
+ if (teammates.every(({ url }) => existingUrls.has(url))) continue;
73
+ additions.push(`TEAM ${commitment.content}`);
74
+ }
75
+ await assertNoConflictingTeamTools(collection, book.url, existingUrls, requiredUrls);
76
+ if (additions.length === 0) return 'unchanged';
77
+
78
+ const augmentedSource = insertTeamCommitments(source, additions);
79
+ const augmentedUrls = await resolveTeamUrls(augmentedSource);
80
+ if ([...requiredUrls].some((url) => !augmentedUrls.has(url))) {
81
+ throw new ParseError(
82
+ spaceTrim(
83
+ 'Existing structural commitments remove a default TEAM reference. Resolve that conflict before initializing the team.',
84
+ ),
85
+ );
86
+ }
87
+ await replaceUnchangedBook(filePath, source, augmentedSource);
88
+ return 'augmented';
89
+ }
90
+
91
+ /** Refuses local names which would cause an added helper to share another Book's generated TEAM tool. */
92
+ async function assertNoConflictingTeamTools(
93
+ collection: LocalAgentBookCollection,
94
+ primaryBookUrl: string,
95
+ existingUrls: ReadonlySet<string>,
96
+ requiredUrls: ReadonlySet<string>,
97
+ ): Promise<void> {
98
+ const localOrigin = new URL(primaryBookUrl).origin;
99
+ const booksByToolName = new Map<string, { url: string; filePath?: string }>();
100
+ // Check required helpers first so a conflict between those two is reported as well.
101
+ for (const url of new Set([...requiredUrls, ...existingUrls])) {
102
+ if (new URL(url).origin !== localOrigin) continue;
103
+ // Local references were registered by the resolver; this does not fetch remote teammate profiles.
104
+ const book = await collection.getBook(url);
105
+ const toolName = createTeamToolName(url, book.profile.agentName);
106
+ const previousBook = booksByToolName.get(toolName);
107
+ if (previousBook && (requiredUrls.has(url) || requiredUrls.has(previousBook.url))) {
108
+ throw new ParseError(
109
+ spaceTrim(
110
+ `TEAM tool \`${toolName}\` conflicts between \`${previousBook.filePath}\` and \`${book.filePath}\`. Give these Books distinct names or META FULLNAME values before adding the default helper reference.`,
111
+ ),
112
+ );
113
+ }
114
+ booksByToolName.set(toolName, book);
115
+ }
116
+ }
117
+
118
+ /** Inserts at a parser-provided block boundary, preserving CLOSED, code examples, prose, and line endings. */
119
+ function insertTeamCommitments(source: string_book, additions: ReadonlyArray<string>): string_book {
120
+ const parsed = parseAgentSourceWithCommitments(source);
121
+ const boundaries = [...parsed.commitments, ...parsed.unknownCommitments].map(({ lineNumber }) => lineNumber);
122
+ const lineEnding = source.includes('\r\n') ? '\r\n' : '\n';
123
+ const insertedText = additions.join(lineEnding) + lineEnding;
124
+ if (boundaries.length === 0) {
125
+ return (source + (source.endsWith('\n') ? '' : lineEnding) + lineEnding + insertedText) as string_book;
126
+ }
127
+ // The last block may be CLOSED/OPEN, a multiline commitment, or an unknown extension. Keep it intact.
128
+ const insertionLine = Math.max(...boundaries) - 1;
129
+ const lines = source.match(/[^\n]*\n|[^\n]+$/g) || [];
130
+ const offset = lines.slice(0, insertionLine).join('').length;
131
+ return (source.slice(0, offset) + insertedText + lineEnding + source.slice(offset)) as string_book;
132
+ }
133
+
134
+ /** Prepares the complete edit before replacing the file and refuses concurrent project edits. */
135
+ async function replaceUnchangedBook(filePath: string, originalSource: string_book, source: string_book): Promise<void> {
136
+ const temporaryPath = `${filePath}.${randomUUID()}.tmp`;
137
+ try {
138
+ await writeFile(temporaryPath, source, { flag: 'wx', mode: (await stat(filePath)).mode });
139
+ if ((await readCoderAgentBook(filePath)) !== originalSource) {
140
+ throw new ParseError(
141
+ spaceTrim(
142
+ `Book \`${filePath}\` changed during initialization. Its new content was preserved; run init again.`,
143
+ ),
144
+ );
145
+ }
146
+ await rename(temporaryPath, filePath);
147
+ } finally {
148
+ await unlink(temporaryPath).catch((error: NodeJS.ErrnoException) => {
149
+ if (error.code !== 'ENOENT') throw error;
150
+ });
151
+ }
152
+ }
@@ -0,0 +1,22 @@
1
+ import { CODER_DEVELOPER_AGENT_FILE_PATH } from './ensureCoderDeveloperAgentFile';
2
+ import { CODER_PLANNER_AGENT_FILE_PATH } from './ensureCoderRoleAgentFile';
3
+
4
+ /**
5
+ * Project-owned Book defaults for execution roles, independent of harness and model selection.
6
+ * Commands without an execution role, such as `coder list`, have no default Book filter.
7
+ *
8
+ * @private internal constant of `ptbk coder`
9
+ */
10
+ export const CODER_DEFAULT_AGENT_BOOK_PATHS = {
11
+ developer: CODER_DEVELOPER_AGENT_FILE_PATH,
12
+ planner: CODER_PLANNER_AGENT_FILE_PATH,
13
+ } as const;
14
+
15
+ /**
16
+ * Execution role whose editable local Book is selected when `--agent` is omitted.
17
+ *
18
+ * @private internal type of `ptbk coder`
19
+ */
20
+ export type CoderAgentRole = keyof typeof CODER_DEFAULT_AGENT_BOOK_PATHS;
21
+
22
+ // Note: [💞] Ignore a discrepancy between file name and exported helper names
@@ -4,20 +4,19 @@ import {
4
4
  ensureDefaultCoderPromptTemplateFile,
5
5
  getDefaultCoderProjectPromptTemplateDefinitions,
6
6
  } from './boilerplateTemplates';
7
- import { CODER_DEVELOPER_AGENT_FILE_PATH, ensureCoderDeveloperAgentFile } from './ensureCoderDeveloperAgentFile';
8
7
  import { ensureCoderMarkdownFile } from './ensureCoderMarkdownFile';
9
8
 
10
9
  /**
11
- * Status of one artifact referenced by the default coder scripts.
10
+ * Status of one default Book or artifact referenced by the default coder scripts.
12
11
  *
13
12
  * `not-referenced` means that no newly added script points at the artifact, so `ptbk coder init` left it alone.
14
13
  *
15
14
  * @private internal utility of `coder init` command
16
15
  */
17
- export type CoderReferencedArtifactStatus = InitializationStatus | 'not-referenced';
16
+ export type CoderReferencedArtifactStatus = InitializationStatus | 'augmented' | 'unresolved' | 'not-referenced';
18
17
 
19
18
  /**
20
- * Result of ensuring one artifact referenced by the default coder scripts.
19
+ * Result of ensuring one default Book or artifact referenced by the default coder scripts.
21
20
  *
22
21
  * @private internal utility of `coder init` command
23
22
  */
@@ -28,9 +27,12 @@ export type EnsuredCoderReferencedArtifact = {
28
27
  readonly relativeFilePath: string;
29
28
 
30
29
  /**
31
- * Status describing whether the artifact had to be created.
30
+ * Status describing whether the artifact was created, augmented, preserved, or could not be resolved.
32
31
  */
33
32
  readonly status: CoderReferencedArtifactStatus;
33
+
34
+ /** Explanation of an unresolved file or TEAM declaration, with the original content preserved. */
35
+ readonly diagnostic?: string;
34
36
  };
35
37
 
36
38
  /**
@@ -64,10 +66,6 @@ function createCoderPromptTemplateArtifactDefinition(
64
66
  * Every artifact which the default coder scripts can reference.
65
67
  */
66
68
  const CODER_REFERENCED_ARTIFACT_DEFINITIONS: ReadonlyArray<CoderReferencedArtifactDefinition> = [
67
- {
68
- relativeFilePath: CODER_DEVELOPER_AGENT_FILE_PATH,
69
- ensureArtifactFile: ensureCoderDeveloperAgentFile,
70
- },
71
69
  {
72
70
  relativeFilePath: AGENTS_FILE_PATH,
73
71
  ensureArtifactFile: (projectPath) =>
@@ -77,10 +75,9 @@ const CODER_REFERENCED_ARTIFACT_DEFINITIONS: ReadonlyArray<CoderReferencedArtifa
77
75
  ];
78
76
 
79
77
  /**
80
- * Creates only those referenced artifacts which the freshly added coder scripts point at.
78
+ * Initializes artifacts referenced by freshly added scripts. Default Books are ensured separately.
81
79
  *
82
- * An artifact of a script which the project already defines is intentionally **not** created - the project-owned
83
- * script is kept as is, so it does not reference the default artifact in the first place.
80
+ * For artifacts other than role Books, an existing project script does not cause default files to be created.
84
81
  *
85
82
  * @private function of `initializeCoderProjectConfiguration`
86
83
  */
@@ -0,0 +1,90 @@
1
+ import { join } from 'path';
2
+ import { spaceTrim } from 'spacetrim';
3
+ import { ADAM_AGENT_BOOK_RELATIVE_PATH, ensureAdamAgentBook } from '../common/ensureAdamAgentBook';
4
+ import { augmentCoderAgentTeam } from './augmentCoderAgentTeam';
5
+ import type { EnsuredCoderReferencedArtifact } from './coderReferencedArtifacts';
6
+ import { ensureCoderRoleAgentFile } from './ensureCoderRoleAgentFile';
7
+ import { readCoderAgentBook } from './readCoderAgentBook';
8
+
9
+ /** Project-owned roles created independently of package-script changes. */
10
+ const CODER_DEFAULT_ROLES = ['developer', 'planner', 'lawyer', 'copywriter'] as const;
11
+
12
+ /**
13
+ * Ensures every default Book independently, then adds missing helper declarations to the two primary roles.
14
+ * A failure leaves the affected Book intact and does not prevent the remaining files from being initialized.
15
+ *
16
+ * @private internal utility of `coder init`
17
+ */
18
+ export async function ensureCoderDefaultAgentFiles(projectPath: string): Promise<EnsuredCoderReferencedArtifact[]> {
19
+ const artifacts: EnsuredCoderReferencedArtifact[] = [];
20
+ const definitions = [
21
+ {
22
+ relativeFilePath: `agents/${ADAM_AGENT_BOOK_RELATIVE_PATH}`,
23
+ ensureFile: () => ensureAdamAgentBook(join(projectPath, 'agents')),
24
+ },
25
+ ...CODER_DEFAULT_ROLES.map((role) => ({
26
+ relativeFilePath: `agents/${role}.book`,
27
+ ensureFile: () => ensureCoderRoleAgentFile(projectPath, role),
28
+ })),
29
+ ];
30
+ for (const { relativeFilePath, ensureFile } of definitions) {
31
+ try {
32
+ const filePath = join(projectPath, relativeFilePath);
33
+ let status: EnsuredCoderReferencedArtifact['status'] = 'unchanged';
34
+ try {
35
+ await readCoderAgentBook(filePath);
36
+ } catch (error) {
37
+ if ((error as NodeJS.ErrnoException).code !== 'ENOENT') throw error;
38
+ status = await ensureFile();
39
+ await readCoderAgentBook(filePath);
40
+ }
41
+ artifacts.push({ relativeFilePath, status });
42
+ } catch (error) {
43
+ artifacts.push({ relativeFilePath, status: 'unresolved', diagnostic: describeInitializationError(error) });
44
+ }
45
+ }
46
+
47
+ const unresolvedDependencies = artifacts.filter(
48
+ ({ relativeFilePath, status }) =>
49
+ status === 'unresolved' && !['agents/developer.book', 'agents/planner.book'].includes(relativeFilePath),
50
+ );
51
+ for (const role of ['developer', 'planner'] as const) {
52
+ const index = artifacts.findIndex(({ relativeFilePath }) => relativeFilePath === `agents/${role}.book`);
53
+ const artifact = artifacts[index]!;
54
+ if (artifact.status === 'unresolved') continue;
55
+ try {
56
+ if (unresolvedDependencies.length > 0) {
57
+ artifacts[index] = {
58
+ ...artifact,
59
+ status: 'unresolved',
60
+ diagnostic: spaceTrim(
61
+ `Default TEAM references could not be checked or added because these Books are unresolved: ${unresolvedDependencies
62
+ .map(({ relativeFilePath }) => `\`${relativeFilePath}\``)
63
+ .join(', ')}. Existing content was preserved.`,
64
+ ),
65
+ };
66
+ continue;
67
+ }
68
+ const teamStatus = await augmentCoderAgentTeam(projectPath, role);
69
+ if (teamStatus === 'augmented' && artifact.status !== 'created') {
70
+ artifacts[index] = { ...artifact, status: teamStatus };
71
+ }
72
+ } catch (error) {
73
+ artifacts[index] = {
74
+ ...artifact,
75
+ status: 'unresolved',
76
+ diagnostic: spaceTrim(
77
+ `Default TEAM references could not be safely added; existing content was preserved. ${describeInitializationError(
78
+ error,
79
+ )}`,
80
+ ),
81
+ };
82
+ }
83
+ }
84
+ return artifacts;
85
+ }
86
+
87
+ /** Retains filesystem error codes and Book diagnostics in the per-artifact initialization report. */
88
+ function describeInitializationError(error: unknown): string {
89
+ return error instanceof Error ? error.message : String(error);
90
+ }
@@ -1,7 +1,5 @@
1
- import { copyFile, stat } from 'fs/promises';
2
- import { join } from 'path';
3
- import { resolveBundledAgentBookPath } from '../common/resolveBundledAgentBookPath';
4
1
  import type { InitializationStatus } from './boilerplateTemplates';
2
+ import { ensureCoderRoleAgentFile } from './ensureCoderRoleAgentFile';
5
3
 
6
4
  /**
7
5
  * Relative directory path for agents initialized by `ptbk coder init`.
@@ -30,24 +28,7 @@ export const DEFAULT_CODER_DEVELOPER_AGENT_SOURCE_FILE_PATH = 'agents/default/de
30
28
  * @private function of `initializeCoderProjectConfiguration`
31
29
  */
32
30
  export async function ensureCoderDeveloperAgentFile(projectPath: string): Promise<InitializationStatus> {
33
- const absoluteFilePath = join(projectPath, CODER_DEVELOPER_AGENT_FILE_PATH);
34
- if (await isExistingFile(absoluteFilePath)) {
35
- return 'unchanged';
36
- }
37
-
38
- await copyFile(await resolveBundledAgentBookPath(DEFAULT_CODER_DEVELOPER_AGENT_SOURCE_FILE_PATH), absoluteFilePath);
39
- return 'created';
40
- }
41
-
42
- /**
43
- * Checks whether a path exists and is a file.
44
- */
45
- async function isExistingFile(path: string): Promise<boolean> {
46
- try {
47
- return (await stat(path)).isFile();
48
- } catch {
49
- return false;
50
- }
31
+ return ensureCoderRoleAgentFile(projectPath, 'developer');
51
32
  }
52
33
 
53
34
  // Note: [🟡] Code for coder init developer agent bootstrapping [ensureCoderDeveloperAgentFile](src/cli/cli-commands/coder/ensureCoderDeveloperAgentFile.ts) should never be published outside of `@promptbook/cli`
@@ -0,0 +1,36 @@
1
+ import { constants } from 'fs';
2
+ import { copyFile, mkdir } from 'fs/promises';
3
+ import { join } from 'path';
4
+ import { resolveBundledAgentBookPath } from '../common/resolveBundledAgentBookPath';
5
+ import type { InitializationStatus } from './boilerplateTemplates';
6
+
7
+ /**
8
+ * Project-owned planning role selected when `coder plan` has no explicit Book override.
9
+ * @private internal constant of Coder role resolution
10
+ */
11
+ export const CODER_PLANNER_AGENT_FILE_PATH = 'agents/planner.book';
12
+
13
+ /**
14
+ * Copies a bundled role without overwriting an existing project-owned Book, including on repeated init.
15
+ *
16
+ * @private internal utility of `coder init`
17
+ */
18
+ export async function ensureCoderRoleAgentFile(
19
+ projectPath: string,
20
+ role: 'developer' | 'planner' | 'lawyer' | 'copywriter',
21
+ ): Promise<InitializationStatus> {
22
+ await mkdir(join(projectPath, 'agents'), { recursive: true });
23
+ try {
24
+ await copyFile(
25
+ await resolveBundledAgentBookPath(`agents/default/${role}.book`),
26
+ join(projectPath, 'agents', `${role}.book`),
27
+ constants.COPYFILE_EXCL,
28
+ );
29
+ return 'created';
30
+ } catch (error) {
31
+ if ((error as NodeJS.ErrnoException).code === 'EEXIST') {
32
+ return 'unchanged';
33
+ }
34
+ throw error;
35
+ }
36
+ }
@@ -4,6 +4,8 @@ import type {
4
4
  } from 'commander';
5
5
  import spaceTrim from 'spacetrim';
6
6
  import type { $side_effect } from '../../../utils/organization/$side_effect';
7
+ import { $preflightWorkspaceRepository } from '../common/workspaceRepository';
8
+ import { addWorkspaceRepositoryOptions } from '../common/workspaceRepositoryCliOptions';
7
9
  import { handleActionErrors } from '../common/handleActionErrors';
8
10
 
9
11
  /**
@@ -25,15 +27,22 @@ export function $initializeCoderFindFreshEmojiTagCommand(program: Program): $sid
25
27
  `),
26
28
  );
27
29
 
30
+ addWorkspaceRepositoryOptions(command);
31
+
28
32
  command.action(
29
- handleActionErrors(async () => {
33
+ handleActionErrors(async (cliOptions) => {
34
+ const workspace = await $preflightWorkspaceRepository({
35
+ policy: 'read-only',
36
+ isAskingQuestionsEnabled: cliOptions.questions,
37
+ });
38
+
30
39
  // Note: Import the function dynamically to avoid loading heavy dependencies until needed
31
40
  const { findFreshEmojiTag } = await import(
32
41
  '../../../../scripts/find-fresh-emoji-tags/find-fresh-emoji-tags'
33
42
  );
34
43
 
35
44
  try {
36
- await findFreshEmojiTag();
45
+ await findFreshEmojiTag(workspace.projectPath);
37
46
  } catch (error) {
38
47
  console.error(colors.bgRed('Failed to find fresh emoji tags:'), error);
39
48
  return process.exit(1);
@@ -13,6 +13,8 @@ import {
13
13
  import { assertsError } from '../../../errors/assertsError';
14
14
  import type { $side_effect } from '../../../utils/organization/$side_effect';
15
15
  import { createPositiveIntegerOptionParser } from '../common/createPositiveIntegerOptionParser';
16
+ import { $preflightWorkspaceRepository } from '../common/workspaceRepository';
17
+ import { addWorkspaceRepositoryOptions } from '../common/workspaceRepositoryCliOptions';
16
18
  import { handleActionErrors } from '../common/handleActionErrors';
17
19
 
18
20
  /**
@@ -51,6 +53,8 @@ export function $initializeCoderFindRefactorCandidatesCommand(program: Program):
51
53
  createPositiveIntegerOptionParser('--limit'),
52
54
  );
53
55
 
56
+ addWorkspaceRepositoryOptions(command);
57
+
54
58
  command.action(
55
59
  handleActionErrors(async (cliOptions) => {
56
60
  const { level = DEFAULT_REFACTOR_CANDIDATE_LEVEL, limit } = cliOptions as {
@@ -58,13 +62,18 @@ export function $initializeCoderFindRefactorCandidatesCommand(program: Program):
58
62
  readonly limit?: number;
59
63
  };
60
64
 
65
+ const workspace = await $preflightWorkspaceRepository({
66
+ policy: 'mutate',
67
+ isAskingQuestionsEnabled: cliOptions.questions,
68
+ });
69
+
61
70
  // Note: Import the function dynamically to avoid loading heavy dependencies until needed
62
71
  const { findRefactorCandidates } = await import(
63
72
  '../../../../scripts/find-refactor-candidates/find-refactor-candidates'
64
73
  );
65
74
 
66
75
  try {
67
- await findRefactorCandidates({ level, limit });
76
+ await findRefactorCandidates({ level, limit, projectPath: workspace.projectPath });
68
77
  } catch (error) {
69
78
  assertsError(error);
70
79
  console.error(colors.bgRed(`${error.name}`));
@@ -2,6 +2,8 @@ import colors from 'colors';
2
2
  import { Command as Program /* <- Note: [🔸] Using Program because Command is misleading name */ } from 'commander';
3
3
  import { assertsError } from '../../../errors/assertsError';
4
4
  import type { $side_effect } from '../../../utils/organization/$side_effect';
5
+ import { $preflightWorkspaceRepository } from '../common/workspaceRepository';
6
+ import { addWorkspaceRepositoryOptions } from '../common/workspaceRepositoryCliOptions';
5
7
  import { handleActionErrors } from '../common/handleActionErrors';
6
8
 
7
9
  /**
@@ -16,19 +18,26 @@ export function $initializeCoderFindUnwrittenCommand(program: Program): $side_ef
16
18
  command.description('List all prompt sections that still need to be authored (contain @@@ placeholder)');
17
19
  command.option('--priority <minimum-priority>', 'Filter prompts by minimum priority level', parseIntOption, 0);
18
20
 
21
+ addWorkspaceRepositoryOptions(command);
22
+
19
23
  command.action(
20
24
  handleActionErrors(async (cliOptions) => {
21
25
  const { priority = 0 } = cliOptions as {
22
26
  readonly priority?: number;
23
27
  };
24
28
 
29
+ const workspace = await $preflightWorkspaceRepository({
30
+ policy: 'read-only',
31
+ isAskingQuestionsEnabled: cliOptions.questions,
32
+ });
33
+
25
34
  // Note: Import the function dynamically to avoid loading heavy dependencies until needed
26
35
  const { findUnwrittenPrompts } = await import(
27
36
  '../../../../scripts/run-codex-prompts/main/findUnwrittenPrompts'
28
37
  );
29
38
 
30
39
  try {
31
- await findUnwrittenPrompts({ priority });
40
+ await findUnwrittenPrompts({ priority, projectPath: workspace.projectPath });
32
41
  } catch (error) {
33
42
  assertsError(error);
34
43
  console.error(colors.bgRed(`${error.name}`));
@@ -12,6 +12,8 @@ import {
12
12
  CODER_GIT_SYNC_DESCRIPTION,
13
13
  normalizeCoderGitSyncCliOptions,
14
14
  } from '../common/coderGitSyncCliOptions';
15
+ import { $preflightWorkspaceRepository } from '../common/workspaceRepository';
16
+ import { addWorkspaceRepositoryOptions } from '../common/workspaceRepositoryCliOptions';
15
17
  import { handleActionErrors } from '../common/handleActionErrors';
16
18
  import type { BoilerplateCount } from './boilerplateCount';
17
19
  import {
@@ -59,6 +61,8 @@ export function $initializeCoderGenerateBoilerplatesCommand(program: Program): $
59
61
  );
60
62
  addCoderGitSyncOptions(command);
61
63
 
64
+ addWorkspaceRepositoryOptions(command);
65
+
62
66
  command.action(
63
67
  handleActionErrors(async (cliOptions) => {
64
68
  const { count: countOption, template: templateOption } = cliOptions as {
@@ -68,14 +72,18 @@ export function $initializeCoderGenerateBoilerplatesCommand(program: Program): $
68
72
 
69
73
  const boilerplateCount = parseBoilerplateCount(countOption);
70
74
  const gitSync = normalizeCoderGitSyncCliOptions(cliOptions as CoderGitSyncCliOptions);
71
- const projectPath = process.cwd();
75
+ const workspace = await $preflightWorkspaceRepository({
76
+ policy: 'mutate',
77
+ isAskingQuestionsEnabled: cliOptions.questions,
78
+ });
79
+ const { projectPath } = workspace;
72
80
 
73
81
  // Note: Import the git synchronization dynamically to keep the CLI fast for runs without `--commit`
74
82
  const { $commitCoderChanges, $startCoderGitSync } = await import(
75
83
  '../../../../scripts/run-codex-prompts/git/coderGitSync'
76
84
  );
77
85
 
78
- const commitScope = await $startCoderGitSync({ gitSync, projectPath });
86
+ const commitScope = await $startCoderGitSync({ gitSync, workspace });
79
87
 
80
88
  await generatePromptBoilerplate({
81
89
  projectPath,
@@ -107,7 +115,7 @@ export async function generatePromptBoilerplate({
107
115
  readonly projectPath: string;
108
116
  readonly boilerplateCount: BoilerplateCount;
109
117
  readonly templateOption?: string;
110
- }): Promise<void> {
118
+ }): Promise<ReadonlyArray<string>> {
111
119
  const { filesCount, promptsPerFileCount } = boilerplateCount;
112
120
 
113
121
  // Note: Import these dynamically to avoid circular dependencies and keep CLI fast
@@ -192,6 +200,7 @@ export async function generatePromptBoilerplate({
192
200
  ` Successfully created ${promptsCount} prompts in ${filesToCreate.length} prompt boilerplate files! `,
193
201
  ),
194
202
  );
203
+ return filesToCreate.map(({ filepath }) => filepath);
195
204
  }
196
205
 
197
206
  /**
@@ -0,0 +1,42 @@
1
+ import { join, relative } from 'path';
2
+ import type { WorkspaceRepositoryContext } from '../common/workspaceRepository';
3
+ import { ADAM_AGENT_BOOK_RELATIVE_PATH } from '../common/ensureAdamAgentBook';
4
+ import type { CoderReferencedArtifactStatus } from './coderReferencedArtifacts';
5
+ import { CODER_AGENTS_DIRECTORY_PATH } from './ensureCoderDeveloperAgentFile';
6
+ import type { CoderInitializationSummary } from './initializeCoderProjectConfiguration';
7
+
8
+ /**
9
+ * Restricts an explicit initialization commit to the initializer's write set, in repository-relative paths.
10
+ * The shared snapshot still excludes pre-existing files that initialization did not actually change.
11
+ *
12
+ * @private internal utility of the shared project initializer
13
+ */
14
+ export function getCoderInitializationCommitPaths(
15
+ workspace: WorkspaceRepositoryContext,
16
+ summary: CoderInitializationSummary,
17
+ boilerplatePaths: ReadonlyArray<string>,
18
+ ): ReadonlyArray<string> {
19
+ const artifacts: ReadonlyArray<{
20
+ readonly relativeFilePath: string;
21
+ readonly status: CoderReferencedArtifactStatus;
22
+ }> = [
23
+ { relativeFilePath: 'prompts/README.md', status: summary.promptsReadmeFileStatus },
24
+ {
25
+ relativeFilePath: `${CODER_AGENTS_DIRECTORY_PATH}/${ADAM_AGENT_BOOK_RELATIVE_PATH}`,
26
+ status: summary.adamAgentFileStatus,
27
+ },
28
+ { relativeFilePath: '.env', status: summary.envFileStatus },
29
+ { relativeFilePath: '.gitignore', status: summary.gitignoreFileStatus },
30
+ { relativeFilePath: 'package.json', status: summary.packageJsonFileStatus },
31
+ { relativeFilePath: '.vscode/settings.json', status: summary.vscodeSettingsFileStatus },
32
+ ...summary.referencedArtifactStatuses,
33
+ ];
34
+ return [
35
+ ...artifacts
36
+ .filter(({ status }) => status === 'created' || status === 'updated' || status === 'augmented')
37
+ .map(({ relativeFilePath }) => relativeFilePath),
38
+ ...boilerplatePaths,
39
+ ].map((path) => relative(workspace.repositoryRoot!, join(workspace.projectPath, path)).replace(/\\/gu, '/'));
40
+ }
41
+
42
+ // Note: [🟡] Code for initialization commit paths [getCoderInitializationCommitPaths](src/cli/cli-commands/coder/getCoderInitializationCommitPaths.ts) should never be published outside of `@promptbook/cli`
@@ -2,6 +2,7 @@ import { AGENTS_FILE_PATH } from './agentsFile';
2
2
  import { DEFAULT_BOILERPLATE_COUNT_OPTION_VALUE } from './boilerplateCount';
3
3
  import { COMMON_PROMPT_TEMPLATE_FILE_PATH } from './boilerplateTemplates';
4
4
  import { CODER_DEVELOPER_AGENT_FILE_PATH } from './ensureCoderDeveloperAgentFile';
5
+ import { CODER_PLANNER_AGENT_FILE_PATH } from './ensureCoderRoleAgentFile';
5
6
  import { formatDisplayPath } from './formatDisplayPath';
6
7
 
7
8
  /**
@@ -26,7 +27,7 @@ type CoderPackageJsonScriptDefinition = {
26
27
  /**
27
28
  * Project-relative paths of the artifacts the command points at.
28
29
  *
29
- * They are created only together with the script itself, never for a script the project already defines.
30
+ * Non-role artifacts are created with newly added scripts; role Books are always initialized when missing.
30
31
  */
31
32
  readonly referencedArtifactPaths: ReadonlyArray<string>;
32
33
  };
@@ -49,11 +50,15 @@ const DEFAULT_CODER_PACKAGE_JSON_SCRIPT_DEFINITIONS: ReadonlyArray<CoderPackageJ
49
50
  scriptCommand: `npx ptbk coder add --template ${formatCoderScriptFilePath(COMMON_PROMPT_TEMPLATE_FILE_PATH)}`,
50
51
  referencedArtifactPaths: [COMMON_PROMPT_TEMPLATE_FILE_PATH],
51
52
  },
53
+ {
54
+ scriptName: 'coder:plan',
55
+ scriptCommand: 'npx ptbk coder plan --harness openai-codex',
56
+ referencedArtifactPaths: [CODER_PLANNER_AGENT_FILE_PATH, COMMON_PROMPT_TEMPLATE_FILE_PATH],
57
+ },
52
58
  {
53
59
  scriptName: 'coder:run',
54
60
  scriptCommand: [
55
61
  'npx ptbk coder run --harness openai-codex --thinking-level max',
56
- `--agent ${formatDisplayPath(CODER_DEVELOPER_AGENT_FILE_PATH)}`,
57
62
  `--context ${formatDisplayPath(AGENTS_FILE_PATH)}`,
58
63
  `--test "npm run ${CODER_TEST_SCRIPT_NAME}" --test-before yes-and-fix`,
59
64
  ].join(' '),