@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,265 @@
1
+ import { execFile } from 'child_process';
2
+ import { lstat, realpath, stat } from 'fs/promises';
3
+ import { dirname, join, resolve } from 'path';
4
+ import { spaceTrim } from 'spacetrim';
5
+ import { promisify } from 'util';
6
+ import { EnvironmentMismatchError } from '../../../errors/EnvironmentMismatchError';
7
+ import { NotAllowed } from '../../../errors/NotAllowed';
8
+ import { loadPromptsModule } from '../../common/loadPromptsModule';
9
+ import type { NormalizedQuestionsCliOptions } from './questionsCliOptions';
10
+
11
+ /** Shell-free Git execution, also usable from the packaged CLI. */
12
+ const EXECUTE_FILE = promisify(execFile);
13
+
14
+ /**
15
+ * Resolved project directory and its enclosing working tree. Project artifacts belong to `projectPath`;
16
+ * Git paths and synchronization belong to `repositoryRoot`, which may be an enclosing monorepo.
17
+ *
18
+ * @private shared workspace context for Coder and workspace server commands
19
+ */
20
+ export type WorkspaceRepositoryContext = {
21
+ readonly projectPath: string;
22
+ readonly repositoryRoot?: string;
23
+ readonly gitDirectory?: string;
24
+ readonly repositoryStatus: 'missing' | 'reused' | 'initialized';
25
+ };
26
+
27
+ /**
28
+ * Command policy is separate from discovery: previews never initialize; explicit init needs no confirmation.
29
+ *
30
+ * @private shared workspace policy for Coder and workspace server commands
31
+ */
32
+ export type WorkspaceRepositoryPolicy = 'initialize' | 'mutate' | 'read-only';
33
+
34
+ /**
35
+ * Resolves the requested project once and discovers Git using Git itself, without requiring `HEAD`.
36
+ * Broken metadata, bare repositories, ownership errors and unavailable Git are failures, not missing repositories.
37
+ *
38
+ * @private shared workspace discovery for CLI commands
39
+ */
40
+ export async function $resolveWorkspaceRepository(
41
+ projectDirectory = process.cwd(),
42
+ ): Promise<WorkspaceRepositoryContext> {
43
+ const requestedPath = resolve(projectDirectory);
44
+ let projectPath: string;
45
+ try {
46
+ projectPath = await realpath(requestedPath);
47
+ if (!(await stat(projectPath)).isDirectory()) {
48
+ throw new EnvironmentMismatchError(`The project path \`${requestedPath}\` is not a directory.`);
49
+ }
50
+ } catch (error) {
51
+ throw new EnvironmentMismatchError(
52
+ spaceTrim(
53
+ `Cannot access project directory \`${requestedPath}\`. Check that it exists and is accessible.\n\n${describeWorkspaceError(
54
+ error,
55
+ )}`,
56
+ ),
57
+ );
58
+ }
59
+ return $inspectWorkspaceRepository(projectPath);
60
+ }
61
+
62
+ /**
63
+ * Checks the shared prerequisite before any project writes, Git synchronization, installation or startup.
64
+ * Only an affirmative interactive answer or an explicit initializer authorizes `git init`.
65
+ *
66
+ * @private shared workspace preflight for Coder and workspace server commands
67
+ */
68
+ export async function $preflightWorkspaceRepository(
69
+ options: {
70
+ readonly projectDirectory?: string;
71
+ readonly policy: WorkspaceRepositoryPolicy;
72
+ } & Partial<NormalizedQuestionsCliOptions>,
73
+ ): Promise<WorkspaceRepositoryContext> {
74
+ const workspace = await $resolveWorkspaceRepository(options.projectDirectory);
75
+ if (workspace.repositoryStatus !== 'missing') {
76
+ if (options.policy === 'initialize') {
77
+ console.info(
78
+ `Reusing Git repository \`${workspace.repositoryRoot}\` for project \`${workspace.projectPath}\`.`,
79
+ );
80
+ }
81
+ return workspace;
82
+ }
83
+
84
+ const recovery = spaceTrim(`
85
+ Run \`ptbk init\`, \`ptbk coder init\`, or \`git init\` in \`${workspace.projectPath}\`, then retry.
86
+ `);
87
+ const diagnostic = spaceTrim(`
88
+ No Git working tree contains project \`${workspace.projectPath}\`.
89
+
90
+ ${recovery}
91
+ `);
92
+ if (options.policy === 'read-only') {
93
+ console.warn(`Warning: ${diagnostic}`);
94
+ return workspace;
95
+ }
96
+ if (options.policy === 'mutate') {
97
+ if (
98
+ options.isAskingQuestionsEnabled === false ||
99
+ !process.stdin.isTTY ||
100
+ process.stdin.destroyed ||
101
+ process.stdin.readableEnded
102
+ ) {
103
+ throw new NotAllowed(
104
+ spaceTrim(
105
+ `${diagnostic}\n\nRepository initialization requires an interactive answer; \`--no-questions\` is not consent.`,
106
+ ),
107
+ );
108
+ }
109
+ console.info(`Target project directory: \`${workspace.projectPath}\`.`);
110
+ const { default: prompts } = await loadPromptsModule();
111
+ let answer: { readonly isInitializingRepository?: boolean };
112
+ try {
113
+ answer = await prompts({
114
+ type: 'confirm',
115
+ name: 'isInitializingRepository',
116
+ message: `Initialize a Git repository in ${workspace.projectPath}?`,
117
+ initial: false,
118
+ });
119
+ } catch (error) {
120
+ throw new NotAllowed(
121
+ spaceTrim(`
122
+ Git initialization confirmation failed. The command stopped before project setup.
123
+ ${recovery}
124
+
125
+ ${describeWorkspaceError(error)}
126
+ `),
127
+ );
128
+ }
129
+ if (answer.isInitializingRepository !== true) {
130
+ throw new NotAllowed(
131
+ spaceTrim(
132
+ `Git initialization was declined or cancelled. The command stopped before project setup.\n\n${recovery}`,
133
+ ),
134
+ );
135
+ }
136
+ }
137
+
138
+ // A parent repository may have appeared while the user answered. Recheck before creating metadata.
139
+ const recheckedWorkspace = await $inspectWorkspaceRepository(workspace.projectPath);
140
+ if (recheckedWorkspace.repositoryStatus !== 'missing') return recheckedWorkspace;
141
+ try {
142
+ await $runWorkspaceGit(workspace.projectPath, ['init']);
143
+ const initializedWorkspace = await $inspectWorkspaceRepository(workspace.projectPath);
144
+ if (!initializedWorkspace.repositoryRoot) {
145
+ throw new EnvironmentMismatchError('Git did not create a valid working tree.');
146
+ }
147
+ console.info(`Git repository initialized in \`${initializedWorkspace.repositoryRoot}\`.`);
148
+ return { ...initializedWorkspace, repositoryStatus: 'initialized' };
149
+ } catch (error) {
150
+ throw new EnvironmentMismatchError(
151
+ spaceTrim(`
152
+ Git initialization failed in \`${workspace.projectPath}\`.
153
+ Project scaffolding, harness installation and command execution have not started.
154
+ Git may have left partial metadata; inspect it and fix directory permissions before retrying.
155
+
156
+ ${describeWorkspaceError(error)}
157
+ `),
158
+ );
159
+ }
160
+ }
161
+
162
+ /** Discovers and validates a working tree at an already resolved project directory. */
163
+ async function $inspectWorkspaceRepository(projectPath: string): Promise<WorkspaceRepositoryContext> {
164
+ let flags: string;
165
+ try {
166
+ flags = await $runWorkspaceGit(projectPath, ['rev-parse', '--is-bare-repository', '--is-inside-work-tree']);
167
+ } catch (error) {
168
+ const details = describeWorkspaceError(error);
169
+ if (/fatal: not a git repository \(or any (?:of the )?parent/iu.test(details)) {
170
+ // Git can ignore a damaged `.git` directory and report no repository. Such metadata must be repaired,
171
+ // never replaced by init. This check supplements Git discovery; it is not the repository detector.
172
+ await $assertNoBrokenRepositoryMetadata(projectPath);
173
+ return { projectPath, repositoryStatus: 'missing' };
174
+ }
175
+ throw workspaceDiscoveryError(projectPath, error);
176
+ }
177
+ const [isBareRepository, isInsideWorkingTree] = flags.trim().split(/\r?\n/u);
178
+ if (isBareRepository === 'true' || isInsideWorkingTree !== 'true') {
179
+ throw new EnvironmentMismatchError(
180
+ spaceTrim(`
181
+ Project \`${projectPath}\` is in a bare repository or outside its Git working tree.
182
+ Use a working-tree checkout of the project. No repository was initialized.
183
+ `),
184
+ );
185
+ }
186
+ try {
187
+ // Normalize Git's path spelling to match the resolved project (including Windows separators
188
+ // and filesystem aliases) before comparing ancestor directories.
189
+ const repositoryRoot = await realpath(
190
+ (await $runWorkspaceGit(projectPath, ['rev-parse', '--show-toplevel'])).trim(),
191
+ );
192
+ // Git may skip damaged inner metadata and find a valid parent. Do not silently use that parent
193
+ // for a project whose own checkout needs repair.
194
+ await $assertNoBrokenRepositoryMetadata(projectPath, repositoryRoot);
195
+ const gitDirectory = (await $runWorkspaceGit(projectPath, ['rev-parse', '--absolute-git-dir'])).trim();
196
+ // Also validate the index and metadata, without refreshing the index or depending on an existing commit.
197
+ await $runWorkspaceGit(projectPath, ['status', '--porcelain', '--untracked-files=no']);
198
+ return { projectPath, repositoryRoot, gitDirectory, repositoryStatus: 'reused' };
199
+ } catch (error) {
200
+ throw workspaceDiscoveryError(projectPath, error);
201
+ }
202
+ }
203
+
204
+ /** Checks ancestors only to disambiguate genuinely absent metadata from broken or inaccessible metadata. */
205
+ async function $assertNoBrokenRepositoryMetadata(projectPath: string, repositoryRoot?: string): Promise<void> {
206
+ let directory = projectPath;
207
+ while (directory !== repositoryRoot) {
208
+ const metadataPath = join(directory, '.git');
209
+ try {
210
+ await lstat(metadataPath);
211
+ } catch (error) {
212
+ if ((error as NodeJS.ErrnoException).code !== 'ENOENT') throw workspaceDiscoveryError(projectPath, error);
213
+ const parentDirectory = dirname(directory);
214
+ if (parentDirectory === directory) return;
215
+ directory = parentDirectory;
216
+ continue;
217
+ }
218
+ throw new EnvironmentMismatchError(
219
+ spaceTrim(`
220
+ Git could not read repository metadata at \`${metadataPath}\` for project \`${projectPath}\`.
221
+ Repair the invalid or inaccessible metadata before retrying. No repository was initialized.
222
+ `),
223
+ );
224
+ }
225
+ }
226
+
227
+ /** Executes Git without a shell, optional index locks, or credential prompts. */
228
+ async function $runWorkspaceGit(projectPath: string, argumentsList: ReadonlyArray<string>): Promise<string> {
229
+ const result = await EXECUTE_FILE('git', [...argumentsList], {
230
+ cwd: projectPath,
231
+ env: { ...process.env, LC_ALL: 'C', GIT_OPTIONAL_LOCKS: '0', GIT_TERMINAL_PROMPT: '0' },
232
+ windowsHide: true,
233
+ maxBuffer: 8 * 1024 * 1024,
234
+ });
235
+ return result.stdout;
236
+ }
237
+
238
+ /** Translates discovery failures without ever treating an ownership or executable error as permission to init. */
239
+ function workspaceDiscoveryError(projectPath: string, error: unknown): EnvironmentMismatchError {
240
+ const details = describeWorkspaceError(error);
241
+ const isGitUnavailable = (error as NodeJS.ErrnoException)?.code === 'ENOENT';
242
+ const hint = isGitUnavailable
243
+ ? 'Git is not available on `PATH`. Install Git or fix `PATH`, then retry.'
244
+ : /dubious ownership|safe.directory/iu.test(details)
245
+ ? 'Git rejected repository ownership. Review the ownership and trust of this specific checkout before retrying.'
246
+ : 'Check repository metadata, permissions and Git configuration before retrying.';
247
+ return new EnvironmentMismatchError(
248
+ spaceTrim(`
249
+ Cannot inspect Git for project \`${projectPath}\`.
250
+ ${hint}
251
+ No repository was initialized and project setup has not started.
252
+
253
+ ${details}
254
+ `),
255
+ );
256
+ }
257
+
258
+ /** Extracts useful Git stderr or filesystem diagnostics from a process failure. */
259
+ function describeWorkspaceError(error: unknown): string {
260
+ const failure = error as { stderr?: string; message?: string };
261
+ return failure?.stderr?.trim() || failure?.message || String(error);
262
+ }
263
+
264
+ // Note: [🟡] Code for workspace Git preflight [workspaceRepository](src/cli/cli-commands/common/workspaceRepository.ts) should never be published outside of `@promptbook/cli`
265
+ // Note: [💞] Ignore a discrepancy between file name and exported helper names
@@ -0,0 +1,29 @@
1
+ import type { Command } from 'commander';
2
+ import { spaceTrim } from 'spacetrim';
3
+ import { addQuestionsOption } from './questionsCliOptions';
4
+
5
+ /**
6
+ * Shared explanation of the workspace prerequisite, independent of commit and synchronization settings.
7
+ * @private internal CLI help text
8
+ */
9
+ export const WORKSPACE_REPOSITORY_DESCRIPTION = spaceTrim(`
10
+ Workspace Git prerequisite:
11
+ - Workspace actions inspect the enclosing Git working tree, including worktrees and submodules
12
+ - ptbk init and ptbk coder init automatically initialize Git if it is missing; existing repositories are reused
13
+ - Other mutating actions ask once before initializing Git in the displayed project directory
14
+ - --no-questions and noninteractive input require an existing repository; recover with ptbk init, ptbk coder init, or git init
15
+ - Read-only inspection and --dry-run only warn when Git is missing and never initialize it
16
+ - --no-commit disables commits, not repository detection; a local repository needs no remote
17
+ `);
18
+
19
+ /**
20
+ * Adds shared Git help and the questions switch to every workspace command without duplicating existing options.
21
+ * @private internal registration helper for workspace CLI commands
22
+ */
23
+ export function addWorkspaceRepositoryOptions(command: Command): void {
24
+ if (!command.options.some((option) => option.long === '--no-questions')) addQuestionsOption(command);
25
+ command.addHelpText('after', `\n${WORKSPACE_REPOSITORY_DESCRIPTION}\n`);
26
+ }
27
+
28
+ // Note: [🟡] Code for workspace CLI options [workspaceRepositoryCliOptions](src/cli/cli-commands/common/workspaceRepositoryCliOptions.ts) should never be published outside of `@promptbook/cli`
29
+ // Note: [💞] Ignore a discrepancy between file name and exported helper names
@@ -171,6 +171,18 @@ export class TeamCommitmentDefinition extends BaseCommitmentDefinition<'TEAM'> {
171
171
 
172
172
  Registers teammate agents that the current agent can consult via tools.
173
173
 
174
+ The primary agent sends a question and relevant context to a teammate and receives an attributed answer.
175
+ Each teammate uses its own Book. Declaring a team makes advisers available when relevant; it does not
176
+ merge their rules into the primary agent or start every teammate automatically.
177
+
178
+ In \`ptbk coder run\` and \`ptbk coder plan\`, TEAM entries in the selected Book, its ancestors and imports
179
+ use the existing reference rules: \`@Name\`, \`{Agent Name}\`, \`{./lawyer.book}\`, project paths such as
180
+ \`{agents/lawyer.book}\`, and HTTP(S) Book URLs. Local advisers require no Agents Server. A remote Book
181
+ must be readable through its normal endpoint; private or inaccessible sources return errors.
182
+ Coding harnesses expose scoped command tools; planning uses restricted host tools and currently requires
183
+ OpenAI Codex. Planning restrictions apply to every adviser, including custom Developer Books.
184
+ The primary agent retains responsibility for the task, PRD proposals and final output.
185
+
174
186
  ## Examples
175
187
 
176
188
  \`\`\`book
@@ -216,22 +228,32 @@ export class TeamCommitmentDefinition extends BaseCommitmentDefinition<'TEAM'> {
216
228
  >;
217
229
 
218
230
  const resolvedTeammates: TeamTeammate[] = resolveTeamTeammateLabels(trimmedContent, teammates);
231
+ const toolUrls = new Map(existingTeammates.map((teammate) => [teammate.toolName, teammate.url]));
219
232
 
220
233
  const teamEntries: TeamToolEntry[] = resolvedTeammates.map((teammate) => {
221
234
  const profile = preResolvedProfiles[teammate.url];
222
235
  const resolvedLabel = profile?.agentName || teammate.label;
223
236
  const existingTeammate = existingTeammates.find((entry) => entry.url === teammate.url);
237
+ const baseToolName = existingTeammate?.toolName || createTeamToolName(teammate.url, resolvedLabel);
238
+ let toolName = baseToolName;
239
+ let suffix = 1;
240
+ // Explicit paths can identify distinct Books with the same display name or normalized label.
241
+ while (toolUrls.has(toolName) && toolUrls.get(toolName) !== teammate.url) {
242
+ toolName = `${baseToolName}_${++suffix}`;
243
+ }
244
+ toolUrls.set(toolName, teammate.url);
224
245
  return {
225
- toolName: (existingTeammate?.toolName ||
226
- createTeamToolName(teammate.url, resolvedLabel)) as string_javascript_name,
246
+ toolName: toolName as string_javascript_name,
227
247
  teammate: { ...teammate, label: resolvedLabel },
228
248
  agentName,
229
249
  description: profile?.personaDescription || null,
230
250
  };
231
251
  });
232
252
 
233
- for (const entry of teamEntries) {
234
- registerTeamTool(entry);
253
+ if (!requirements._metadata?.isTeamToolRegistrationDisabled) {
254
+ for (const entry of teamEntries) {
255
+ registerTeamTool(entry);
256
+ }
235
257
  }
236
258
 
237
259
  const existingTools: readonly LlmToolDefinition[] = requirements.tools || [];
@@ -7,4 +7,6 @@ import { createLazyModuleLoader } from '../../utils/misc/createLazyModuleLoader'
7
7
  *
8
8
  * @private internal utility of `loadArchive` and `saveArchive`
9
9
  */
10
- export const loadJsZipModule = createLazyModuleLoader(() => import('jszip'));
10
+ export const loadJsZipModule: () => Promise<{ default: typeof import('jszip') }> = createLazyModuleLoader(
11
+ () => import('jszip'),
12
+ );