@promptbook/cli 0.114.0-41 → 0.114.0-47

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 +921 -830
  164. package/src/version.ts +2 -2
  165. package/src/versions.txt +7 -1
  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
@@ -1,4 +1,5 @@
1
1
  import colors from 'colors';
2
+ import { NotAllowed } from '../../../errors/NotAllowed';
2
3
  import {
3
4
  Command as Program /* <- Note: [🔸] Using Program because Command is misleading name */,
4
5
  Option,
@@ -17,6 +18,8 @@ import {
17
18
  CODER_GIT_SYNC_DESCRIPTION,
18
19
  normalizeCoderGitSyncCliOptions,
19
20
  } from '../common/coderGitSyncCliOptions';
21
+ import { $preflightWorkspaceRepository } from '../common/workspaceRepository';
22
+ import { addWorkspaceRepositoryOptions } from '../common/workspaceRepositoryCliOptions';
20
23
  import { handleActionErrors } from '../common/handleActionErrors';
21
24
 
22
25
  /**
@@ -74,6 +77,8 @@ export function $initializeCoderVerifyCommand(program: Program): $side_effect {
74
77
  );
75
78
  addCoderGitSyncOptions(command);
76
79
 
80
+ addWorkspaceRepositoryOptions(command);
81
+
77
82
  command.action(
78
83
  handleActionErrors(async (cliOptions) => {
79
84
  const { order, ignore } = cliOptions as {
@@ -83,11 +88,23 @@ export function $initializeCoderVerifyCommand(program: Program): $side_effect {
83
88
 
84
89
  const gitSync = normalizeCoderGitSyncCliOptions(cliOptions as CoderGitSyncCliOptions);
85
90
 
91
+ const workspace = await $preflightWorkspaceRepository({
92
+ policy: 'mutate',
93
+ isAskingQuestionsEnabled: cliOptions.questions,
94
+ });
95
+ if (cliOptions.questions === false) {
96
+ throw new NotAllowed(
97
+ spaceTrim(
98
+ '`ptbk coder verify` requires answers before changing PRD statuses or archiving files. Run it without `--no-questions` in an interactive terminal.',
99
+ ),
100
+ );
101
+ }
102
+
86
103
  // Note: Import the main function dynamically to avoid loading heavy dependencies until needed
87
104
  const { verifyPrompts } = await import('../../../../scripts/verify-prompts/verify-prompts');
88
105
 
89
106
  try {
90
- await verifyPrompts({ order, ignore, gitSync });
107
+ await verifyPrompts({ order, ignore, gitSync, workspace });
91
108
  } catch (error) {
92
109
  console.error(colors.bgRed('Prompt verification failed:'), error);
93
110
  return process.exit(1);
@@ -3,6 +3,7 @@ import type {
3
3
  } from 'commander';
4
4
  import { spaceTrim } from 'spacetrim';
5
5
  import type { $side_effect } from '../../utils/organization/$side_effect';
6
+ import { WORKSPACE_REPOSITORY_DESCRIPTION } from './common/workspaceRepositoryCliOptions';
6
7
  import { $requireCliSubcommand } from '../common/$requireCliSubcommand';
7
8
  import { $initializeCoderAddCommand } from './coder/add';
8
9
  import { $initializeCoderFindFreshEmojiTagCommand } from './coder/find-fresh-emoji-tags';
@@ -12,6 +13,7 @@ import { $initializeCoderGenerateBoilerplatesCommand } from './coder/generate-bo
12
13
  import { $initializeCoderInitCommand } from './coder/init';
13
14
  import { $initializeCoderListCommand } from './coder/list';
14
15
  import { $initializeCoderPingCommand } from './coder/ping';
16
+ import { $initializeCoderPlanCommand } from './coder/plan';
15
17
  import { $initializeCoderRunCommand } from './coder/run';
16
18
  import { $initializeCoderServerCommand } from './coder/server';
17
19
  import { $initializeCoderVerifyCommand } from './coder/verify';
@@ -22,6 +24,7 @@ import { $initializeCoderVerifyCommand } from './coder/verify';
22
24
  * The coder command provides utilities for automated coding:
23
25
  * - init: Initialize coder configuration in current project
24
26
  * - add: Add one ready-to-run prompt file to the queue
27
+ * - plan: Discuss features with Planner and author reviewed PRDs
25
28
  * - generate-boilerplates: Generate prompt boilerplate files
26
29
  * - find-refactor-candidates: Find files that need refactoring
27
30
  * - list: List ready prompts in priority order without running them
@@ -43,6 +46,7 @@ export function $initializeCoderCommand(program: Program): $side_effect {
43
46
  Subcommands:
44
47
  - init: Initialize coder configuration in current project
45
48
  - add: Add one ready-to-run prompt file to the queue
49
+ - plan: Discuss features with Planner and author reviewed PRDs
46
50
  - generate-boilerplates: Generate prompt boilerplate files
47
51
  - find-refactor-candidates: Find files that need refactoring
48
52
  - find-unwritten: List prompt sections that still need to be authored
@@ -55,9 +59,12 @@ export function $initializeCoderCommand(program: Program): $side_effect {
55
59
  `),
56
60
  );
57
61
 
62
+ coderCommand.addHelpText('after', `\n${WORKSPACE_REPOSITORY_DESCRIPTION}\n`);
63
+
58
64
  // Register all subcommands
59
65
  $initializeCoderInitCommand(coderCommand);
60
66
  $initializeCoderAddCommand(coderCommand);
67
+ $initializeCoderPlanCommand(coderCommand);
61
68
  $initializeCoderGenerateBoilerplatesCommand(coderCommand);
62
69
  $initializeCoderFindRefactorCandidatesCommand(coderCommand);
63
70
  $initializeCoderFindUnwrittenCommand(coderCommand);
@@ -7,6 +7,7 @@ import { parseAgentSource } from '../../../book-2.0/agent-source/parseAgentSourc
7
7
  import type { string_book } from '../../../book-2.0/agent-source/string_book';
8
8
  import type { TeammateProfile } from '../../../book-2.0/agent-source/TeammateProfileResolver';
9
9
  import { NotFoundError } from '../../../errors/NotFoundError';
10
+ import { NotAllowed } from '../../../errors/NotAllowed';
10
11
  import { ParseError } from '../../../errors/ParseError';
11
12
  import { isValidAgentUrl } from '../../../utils/validators/url/isValidAgentUrl';
12
13
  import { ADAM_AGENT_BOOK_RELATIVE_PATH, ensureAdamAgentBook } from './ensureAdamAgentBook';
@@ -33,6 +34,8 @@ const LOCAL_AGENT_URL_PREFIX = 'https://local-agent.promptbook/';
33
34
  * Directories which cannot contain project-owned agent definitions.
34
35
  */
35
36
  const IGNORED_DIRECTORY_NAMES = new Set(['.git', 'node_modules']);
37
+ /** Bound remote profile discovery even before a consultation's own timeout has started. */
38
+ const REMOTE_BOOK_TIMEOUT_MS = 30_000;
36
39
 
37
40
  /**
38
41
  * Reads repository books and indexes their first-line names for CLI reference resolution.
@@ -48,7 +51,12 @@ export class LocalAgentBookCollection {
48
51
  public readonly createdAgentBookPaths: string[] = [];
49
52
 
50
53
  /** Creates a collection rooted at the primary book's directory. */
51
- public constructor(private readonly agentDirectoryPath: string, private readonly currentWorkingDirectory: string) {}
54
+ public constructor(
55
+ private readonly agentDirectoryPath: string,
56
+ private readonly currentWorkingDirectory: string,
57
+ private readonly isInitializationAllowed = true,
58
+ private readonly signal?: AbortSignal,
59
+ ) {}
52
60
 
53
61
  /** Discovers nested books, including the hidden `.core` directory. */
54
62
  public async initialize(): Promise<void> {
@@ -95,6 +103,15 @@ export class LocalAgentBookCollection {
95
103
  /** Resolves a name, a path relative to its declaring book, or a path relative to the CLI cwd. */
96
104
  public async resolveReference(reference: string, declaringBook: LocalAgentBook): Promise<string> {
97
105
  const isRemoteReference = Boolean(isValidAgentUrl(reference));
106
+ // Remote instructions cannot name host-local Books or manufacture internal collection identities.
107
+ if (
108
+ !declaringBook.filePath &&
109
+ (reference.startsWith(LOCAL_AGENT_URL_PREFIX) || (!isRemoteReference && !/^\.{1,2}[\\/]/.test(reference)))
110
+ ) {
111
+ throw new NotAllowed(
112
+ spaceTrim(`Remote Book \`${declaringBook.url}\` cannot access local reference \`${reference}\`.`),
113
+ );
114
+ }
98
115
  if (isRemoteReference) {
99
116
  return reference;
100
117
  }
@@ -137,13 +154,21 @@ export class LocalAgentBookCollection {
137
154
  }
138
155
 
139
156
  /** Loads a referenced remote book, while keeping local identifiers entirely inside the collection. */
140
- public async getBook(url: string): Promise<LocalAgentBook> {
157
+ public async getBook(url: string, signal = this.signal): Promise<LocalAgentBook> {
158
+ signal?.throwIfAborted();
141
159
  const existingBook = this.booksByUrl.get(url);
142
160
  if (existingBook) {
143
161
  return existingBook;
144
162
  }
145
163
  if (url === this.getAdamAgentUrl()) {
146
164
  const adamBookPath = join(this.agentDirectoryPath, ADAM_AGENT_BOOK_RELATIVE_PATH);
165
+ if (!this.isInitializationAllowed) {
166
+ throw new NotFoundError(
167
+ spaceTrim(
168
+ `Missing inherited Adam Book at \`${adamBookPath}\`. Run \`ptbk coder init\`, or prepare the custom Book's ancestor explicitly.`,
169
+ ),
170
+ );
171
+ }
147
172
  if ((await ensureAdamAgentBook(this.agentDirectoryPath)) === 'created') {
148
173
  this.createdAgentBookPaths.push(adamBookPath);
149
174
  }
@@ -159,23 +184,36 @@ export class LocalAgentBookCollection {
159
184
  if (!/\.(book|md)$/i.test(bookUrl.pathname) && !bookUrl.pathname.endsWith('/api/book')) {
160
185
  bookUrl.pathname = bookUrl.pathname.replace(/\/$/, '') + '/api/book';
161
186
  }
162
- const response = await fetch(bookUrl.href);
163
- if (!response.ok) {
164
- throw new NotFoundError(
165
- spaceTrim(`Cannot load agent book \`${url}\`: **${response.status} ${response.statusText}**.`),
166
- );
167
- }
168
- let source: unknown;
169
- if (response.headers.get('content-type')?.includes('application/json')) {
170
- const payload: unknown = await response.json();
171
- source = typeof payload === 'string' ? payload : (payload as { source?: unknown } | null)?.source;
172
- } else {
173
- source = await response.text();
174
- }
175
- if (typeof source !== 'string') {
176
- throw new ParseError(spaceTrim(`Agent book \`${url}\` did not return a text source.`));
187
+ const controller = new AbortController();
188
+ const cancel = (): void => controller.abort(signal?.reason);
189
+ signal?.addEventListener('abort', cancel, { once: true });
190
+ if (signal?.aborted) cancel();
191
+ const timeout = setTimeout(
192
+ () => controller.abort(new NotAllowed(spaceTrim(`Remote TEAM Book \`${url}\` timed out.`))),
193
+ REMOTE_BOOK_TIMEOUT_MS,
194
+ );
195
+ try {
196
+ const response = await fetch(bookUrl.href, { signal: controller.signal });
197
+ if (!response.ok) {
198
+ throw new NotFoundError(
199
+ spaceTrim(`Cannot load agent book \`${url}\`: **${response.status} ${response.statusText}**.`),
200
+ );
201
+ }
202
+ let source: unknown;
203
+ if (response.headers.get('content-type')?.includes('application/json')) {
204
+ const payload: unknown = await response.json();
205
+ source = typeof payload === 'string' ? payload : (payload as { source?: unknown } | null)?.source;
206
+ } else {
207
+ source = await response.text();
208
+ }
209
+ if (typeof source !== 'string' || !source.trim() || source.includes('\0')) {
210
+ throw new ParseError(spaceTrim(`Agent book \`${url}\` did not return a text source.`));
211
+ }
212
+ return this.registerBook(url, source);
213
+ } finally {
214
+ clearTimeout(timeout);
215
+ signal?.removeEventListener('abort', cancel);
177
216
  }
178
- return this.registerBook(url, source);
179
217
  }
180
218
 
181
219
  /** Adds a book under its normalized first-line name and preserves the display name for TEAM. */
@@ -34,7 +34,7 @@ export const CODER_GIT_SYNC_DESCRIPTION = spaceTrim(`
34
34
  * Registers the shared `--commit`, `--auto-push` and `--auto-pull` flags on a `ptbk coder` command.
35
35
  *
36
36
  * Note: Unlike `ptbk coder run`, which commits by default and opts out through `--no-commit`,
37
- * these commands never touch git unless the flags are used explicitly.
37
+ * these commands only mutate Git when the flags are used explicitly. Workspace detection always runs.
38
38
  *
39
39
  * @private internal utility of `promptbookCli`
40
40
  */
@@ -1,6 +1,7 @@
1
1
  import { spaceTrim } from 'spacetrim';
2
2
  import type { AgentReferenceResolver } from '../../../book-2.0/agent-source/AgentReferenceResolver';
3
3
  import { extractAgentReferenceTokens } from '../../../book-2.0/agent-source/extractAgentReferenceTokens';
4
+ import { parseTeamCommitmentContent } from '../../../book-2.0/agent-source/parseTeamCommitment';
4
5
  import {
5
6
  createPseudoAgentUrl,
6
7
  isPseudoAgentAllowedInCommitment,
@@ -40,6 +41,12 @@ export function createLocalAgentReferenceResolver(
40
41
 
41
42
  return {
42
43
  resolveCommitmentContent: async (commitmentType, content) => {
44
+ // Bare TEAM URLs bypass compact token replacement, but must obey the same remote/local boundary.
45
+ if (commitmentType === 'TEAM') {
46
+ for (const teammate of parseTeamCommitmentContent(content)) {
47
+ await collection.resolveReference(teammate.url, declaringBook);
48
+ }
49
+ }
43
50
  const tokens = extractAgentReferenceTokens(content);
44
51
  if (tokens.length === 0) {
45
52
  if (commitmentType !== 'TEAM' && content.trim()) {
@@ -18,8 +18,12 @@ import { LocalAgentBookCollection, type LocalAgentBook } from './LocalAgentBookC
18
18
  * @private internal type of CLI agent resolution
19
19
  */
20
20
  export type ResolvedLocalAgentSource = {
21
+ /** Canonical identity used to bound recursive TEAM consultations. */
22
+ readonly agentUrl: string;
21
23
  readonly agentSource: string_book;
22
24
  readonly agentReferenceResolver: AgentReferenceResolver;
25
+ /** Resolves another Book in this collection, retaining its own inheritance and reference locations. */
26
+ readonly resolveAgentSource: (url: string, signal?: AbortSignal) => Promise<ResolvedLocalAgentSource>;
23
27
  /** Newly created books which the coder may include in its initialization commit. */
24
28
  readonly createdAgentBookPaths: ReadonlyArray<string>;
25
29
  };
@@ -32,8 +36,14 @@ export type ResolvedLocalAgentSource = {
32
36
  export async function resolveLocalAgentSource(
33
37
  agentBookPath: string,
34
38
  currentWorkingDirectory: string,
39
+ options: { readonly isInitializationAllowed?: boolean; readonly signal?: AbortSignal } = {},
35
40
  ): Promise<ResolvedLocalAgentSource> {
36
- const collection = new LocalAgentBookCollection(dirname(agentBookPath), currentWorkingDirectory);
41
+ const collection = new LocalAgentBookCollection(
42
+ dirname(agentBookPath),
43
+ currentWorkingDirectory,
44
+ options.isInitializationAllowed,
45
+ options.signal,
46
+ );
37
47
  await collection.initialize();
38
48
  const primaryBook = await collection.readBook(agentBookPath);
39
49
  const adamAgentUrl = collection.getAdamAgentUrl();
@@ -42,7 +52,9 @@ export async function resolveLocalAgentSource(
42
52
  async function resolveBook(
43
53
  book: LocalAgentBook,
44
54
  inheritancePath: ReadonlyArray<string> = [],
55
+ signal = options.signal,
45
56
  ): Promise<string_book> {
57
+ signal?.throwIfAborted();
46
58
  if (inheritancePath.length > DEFAULT_MAX_RECURSION) {
47
59
  throw new ParseError(
48
60
  spaceTrim(
@@ -59,28 +71,36 @@ export async function resolveLocalAgentSource(
59
71
  currentAgentUrl: book.url,
60
72
  inheritancePath,
61
73
  agentSourceImporter: async (url, context) =>
62
- resolveBook(await collection.getBook(url), context.importAgentOptions.inheritancePath),
74
+ resolveBook(await collection.getBook(url, signal), context.importAgentOptions.inheritancePath, signal),
63
75
  });
64
76
  }
65
77
 
66
- return {
67
- agentSource: await resolveBook(primaryBook),
68
- agentReferenceResolver: {
69
- ...createLocalAgentReferenceResolver(collection, primaryBook),
70
- resolveTeammateProfile: async (url) => {
71
- if (isPseudoAgentUrl(url)) {
72
- return null;
73
- }
74
- const book = await collection.getBook(url);
75
- const parsedSource = parseAgentSource(await resolveBook(book));
76
- return {
77
- agentName: book.profile.agentName,
78
- personaDescription: parsedSource.personaDescription,
79
- };
78
+ /** Keeps the source loader and profiles scoped to this resolution, never to a global TEAM registry. */
79
+ async function resolveAgent(book: LocalAgentBook, signal = options.signal): Promise<ResolvedLocalAgentSource> {
80
+ return {
81
+ agentUrl: book.url,
82
+ agentSource: await resolveBook(book, [], signal),
83
+ agentReferenceResolver: {
84
+ ...createLocalAgentReferenceResolver(collection, book),
85
+ resolveTeammateProfile: async (url) => {
86
+ if (isPseudoAgentUrl(url)) {
87
+ return null;
88
+ }
89
+ const book = await collection.getBook(url, signal);
90
+ const parsedSource = parseAgentSource(await resolveBook(book, [], signal));
91
+ return {
92
+ agentName: book.profile.agentName,
93
+ personaDescription: parsedSource.personaDescription,
94
+ };
95
+ },
80
96
  },
81
- },
82
- createdAgentBookPaths: collection.createdAgentBookPaths,
83
- };
97
+ resolveAgentSource: async (url, consultationSignal) =>
98
+ resolveAgent(await collection.getBook(url, consultationSignal || signal), consultationSignal || signal),
99
+ createdAgentBookPaths: collection.createdAgentBookPaths,
100
+ };
101
+ }
102
+
103
+ return resolveAgent(primaryBook);
84
104
  }
85
105
 
86
106
  /**
@@ -0,0 +1,91 @@
1
+ import { spaceTrim } from 'spacetrim';
2
+ import type { RunOptions } from '../../../../scripts/run-codex-prompts/cli/RunOptions';
3
+ import { isTestBeforeMode } from '../../../../scripts/run-codex-prompts/testing/TestBeforeMode';
4
+ import { DatabaseError } from '../../../errors/DatabaseError';
5
+ import { NotAllowed } from '../../../errors/NotAllowed';
6
+
7
+ /**
8
+ * Validates cross-flag constraints before workspace setup or the run starts.
9
+ * @private shared validation for Coder execution commands
10
+ */
11
+ export function validateCoderRunOptions(options: RunOptions): void {
12
+ if (!isTestBeforeMode(options.testBefore ?? 'no')) {
13
+ throw new NotAllowed(
14
+ spaceTrim(`
15
+ Invalid ${'`--test-before`'} mode: \`${String(options.testBefore)}\`.
16
+
17
+ Use one of: \`no\`, \`yes-and-fail\`, \`yes-and-fix\`.
18
+ `),
19
+ );
20
+ }
21
+
22
+ if (options.allowDestructiveAutoMigrate && !options.autoMigrate) {
23
+ throw new DatabaseError(
24
+ spaceTrim(`
25
+ Flag \`--allow-destructive-auto-migrate\` requires \`--auto-migrate\`.
26
+ `),
27
+ );
28
+ }
29
+
30
+ if (options.noCommit && !options.waitForUser && options.gitChanges !== 'ignore') {
31
+ throw new NotAllowed(
32
+ spaceTrim(`
33
+ Flag \`--no-commit\` requires \`--git-changes ignore\` when running in auto mode (the default; pass \`--no-auto\` for interactive confirmation).
34
+
35
+ Without commits, the next prompt round would fail the clean working tree check.
36
+ `),
37
+ );
38
+ }
39
+
40
+ if (options.autoPull && options.noCommit && !options.dryRun) {
41
+ throw new NotAllowed(
42
+ spaceTrim(`
43
+ Flag \`--auto-pull\` requires commits, so it cannot be combined with \`--no-commit\`.
44
+
45
+ Auto-pull keeps the repository up to date between prompt rounds, which requires each successful round to end with a clean committed working tree.
46
+ `),
47
+ );
48
+ }
49
+
50
+ if (options.isIsolated && options.noCommit) {
51
+ throw new NotAllowed(
52
+ spaceTrim(`
53
+ Flag \`--isolate\` cannot be combined with \`--no-commit\`.
54
+
55
+ An isolated task is implemented in a temporary worktree and reaches the original branch only through a merge, which requires the round to end with a commit.
56
+ `),
57
+ );
58
+ }
59
+
60
+ if (options.isIsolated && options.gitChanges === 'continue') {
61
+ throw new NotAllowed(
62
+ spaceTrim(`
63
+ Flag \`--isolate\` cannot be combined with \`--git-changes continue\`.
64
+
65
+ An isolated task is implemented in a fresh temporary worktree checked out from the last commit, so the uncommitted changes of the interrupted prompt would be left behind instead of being continued.
66
+ `),
67
+ );
68
+ }
69
+
70
+ if (options.gitChanges === 'continue' && options.testBefore === 'yes-and-fix') {
71
+ throw new NotAllowed(
72
+ spaceTrim(`
73
+ Flag \`--git-changes continue\` cannot be combined with \`--test-before yes-and-fix\`.
74
+
75
+ An interrupted prompt already has changes in progress, so there is no unmodified project state for pre-coding verification to repair.
76
+ `),
77
+ );
78
+ }
79
+
80
+ if (options.limit !== undefined && (!Number.isInteger(options.limit) || options.limit <= 0)) {
81
+ throw new NotAllowed(
82
+ spaceTrim(`
83
+ Flag \`--limit\` expects a positive integer.
84
+
85
+ Received: \`${options.limit}\`
86
+ `),
87
+ );
88
+ }
89
+ }
90
+
91
+ // Note: [🟡] Code for Coder run validation [validateCoderRunOptions](src/cli/cli-commands/common/validateCoderRunOptions.ts) should never be published outside of `@promptbook/cli`
@@ -0,0 +1,46 @@
1
+ <!-- cspell:ignore pathspecs noninteractive -->
2
+
3
+ # Workspace Git prerequisite
4
+
5
+ Every registered Coder workspace action uses `$preflightWorkspaceRepository` before project writes,
6
+ Git synchronization, harness setup, execution, or server startup. Command argument validation runs first;
7
+ help, version and usage errors do not run preflight. The same helper is available for the subsequent
8
+ workspace `ptbk server` entrypoint and its `ptbk coder server` alias.
9
+
10
+ | Registered action | Policy | Reason |
11
+ | --- | --- | --- |
12
+ | `ptbk init`, `coder init`, `coder initialize` | Initialization | Explicit authorization to create missing Git metadata, then reuse the existing additive initializer. |
13
+ | `coder add` | Potentially mutating | Authors a prompt in the project queue. |
14
+ | `coder plan` | Potentially mutating | Creates a planning workspace, runs a harness and saves reviewed PRDs. |
15
+ | `coder generate-boilerplates` | Potentially mutating | Generates starter prompt files and scan caches. |
16
+ | `coder find-refactor-candidates` | Potentially mutating | Scans source and generates refactor prompts. |
17
+ | `coder run` | Potentially mutating | Runs tests and a harness, updates task state and may synchronize Git. |
18
+ | `coder ping` | Potentially mutating | May install a harness, augment ignore rules, and create temporary harness artifacts. |
19
+ | `coder server` | Potentially mutating | Starts the server and runner; browser edits also mutate PRDs. |
20
+ | `coder verify` | Potentially mutating | Updates statuses, writes repair prompts and archives completed files. There is no separate archive action. |
21
+ | `coder list` | Read-only | Lists ready prompts and optional runner filters. |
22
+ | `coder find-unwritten` | Read-only | Inspects authoring placeholders. |
23
+ | `coder find-fresh-emoji-tags` | Read-only | Scans existing tags without writing its optional cache. |
24
+ | `coder run --dry-run`, `coder server --dry-run` | Read-only preview | Prints authoring work without installation, writes or server startup. |
25
+
26
+ Discovery resolves the project directory once and uses Git to find the enclosing working tree, including
27
+ linked worktrees and submodules. The project directory stays separate from the repository root: Books,
28
+ prompts and initialization artifacts stay in the requested project; Git snapshots and pathspecs use the
29
+ repository root. Isolated execution maps that project location into its temporary working tree and copies the
30
+ project environment there. Unborn branches are valid. Discovery never requires a remote or a Git identity.
31
+
32
+ Only genuinely missing repositories may be initialized. Missing Git, bare repositories, broken metadata,
33
+ permission errors and ownership failures stop with diagnostics; no global `safe.directory` changes are made.
34
+ Damaged inner metadata is rejected even when Git skips it and discovers a valid parent repository.
35
+ Read-only operations warn for absent repositories. Other actions ask once in a terminal and continue after
36
+ successful initialization. Declining or cancelling stops before normal effects. `--no-questions` and
37
+ noninteractive input fail immediately and suggest `ptbk init`, `ptbk coder init`, or `git init`.
38
+
39
+ Explicit initialization needs no Git confirmation, even with `--no-questions`. Existing Git metadata is reused
40
+ without staging, committing or changing configuration. Optional `--auto-pull` runs after Git validation;
41
+ `--commit` uses the existing scoped change snapshot, including before the first commit. Unrelated staged,
42
+ unstaged and untracked files stay outside initialization commits. Remote synchronization still needs the
43
+ user's configured remote and identity. Partial initialization failures report completed setup steps.
44
+
45
+ Tests use temporary repositories and mocked prompts or harnesses. The packed CLI fixture exercises the
46
+ top-level initializer and no-repository recovery outside this monorepo without network access.