@promptbook/cli 0.114.0-32 → 0.114.0-34

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 (177) hide show
  1. package/esm/index.es.js +1417 -400
  2. package/esm/index.es.js.map +1 -1
  3. package/esm/scripts/run-codex-prompts/common/createFreeDiskSpaceGuard.d.ts +25 -0
  4. package/esm/scripts/run-codex-prompts/common/formatUnknownErrorDetails.d.ts +4 -0
  5. package/esm/scripts/run-codex-prompts/common/resolveCoderAgent.d.ts +21 -3
  6. package/esm/scripts/run-codex-prompts/main/listCoderPrompts.d.ts +20 -0
  7. package/esm/scripts/run-codex-prompts/prompts/buildPromptRunTraceContent.d.ts +77 -0
  8. package/esm/scripts/run-codex-prompts/prompts/buildPromptRunTracePath.d.ts +10 -0
  9. package/esm/scripts/run-codex-prompts/prompts/isPromptCompatibleWithRunner.d.ts +11 -6
  10. package/esm/scripts/run-codex-prompts/prompts/loadPromptFiles.d.ts +1 -1
  11. package/esm/scripts/run-codex-prompts/prompts/writePromptRunTrace.d.ts +19 -0
  12. package/esm/scripts/run-codex-prompts/runners/common/buildHarnessAuthenticationError.d.ts +20 -0
  13. package/esm/scripts/run-codex-prompts/runners/common/createAuthenticationAwarePromptRunner.d.ts +11 -0
  14. package/esm/scripts/run-codex-prompts/runners/common/extractHarnessAuthenticationFailureReason.d.ts +9 -0
  15. package/esm/scripts/run-codex-prompts/ui/buildCoderRunUiFrame.d.ts +3 -0
  16. package/esm/src/book-2.0/book-language-documentation/getSafeCodeBlock.d.ts +1 -1
  17. package/esm/src/book-components/Chat/MockedChat/MockedChat.test.d.ts +2 -0
  18. package/esm/src/cli/cli-commands/coder/$ensureCoderHarnessGitignoreRules.d.ts +2 -1
  19. package/esm/src/cli/cli-commands/coder/agentCliOptions.d.ts +21 -0
  20. package/esm/src/cli/cli-commands/coder/boilerplateTemplates.d.ts +8 -21
  21. package/esm/src/cli/cli-commands/coder/coderReferencedArtifacts.d.ts +33 -0
  22. package/esm/src/cli/cli-commands/coder/ensureCoderPackageJsonFile.d.ts +4 -2
  23. package/esm/src/cli/cli-commands/coder/ensureCoderVscodeSettingsFile.d.ts +2 -0
  24. package/esm/src/cli/cli-commands/coder/ensureDirectory.d.ts +6 -0
  25. package/esm/src/cli/cli-commands/coder/getDefaultCoderPackageJsonScripts.d.ts +6 -0
  26. package/esm/src/cli/cli-commands/coder/initializeCoderProjectConfiguration.d.ts +7 -5
  27. package/esm/src/cli/cli-commands/coder/list.d.ts +10 -0
  28. package/esm/src/cli/cli-commands/coder/mergeStringRecordJsonFile.d.ts +19 -1
  29. package/esm/src/cli/cli-commands/coder/printCoderRunFailure.d.ts +6 -0
  30. package/esm/src/cli/cli-commands/coder.d.ts +1 -0
  31. package/esm/src/cli/cli-commands/common/$askForConfirmation.d.ts +4 -2
  32. package/esm/src/cli/cli-commands/common/$askForConfirmation.test.d.ts +1 -0
  33. package/esm/src/cli/cli-commands/common/disk-space/$assertSufficientFreeDiskSpace.d.ts +12 -0
  34. package/esm/src/cli/cli-commands/common/disk-space/$assertSufficientFreeDiskSpace.test.d.ts +1 -0
  35. package/esm/src/cli/cli-commands/common/disk-space/$readFreeDiskSpaceStatus.d.ts +11 -0
  36. package/esm/src/cli/cli-commands/common/disk-space/$readFreeDiskSpaceStatus.test.d.ts +1 -0
  37. package/esm/src/cli/cli-commands/common/disk-space/FreeDiskSpaceStatus.d.ts +33 -0
  38. package/esm/src/cli/cli-commands/common/disk-space/formatFreeDiskSpaceBytes.d.ts +6 -0
  39. package/esm/src/cli/cli-commands/common/disk-space/formatFreeDiskSpaceBytes.test.d.ts +1 -0
  40. package/esm/src/cli/cli-commands/common/disk-space/formatLowFreeDiskSpaceWarning.d.ts +10 -0
  41. package/esm/src/cli/cli-commands/common/disk-space/freeDiskSpaceConstants.d.ts +28 -0
  42. package/esm/src/cli/cli-commands/common/disk-space/resolveFreeDiskSpaceLevel.d.ts +7 -0
  43. package/esm/src/cli/cli-commands/common/disk-space/resolveFreeDiskSpaceLevel.test.d.ts +1 -0
  44. package/esm/src/cli/cli-commands/common/harness/$applyHarnessInstallationStatus.d.ts +2 -1
  45. package/esm/src/cli/cli-commands/common/harness/$ensureHarnessInstallations.d.ts +3 -2
  46. package/esm/src/cli/cli-commands/common/harness/HarnessDefinition.d.ts +26 -0
  47. package/esm/src/cli/cli-commands/common/npm/$askForNpmPackageInstallationApproval.d.ts +4 -2
  48. package/esm/src/cli/cli-commands/common/promptPriorityCliOptions.d.ts +7 -0
  49. package/esm/src/cli/cli-commands/common/promptbook-cli/$ensurePromptbookCliInstallations.d.ts +2 -1
  50. package/esm/src/cli/cli-commands/common/questionsCliOptions.d.ts +45 -0
  51. package/esm/src/cli/cli-commands/common/questionsCliOptions.test.d.ts +1 -0
  52. package/esm/src/cli/common/$deprecateCliCommand.d.ts +3 -0
  53. package/esm/src/cli/common/$hideCliCommandFromHelp.d.ts +11 -0
  54. package/esm/src/cli/common/$hideCliCommandFromHelp.test.d.ts +1 -0
  55. package/esm/src/cli/common/$requireCliSubcommand.d.ts +18 -0
  56. package/esm/src/cli/common/$requireCliSubcommand.test.d.ts +1 -0
  57. package/esm/src/llm-providers/vercel/VercelExecutionToolsOptions.d.ts +5 -2
  58. package/esm/src/version.d.ts +1 -1
  59. package/package.json +8 -11
  60. package/src/book-2.0/book-language-documentation/getSafeCodeBlock.ts +1 -1
  61. package/src/book-components/Chat/MockedChat/MockedChat.tsx +25 -1
  62. package/src/cli/cli-commands/agent-folder.ts +2 -6
  63. package/src/cli/cli-commands/agent.ts +2 -6
  64. package/src/cli/cli-commands/agents-server.ts +2 -6
  65. package/src/cli/cli-commands/coder/$ensureCoderHarnessGitignoreRules.ts +3 -0
  66. package/src/cli/cli-commands/coder/add.ts +27 -2
  67. package/src/cli/cli-commands/coder/agentCliOptions.ts +32 -0
  68. package/src/cli/cli-commands/coder/boilerplateTemplates.ts +17 -44
  69. package/src/cli/cli-commands/coder/coderReferencedArtifacts.ts +106 -0
  70. package/src/cli/cli-commands/coder/ensureCoderPackageJsonFile.ts +4 -2
  71. package/src/cli/cli-commands/coder/ensureCoderVscodeSettingsFile.ts +5 -1
  72. package/src/cli/cli-commands/coder/ensureDirectory.ts +27 -1
  73. package/src/cli/cli-commands/coder/getDefaultCoderPackageJsonScripts.ts +99 -10
  74. package/src/cli/cli-commands/coder/init.ts +23 -14
  75. package/src/cli/cli-commands/coder/initializeCoderProjectConfiguration.ts +18 -27
  76. package/src/cli/cli-commands/coder/list.ts +89 -0
  77. package/src/cli/cli-commands/coder/mergeStringRecordJsonFile.ts +31 -7
  78. package/src/cli/cli-commands/coder/ping.ts +25 -22
  79. package/src/cli/cli-commands/coder/printCoderRunFailure.ts +14 -0
  80. package/src/cli/cli-commands/coder/printInitializationSummary.ts +23 -16
  81. package/src/cli/cli-commands/coder/run.ts +36 -39
  82. package/src/cli/cli-commands/coder/server.ts +45 -48
  83. package/src/cli/cli-commands/coder.ts +6 -6
  84. package/src/cli/cli-commands/common/$askForConfirmation.ts +12 -2
  85. package/src/cli/cli-commands/common/disk-space/$assertSufficientFreeDiskSpace.ts +35 -0
  86. package/src/cli/cli-commands/common/disk-space/$readFreeDiskSpaceStatus.ts +37 -0
  87. package/src/cli/cli-commands/common/disk-space/FreeDiskSpaceStatus.ts +39 -0
  88. package/src/cli/cli-commands/common/disk-space/formatFreeDiskSpaceBytes.ts +26 -0
  89. package/src/cli/cli-commands/common/disk-space/formatLowFreeDiskSpaceWarning.ts +33 -0
  90. package/src/cli/cli-commands/common/disk-space/freeDiskSpaceConstants.ts +33 -0
  91. package/src/cli/cli-commands/common/disk-space/resolveFreeDiskSpaceLevel.ts +21 -0
  92. package/src/cli/cli-commands/common/harness/$applyHarnessInstallationStatus.ts +17 -5
  93. package/src/cli/cli-commands/common/harness/$ensureHarnessInstallations.ts +8 -3
  94. package/src/cli/cli-commands/common/harness/HarnessDefinition.ts +36 -0
  95. package/src/cli/cli-commands/common/npm/$askForNpmPackageInstallationApproval.ts +8 -3
  96. package/src/cli/cli-commands/common/promptPriorityCliOptions.ts +30 -0
  97. package/src/cli/cli-commands/common/promptRunnerCliOptions.ts +5 -5
  98. package/src/cli/cli-commands/common/promptbook-cli/$ensurePromptbookCliInstallations.ts +13 -2
  99. package/src/cli/cli-commands/common/questionsCliOptions.ts +89 -0
  100. package/src/cli/cli-commands/run.ts +3 -1
  101. package/src/cli/common/$deprecateCliCommand.ts +5 -0
  102. package/src/cli/common/$hideCliCommandFromHelp.ts +27 -0
  103. package/src/cli/common/$requireCliSubcommand.ts +35 -0
  104. package/src/cli/promptbookCli.ts +13 -9
  105. package/src/llm-providers/vercel/VercelExecutionToolsOptions.ts +7 -2
  106. package/src/llm-providers/vercel/createExecutionToolsFromVercelProvider.ts +18 -17
  107. package/src/other/templates/getTemplatesPipelineCollection.ts +695 -707
  108. package/src/version.ts +2 -2
  109. package/src/versions.txt +2 -0
  110. package/umd/index.umd.js +1416 -399
  111. package/umd/index.umd.js.map +1 -1
  112. package/umd/scripts/run-codex-prompts/common/createFreeDiskSpaceGuard.d.ts +25 -0
  113. package/umd/scripts/run-codex-prompts/common/formatUnknownErrorDetails.d.ts +4 -0
  114. package/umd/scripts/run-codex-prompts/common/resolveCoderAgent.d.ts +21 -3
  115. package/umd/scripts/run-codex-prompts/main/listCoderPrompts.d.ts +20 -0
  116. package/umd/scripts/run-codex-prompts/prompts/buildPromptRunTraceContent.d.ts +77 -0
  117. package/umd/scripts/run-codex-prompts/prompts/buildPromptRunTracePath.d.ts +10 -0
  118. package/umd/scripts/run-codex-prompts/prompts/isPromptCompatibleWithRunner.d.ts +11 -6
  119. package/umd/scripts/run-codex-prompts/prompts/loadPromptFiles.d.ts +1 -1
  120. package/umd/scripts/run-codex-prompts/prompts/writePromptRunTrace.d.ts +19 -0
  121. package/umd/scripts/run-codex-prompts/runners/common/buildHarnessAuthenticationError.d.ts +20 -0
  122. package/umd/scripts/run-codex-prompts/runners/common/createAuthenticationAwarePromptRunner.d.ts +11 -0
  123. package/umd/scripts/run-codex-prompts/runners/common/extractHarnessAuthenticationFailureReason.d.ts +9 -0
  124. package/umd/scripts/run-codex-prompts/ui/buildCoderRunUiFrame.d.ts +3 -0
  125. package/umd/src/book-2.0/book-language-documentation/getSafeCodeBlock.d.ts +1 -1
  126. package/umd/src/book-components/Chat/MockedChat/MockedChat.test.d.ts +2 -0
  127. package/umd/src/cli/cli-commands/coder/$ensureCoderHarnessGitignoreRules.d.ts +2 -1
  128. package/umd/src/cli/cli-commands/coder/agentCliOptions.d.ts +21 -0
  129. package/umd/src/cli/cli-commands/coder/boilerplateTemplates.d.ts +8 -21
  130. package/umd/src/cli/cli-commands/coder/coderReferencedArtifacts.d.ts +33 -0
  131. package/umd/src/cli/cli-commands/coder/ensureCoderPackageJsonFile.d.ts +4 -2
  132. package/umd/src/cli/cli-commands/coder/ensureCoderVscodeSettingsFile.d.ts +2 -0
  133. package/umd/src/cli/cli-commands/coder/ensureDirectory.d.ts +6 -0
  134. package/umd/src/cli/cli-commands/coder/getDefaultCoderPackageJsonScripts.d.ts +6 -0
  135. package/umd/src/cli/cli-commands/coder/init.test.d.ts +1 -0
  136. package/umd/src/cli/cli-commands/coder/initializeCoderProjectConfiguration.d.ts +7 -5
  137. package/umd/src/cli/cli-commands/coder/list.d.ts +10 -0
  138. package/umd/src/cli/cli-commands/coder/list.test.d.ts +1 -0
  139. package/umd/src/cli/cli-commands/coder/mergeStringRecordJsonFile.d.ts +19 -1
  140. package/umd/src/cli/cli-commands/coder/printCoderRunFailure.d.ts +6 -0
  141. package/umd/src/cli/cli-commands/coder.d.ts +1 -0
  142. package/umd/src/cli/cli-commands/common/$askForConfirmation.d.ts +4 -2
  143. package/umd/src/cli/cli-commands/common/$askForConfirmation.test.d.ts +1 -0
  144. package/umd/src/cli/cli-commands/common/disk-space/$assertSufficientFreeDiskSpace.d.ts +12 -0
  145. package/umd/src/cli/cli-commands/common/disk-space/$assertSufficientFreeDiskSpace.test.d.ts +1 -0
  146. package/umd/src/cli/cli-commands/common/disk-space/$readFreeDiskSpaceStatus.d.ts +11 -0
  147. package/umd/src/cli/cli-commands/common/disk-space/$readFreeDiskSpaceStatus.test.d.ts +1 -0
  148. package/umd/src/cli/cli-commands/common/disk-space/FreeDiskSpaceStatus.d.ts +33 -0
  149. package/umd/src/cli/cli-commands/common/disk-space/formatFreeDiskSpaceBytes.d.ts +6 -0
  150. package/umd/src/cli/cli-commands/common/disk-space/formatFreeDiskSpaceBytes.test.d.ts +1 -0
  151. package/umd/src/cli/cli-commands/common/disk-space/formatLowFreeDiskSpaceWarning.d.ts +10 -0
  152. package/umd/src/cli/cli-commands/common/disk-space/freeDiskSpaceConstants.d.ts +28 -0
  153. package/umd/src/cli/cli-commands/common/disk-space/resolveFreeDiskSpaceLevel.d.ts +7 -0
  154. package/umd/src/cli/cli-commands/common/disk-space/resolveFreeDiskSpaceLevel.test.d.ts +1 -0
  155. package/umd/src/cli/cli-commands/common/harness/$applyHarnessInstallationStatus.d.ts +2 -1
  156. package/umd/src/cli/cli-commands/common/harness/$ensureHarnessInstallations.d.ts +3 -2
  157. package/umd/src/cli/cli-commands/common/harness/HarnessDefinition.d.ts +26 -0
  158. package/umd/src/cli/cli-commands/common/npm/$askForNpmPackageInstallationApproval.d.ts +4 -2
  159. package/umd/src/cli/cli-commands/common/promptPriorityCliOptions.d.ts +7 -0
  160. package/umd/src/cli/cli-commands/common/promptbook-cli/$ensurePromptbookCliInstallations.d.ts +2 -1
  161. package/umd/src/cli/cli-commands/common/questionsCliOptions.d.ts +45 -0
  162. package/umd/src/cli/cli-commands/common/questionsCliOptions.test.d.ts +1 -0
  163. package/umd/src/cli/common/$deprecateCliCommand.d.ts +3 -0
  164. package/umd/src/cli/common/$hideCliCommandFromHelp.d.ts +11 -0
  165. package/umd/src/cli/common/$hideCliCommandFromHelp.test.d.ts +1 -0
  166. package/umd/src/cli/common/$requireCliSubcommand.d.ts +18 -0
  167. package/umd/src/cli/common/$requireCliSubcommand.test.d.ts +1 -0
  168. package/umd/src/llm-providers/vercel/VercelExecutionToolsOptions.d.ts +5 -2
  169. package/umd/src/version.d.ts +1 -1
  170. package/esm/src/cli/cli-commands/coder/agentCodingFile.d.ts +0 -13
  171. package/esm/src/cli/cli-commands/common/harnessUpdateCliOptions.d.ts +0 -29
  172. package/src/cli/cli-commands/coder/agentCodingFile.ts +0 -25
  173. package/src/cli/cli-commands/common/harnessUpdateCliOptions.ts +0 -46
  174. package/umd/src/cli/cli-commands/coder/agentCodingFile.d.ts +0 -13
  175. package/umd/src/cli/cli-commands/common/harnessUpdateCliOptions.d.ts +0 -29
  176. /package/esm/src/cli/cli-commands/{common/harnessUpdateCliOptions.test.d.ts → coder/init.test.d.ts} +0 -0
  177. /package/{umd/src/cli/cli-commands/common/harnessUpdateCliOptions.test.d.ts → esm/src/cli/cli-commands/coder/list.test.d.ts} +0 -0
@@ -24,6 +24,30 @@ export type HarnessStandaloneInstallation = {
24
24
  readonly updateCommand: string;
25
25
  };
26
26
 
27
+ /**
28
+ * Description of how the user signs in to one CLI coding harness again.
29
+ *
30
+ * Every harness refuses to work once its login is missing or its session has expired, and each of them is
31
+ * signed in differently - some have a dedicated login command, others sign in from their own interactive UI.
32
+ *
33
+ * @private internal utility of `promptbookCli`
34
+ */
35
+ export type HarnessAuthenticationMethod = {
36
+ /**
37
+ * Command which starts the sign-in flow of the harness.
38
+ */
39
+ readonly command: string;
40
+
41
+ /**
42
+ * Step which finishes the sign-in inside the started command.
43
+ *
44
+ * Harnesses which sign in from their own interactive user interface leave the user in that interface, so
45
+ * naming just the command would not be enough to get them signed in. Harnesses with a dedicated login
46
+ * command leave this undefined.
47
+ */
48
+ readonly interactiveStep?: string;
49
+ };
50
+
27
51
  /**
28
52
  * Static description of one supported CLI coding harness.
29
53
  *
@@ -60,6 +84,11 @@ export type HarnessDefinition = {
60
84
  */
61
85
  readonly projectGitignoreRules: ReadonlyArray<string>;
62
86
 
87
+ /**
88
+ * How the user signs in to this harness again after its login is missing or has expired.
89
+ */
90
+ readonly authenticationMethod: HarnessAuthenticationMethod;
91
+
63
92
  /**
64
93
  * How a standalone installation of this harness is recognized and updated.
65
94
  *
@@ -80,6 +109,7 @@ export const HARNESS_DEFINITIONS: Readonly<Record<PromptRunnerHarnessName, Harne
80
109
  commandName: 'codex',
81
110
  npmPackageName: '@openai/codex',
82
111
  projectGitignoreRules: ['.codex'],
112
+ authenticationMethod: { command: 'codex login' },
83
113
  // Note: The official standalone installer keeps its package in `~/.codex` and links it onto the `PATH`
84
114
  standaloneInstallation: {
85
115
  directoryNames: ['.codex'],
@@ -92,6 +122,7 @@ export const HARNESS_DEFINITIONS: Readonly<Record<PromptRunnerHarnessName, Harne
92
122
  commandName: 'copilot',
93
123
  npmPackageName: '@github/copilot',
94
124
  projectGitignoreRules: ['.github/copilot/settings.local.json'],
125
+ authenticationMethod: { command: 'copilot', interactiveStep: 'running the `/login` command inside it' },
95
126
  // Note: The GitHub Copilot CLI downloads its native binary in a postinstall script
96
127
  npmInstallEnvironment: { npm_config_ignore_scripts: 'false' },
97
128
  },
@@ -101,6 +132,7 @@ export const HARNESS_DEFINITIONS: Readonly<Record<PromptRunnerHarnessName, Harne
101
132
  commandName: 'cline',
102
133
  npmPackageName: 'cline',
103
134
  projectGitignoreRules: ['.cline'],
135
+ authenticationMethod: { command: 'cline', interactiveStep: 'signing in to the provider inside it' },
104
136
  },
105
137
  'claude-code': {
106
138
  harnessName: 'claude-code',
@@ -108,6 +140,7 @@ export const HARNESS_DEFINITIONS: Readonly<Record<PromptRunnerHarnessName, Harne
108
140
  commandName: 'claude',
109
141
  npmPackageName: '@anthropic-ai/claude-code',
110
142
  projectGitignoreRules: ['.claude'],
143
+ authenticationMethod: { command: 'claude', interactiveStep: 'running the `/login` command inside it' },
111
144
  },
112
145
  opencode: {
113
146
  harnessName: 'opencode',
@@ -115,6 +148,7 @@ export const HARNESS_DEFINITIONS: Readonly<Record<PromptRunnerHarnessName, Harne
115
148
  commandName: 'opencode',
116
149
  npmPackageName: 'opencode-ai',
117
150
  projectGitignoreRules: ['.opencode'],
151
+ authenticationMethod: { command: 'opencode auth login' },
118
152
  },
119
153
  gemini: {
120
154
  harnessName: 'gemini',
@@ -122,6 +156,7 @@ export const HARNESS_DEFINITIONS: Readonly<Record<PromptRunnerHarnessName, Harne
122
156
  commandName: 'gemini',
123
157
  npmPackageName: '@google/gemini-cli',
124
158
  projectGitignoreRules: ['.gemini'],
159
+ authenticationMethod: { command: 'gemini', interactiveStep: 'running the `/auth` command inside it' },
125
160
  },
126
161
  'qwen-code': {
127
162
  harnessName: 'qwen-code',
@@ -129,6 +164,7 @@ export const HARNESS_DEFINITIONS: Readonly<Record<PromptRunnerHarnessName, Harne
129
164
  commandName: 'qwen',
130
165
  npmPackageName: '@qwen-code/qwen-code',
131
166
  projectGitignoreRules: ['.qwen'],
167
+ authenticationMethod: { command: 'qwen', interactiveStep: 'running the `/auth` command inside it' },
132
168
  },
133
169
  };
134
170
 
@@ -1,15 +1,20 @@
1
1
  import { $askForConfirmation } from '../$askForConfirmation';
2
+ import type { NormalizedQuestionsCliOptions } from '../questionsCliOptions';
2
3
 
3
4
  /**
4
5
  * Asks the user in the terminal whether an npm package should be installed or updated now.
5
6
  *
6
7
  * Note: `$` is used to indicate that this function is not a pure function - it reads the answer from stdin
7
8
  *
8
- * @returns `true` when the user confirms, `false` when the user declines or the terminal is not interactive
9
+ * @returns `true` when the user confirms, `false` when the user declines, the terminal is not interactive
10
+ * or the questions are disabled by `--no-questions`
9
11
  * @private internal utility of `promptbookCli`
10
12
  */
11
- export async function $askForNpmPackageInstallationApproval(question: string): Promise<boolean> {
12
- return $askForConfirmation(question);
13
+ export async function $askForNpmPackageInstallationApproval(
14
+ question: string,
15
+ questionsOptions: NormalizedQuestionsCliOptions,
16
+ ): Promise<boolean> {
17
+ return $askForConfirmation(question, questionsOptions);
13
18
  }
14
19
 
15
20
  // Note: [🟡] Code for CLI npm package installation approval [$askForNpmPackageInstallationApproval](src/cli/cli-commands/common/npm/$askForNpmPackageInstallationApproval.ts) should never be published outside of `@promptbook/cli`
@@ -0,0 +1,30 @@
1
+ import type {
2
+ Command as Program /* <- Note: [🔸] Using Program because Command is misleading name */,
3
+ } from 'commander';
4
+ import { createNonNegativeIntegerOptionParser } from './createNonNegativeIntegerOptionParser';
5
+
6
+ /**
7
+ * Registers the shared prompt-priority filter options on a queue-based `ptbk coder` command.
8
+ *
9
+ * @private internal utility of `promptbookCli`
10
+ */
11
+ export function addPromptPriorityOptions(command: Program): void {
12
+ command.option(
13
+ '--priority <minimum-priority>',
14
+ 'Alias for --min-priority; filter prompts by minimum priority level',
15
+ createNonNegativeIntegerOptionParser('--priority'),
16
+ );
17
+ command.option(
18
+ '--min-priority <minimum-priority>',
19
+ 'Filter prompts by minimum priority level',
20
+ createNonNegativeIntegerOptionParser('--min-priority'),
21
+ );
22
+ command.option(
23
+ '--max-priority <maximum-priority>',
24
+ 'Filter prompts by maximum priority level',
25
+ createNonNegativeIntegerOptionParser('--max-priority'),
26
+ );
27
+ }
28
+
29
+ // Note: [🟡] Code for CLI prompt priority options [promptPriorityCliOptions](src/cli/cli-commands/common/promptPriorityCliOptions.ts) should never be published outside of `@promptbook/cli`
30
+ // Note: [💞] Ignore a discrepancy between file name and exported helper names
@@ -94,13 +94,13 @@ export type NormalizedPromptRunnerSelectionCliOptions = Pick<
94
94
  */
95
95
  export const PROMPT_RUNNER_DESCRIPTION = spaceTrim(`
96
96
  Runners:
97
- - openai-codex: OpenAI Codex integration (requires --model)
97
+ - openai-codex: OpenAI Codex integration (requires --model when executing)
98
98
  - github-copilot: GitHub Copilot CLI integration
99
99
  - cline: Cline CLI integration
100
100
  - claude-code: Claude Code integration
101
101
  - opencode: Opencode integration
102
- - gemini: Google Gemini CLI integration (requires --model)
103
- - qwen-code: Qwen Code CLI integration (requires --model)
102
+ - gemini: Google Gemini CLI integration (requires --model when executing)
103
+ - qwen-code: Qwen Code CLI integration (requires --model when executing)
104
104
  `);
105
105
 
106
106
  /**
@@ -110,7 +110,7 @@ export const PROMPT_RUNNER_DESCRIPTION = spaceTrim(`
110
110
  */
111
111
  export const PROMPT_RUNNER_HARNESS_OPTION_DESCRIPTION = `Select runner: ${PROMPT_RUNNER_HARNESS_NAMES.join(
112
112
  ', ',
113
- )} (required for non-dry-run)`;
113
+ )} (required when executing prompts)`;
114
114
 
115
115
  /**
116
116
  * Runner harness names listed as alternatives of the `--harness` option in error messages.
@@ -125,7 +125,7 @@ export const PROMPT_RUNNER_HARNESS_OPTION_HINT = `--harness <${PROMPT_RUNNER_HAR
125
125
  * @private internal utility of `promptbookCli`
126
126
  */
127
127
  export const PROMPT_RUNNER_MODEL_OPTION_DESCRIPTION = spaceTrim(`
128
- Model to use (required for openai-codex, gemini and qwen-code)
128
+ Model to use or filter by (required when executing with openai-codex, gemini and qwen-code)
129
129
 
130
130
  OpenAI examples: gpt-5.2-codex, default
131
131
  Gemini examples: gemini-3-flash-preview, default
@@ -1,6 +1,7 @@
1
1
  import colors from 'colors';
2
2
  import { spaceTrim } from 'spacetrim';
3
3
  import { $askForNpmPackageInstallationApproval } from '../npm/$askForNpmPackageInstallationApproval';
4
+ import type { NormalizedQuestionsCliOptions } from '../questionsCliOptions';
4
5
  import { $checkPromptbookCliInstallations } from './$checkPromptbookCliInstallations';
5
6
  import { $updatePromptbookCliInstallation } from './$updatePromptbookCliInstallation';
6
7
  import { buildPromptbookCliInstallCommand } from './buildPromptbookCliInstallCommand';
@@ -20,7 +21,14 @@ import { formatPromptbookCliInstallationWarning } from './formatPromptbookCliIns
20
21
  * @returns `true` when at least one installation was updated and the current coder run should stop
21
22
  * @private internal utility of `promptbookCli`
22
23
  */
23
- export async function $ensurePromptbookCliInstallations(): Promise<boolean> {
24
+ export async function $ensurePromptbookCliInstallations(
25
+ questionsOptions: NormalizedQuestionsCliOptions,
26
+ ): Promise<boolean> {
27
+ if (!questionsOptions.isAskingQuestionsEnabled) {
28
+ // Note: `--no-questions` forbids asking for the approval, so the registry checks would be useless
29
+ return false;
30
+ }
31
+
24
32
  if (!process.stdin.isTTY) {
25
33
  // Note: Non-interactive runs cannot approve an update and should not wait for registry checks
26
34
  return false;
@@ -36,7 +44,10 @@ export async function $ensurePromptbookCliInstallations(): Promise<boolean> {
36
44
 
37
45
  console.warn(colors.yellow(formatPromptbookCliInstallationWarning(outdatedStatuses)));
38
46
 
39
- const isUpdateApproved = await $askForNpmPackageInstallationApproval('Update Promptbook CLI now?');
47
+ const isUpdateApproved = await $askForNpmPackageInstallationApproval(
48
+ 'Update Promptbook CLI now?',
49
+ questionsOptions,
50
+ );
40
51
 
41
52
  if (!isUpdateApproved) {
42
53
  reportManualPromptbookCliUpdateCommands(outdatedStatuses);
@@ -0,0 +1,89 @@
1
+ import type {
2
+ Command as Program /* <- Note: [🔸] Using Program because Command is misleading name */,
3
+ } from 'commander';
4
+ import { spaceTrim } from 'spacetrim';
5
+ import { NotAllowed } from '../../../errors/NotAllowed';
6
+
7
+ /**
8
+ * Commander option bag for opting out of every interactive question.
9
+ *
10
+ * @private internal utility of `promptbookCli`
11
+ */
12
+ export type QuestionsCliOptions = {
13
+ readonly questions: boolean;
14
+ };
15
+
16
+ /**
17
+ * Normalized interactive-questions option shared by every `ptbk coder` command which can ask something.
18
+ *
19
+ * @private internal utility of `promptbookCli`
20
+ */
21
+ export type NormalizedQuestionsCliOptions = {
22
+ readonly isAskingQuestionsEnabled: boolean;
23
+ };
24
+
25
+ /**
26
+ * Description block shared by the `ptbk coder` commands which can ask interactive questions.
27
+ *
28
+ * @private internal utility of `promptbookCli`
29
+ */
30
+ export const QUESTIONS_DESCRIPTION = spaceTrim(`
31
+ Interactive questions:
32
+ - Steps which need an answer to continue are asked in the terminal
33
+ - --no-questions never asks: an optional step is skipped with a note how to do it manually, a required one fails right away
34
+ `);
35
+
36
+ /**
37
+ * Registers the shared `--no-questions` option on a `ptbk coder` command which can ask interactive questions.
38
+ *
39
+ * @private internal utility of `promptbookCli`
40
+ */
41
+ export function addQuestionsOption(command: Program): void {
42
+ command.option(
43
+ '--no-questions',
44
+ 'Never ask an interactive question and skip every optional step which needs an answer to continue',
45
+ );
46
+ }
47
+
48
+ /**
49
+ * Converts the Commander questions flag into the normalized interactive-questions option.
50
+ *
51
+ * @private internal utility of `promptbookCli`
52
+ */
53
+ export function normalizeQuestionsCliOptions(cliOptions: QuestionsCliOptions): NormalizedQuestionsCliOptions {
54
+ return {
55
+ isAskingQuestionsEnabled: cliOptions.questions,
56
+ };
57
+ }
58
+
59
+ /**
60
+ * Asserts that a command which waits for a user confirmation before each prompt is allowed to ask for it.
61
+ *
62
+ * @throws {NotAllowed} when `--no-auto` is combined with `--no-questions`
63
+ * @private internal utility of `promptbookCli`
64
+ */
65
+ export function assertUserConfirmationIsAllowed(options: {
66
+ readonly isAskingQuestionsEnabled: boolean;
67
+ readonly isWaitingForUser: boolean;
68
+ }): void {
69
+ const { isAskingQuestionsEnabled, isWaitingForUser } = options;
70
+
71
+ if (!isWaitingForUser || isAskingQuestionsEnabled) {
72
+ return;
73
+ }
74
+
75
+ throw new NotAllowed(
76
+ spaceTrim(`
77
+ Flag \`--no-auto\` can not be used together with \`--no-questions\`.
78
+
79
+ **There is nobody who could confirm each prompt when no question may be asked.**
80
+
81
+ Actionable hints:
82
+ - Keep \`--no-auto\` for a supervised run, for example \`ptbk coder run --harness claude-code --no-auto\`.
83
+ - Keep \`--no-questions\` for an unattended run, for example \`ptbk coder run --harness claude-code --no-questions\`.
84
+ `),
85
+ );
86
+ }
87
+
88
+ // Note: [🟡] Code for CLI interactive questions options [questionsCliOptions](src/cli/cli-commands/common/questionsCliOptions.ts) should never be published outside of `@promptbook/cli`
89
+ // Note: [💞] Ignore a discrepancy between file name and exported helper names
@@ -13,7 +13,9 @@ import type { RunCommandCliOptions } from './run/runCommandAction';
13
13
  * @private internal function of `promptbookCli`
14
14
  */
15
15
  export function $initializeRunCommand(program: Program): $side_effect {
16
- const runCommand = program.command('run', { isDefault: true });
16
+ // Note: `run` is deprecated, so it is intentionally NOT the default command of `ptbk`
17
+ // and it must be asked for explicitly
18
+ const runCommand = program.command('run');
17
19
 
18
20
  configureRunCommand(runCommand);
19
21
  runCommand.action(
@@ -2,10 +2,14 @@ import colors from 'colors';
2
2
  import { Command } from 'commander';
3
3
  import { spaceTrim } from 'spacetrim';
4
4
  import type { $side_effect } from '../../utils/organization/$side_effect';
5
+ import { $hideCliCommandFromHelp } from './$hideCliCommandFromHelp';
5
6
 
6
7
  /**
7
8
  * Marks one CLI command as deprecated while keeping it available for existing callers.
8
9
  *
10
+ * Deprecated commands are not advertised anymore - they are hidden from the list of commands in the help of their
11
+ * parent command, they warn when they are used and they explain the deprecation in their own help.
12
+ *
9
13
  * @private utility of CLI
10
14
  */
11
15
  export function $deprecateCliCommand(command: Command, deprecationMessage: string): $side_effect {
@@ -21,6 +25,7 @@ export function $deprecateCliCommand(command: Command, deprecationMessage: strin
21
25
  command.hook('preAction', () => {
22
26
  console.warn(colors.yellow(createDeprecatedCliCommandWarning(command, deprecationMessage)));
23
27
  });
28
+ $hideCliCommandFromHelp(command);
24
29
  }
25
30
 
26
31
  /**
@@ -0,0 +1,27 @@
1
+ import type { Command } from 'commander';
2
+ import type { $side_effect } from '../../utils/organization/$side_effect';
3
+
4
+ /**
5
+ * Shape of the Commander internals which decide whether one command is listed among the subcommands in the help
6
+ *
7
+ * Note: Commander accepts hiding only while the command is being registered - `program.command(name, { hidden: true })`
8
+ * or `program.addCommand(command, { hidden: true })` - and exposes no setter for an already registered command,
9
+ * so the very same flag which both of them set is written here directly.
10
+ *
11
+ * @private internal type of `$hideCliCommandFromHelp`
12
+ */
13
+ type CommandWithHiddenFlag = {
14
+ _hidden: boolean;
15
+ };
16
+
17
+ /**
18
+ * Keeps one already registered CLI command out of the help of its parent command while the command itself stays
19
+ * fully usable - it can still be run, it still has its own help and it is still reachable through `ptbk help <command>`.
20
+ *
21
+ * Note: `$` is used to indicate that this function is not a pure function - it changes how the CLI renders its help
22
+ *
23
+ * @private utility of CLI
24
+ */
25
+ export function $hideCliCommandFromHelp(command: Command): $side_effect {
26
+ (command as unknown as CommandWithHiddenFlag)._hidden = true;
27
+ }
@@ -0,0 +1,35 @@
1
+ import colors from 'colors';
2
+ import type { Command } from 'commander';
3
+ import type { $side_effect } from '../../utils/organization/$side_effect';
4
+
5
+ /**
6
+ * Message printed when one CLI command which only groups subcommands is run without picking any of them.
7
+ *
8
+ * @private internal constant of `$requireCliSubcommand`
9
+ */
10
+ const MISSING_CLI_SUBCOMMAND_MESSAGE = 'Please specify a subcommand.';
11
+
12
+ /**
13
+ * Makes one CLI command which only groups subcommands ask for a subcommand instead of doing anything on its own.
14
+ *
15
+ * Note: `$` is used to indicate that this function is not a pure function - it registers an action in the CLI
16
+ *
17
+ * @private utility of CLI
18
+ */
19
+ export function $requireCliSubcommand(command: Command): $side_effect {
20
+ command.action(() => $reportMissingCliSubcommand(command));
21
+ }
22
+
23
+ /**
24
+ * Asks for a subcommand of one CLI command, prints its help and exits the process.
25
+ *
26
+ * Note: `$` is used to indicate that this function is not a pure function - it writes to the console and exits the process
27
+ *
28
+ * @private utility of CLI
29
+ */
30
+ export function $reportMissingCliSubcommand(command: Command): never {
31
+ console.info(colors.yellow(MISSING_CLI_SUBCOMMAND_MESSAGE));
32
+ console.info('');
33
+
34
+ return command.help();
35
+ }
@@ -22,6 +22,7 @@ import { $initializeStartPipelinesServerCommand } from './cli-commands/start-pip
22
22
  import { $initializeTestCommand } from './cli-commands/test-command';
23
23
  import { $addGlobalOptionsToCommand } from './common/$addGlobalOptionsToCommand';
24
24
  import { $deprecateCliCommand } from './common/$deprecateCliCommand';
25
+ import { $reportMissingCliSubcommand } from './common/$requireCliSubcommand';
25
26
 
26
27
  /**
27
28
  * Shared deprecation text for top-level CLI commands backed by the old pipeline system.
@@ -97,10 +98,17 @@ export async function promptbookCli(): Promise<void> {
97
98
 
98
99
  // Note: These options are valid for all commands
99
100
 
101
+ // Note: Commands are listed in the help in the order they are registered,
102
+ // `coder` is the most used one so it goes first and the deprecated ones,
103
+ // which `$deprecateTopLevelCommands` hides from the help entirely, go last
104
+ $initializeCoderCommand(program);
105
+ $initializeAgentCommand(program);
106
+ $initializeAgentFolderCommand(program);
107
+ $initializeAgentsServerCommand(program);
100
108
  $initializeAboutCommand(program);
109
+ $initializeHelloCommand(program);
101
110
  $initializeRunCommand(program);
102
111
  $initializeLoginCommand(program);
103
- $initializeHelloCommand(program);
104
112
  $initializeMakeCommand(program);
105
113
  $initializePrettifyCommand(program);
106
114
  $initializeTestCommand(program);
@@ -108,19 +116,16 @@ export async function promptbookCli(): Promise<void> {
108
116
  $initializeListScrapersCommand(program);
109
117
  $initializeStartAgentsServerCommand(program);
110
118
  $initializeStartPipelinesServerCommand(program);
111
- $initializeAgentCommand(program);
112
- $initializeAgentFolderCommand(program);
113
- $initializeAgentsServerCommand(program);
114
- $initializeCoderCommand(program);
115
119
 
116
120
  $deprecateTopLevelCommands(program);
117
121
 
118
122
  // TODO: [🧠] Should it be here or not> $addGlobalOptionsToCommand(program);
119
123
  program.commands.forEach($addGlobalOptionsToCommand);
120
124
 
125
+ // Note: There is no default command, so `ptbk` without a subcommand asks for one
126
+ // instead of running the deprecated `ptbk run`
121
127
  if (commandLineArguments.length === 0) {
122
- program.outputHelp();
123
- return process.exit(0);
128
+ return $reportMissingCliSubcommand(program);
124
129
  }
125
130
 
126
131
  program.parse(process.argv);
@@ -138,7 +143,7 @@ function isTopLevelVersionRequested(commandLineArguments: ReadonlyArray<string>)
138
143
  }
139
144
 
140
145
  /**
141
- * Adds one deprecation notice to each configured top-level legacy command.
146
+ * Marks each configured top-level legacy command as deprecated, which keeps it usable but takes it out of the help.
142
147
  */
143
148
  function $deprecateTopLevelCommands(program: commander.Command): void {
144
149
  for (const command of program.commands) {
@@ -151,7 +156,6 @@ function $deprecateTopLevelCommands(program: commander.Command): void {
151
156
  }
152
157
 
153
158
  // Note: [🟡] Code for CLI program [promptbookCli](src/cli/promptbookCli.ts) should never be published outside of `@promptbook/cli`
154
- // TODO: [🧠] Maybe `run` command the default, instead of `ptbk run ./foo.book` -> `ptbk ./foo.book`
155
159
  // TODO: [🥠] Do not export, its just for CLI script
156
160
  // TODO: [🕌] When more functionalities, rename
157
161
  // Note: 11:11
@@ -24,7 +24,12 @@ export type VercelExecutionToolsOptions = CommonToolsOptions &
24
24
  // and not to pass it as a separate parameter
25
25
 
26
26
  /**
27
- * Additional settings for chat models when calling `vercelProvider.chat('model-name', settings)`
27
+ * Additional settings for chat models, for example `temperature` or `providerOptions`
28
+ *
29
+ * Note: Since Vercel AI SDK v5 these settings belong to the model call, not to
30
+ * `vercelProvider.chat('model-name')` which takes just the model name
28
31
  */
29
- readonly additionalChatSettings?: Partial<Parameters<VercelProvider['chat']>[1]>;
32
+ readonly additionalChatSettings?: Partial<
33
+ Omit<Parameters<ReturnType<VercelProvider['chat']>['doGenerate']>[0], 'prompt'>
34
+ >;
30
35
  };
@@ -34,7 +34,9 @@ const VERCEL_PROVIDER_PROFILE: ChatParticipant = {
34
34
  */
35
35
  export function createExecutionToolsFromVercelProvider(options: VercelExecutionToolsOptions): LlmExecutionTools {
36
36
  let { title, description } = options;
37
- const { vercelProvider, availableModels, userId, additionalChatSettings = {} } = options;
37
+ const { vercelProvider, availableModels, additionalChatSettings = {} } = options;
38
+ // <- Note: `userId` is not forwarded, because Vercel AI SDK moved provider-specific settings like `user` from
39
+ // `vercelProvider.chat(modelName, settings)` into `providerOptions` which are keyed by the provider
38
40
 
39
41
  if (!/Vercel/i.test(title)) {
40
42
  title = `${title} (through Vercel)`;
@@ -89,10 +91,7 @@ export function createExecutionToolsFromVercelProvider(options: VercelExecutionT
89
91
  );
90
92
  }
91
93
 
92
- const model = await vercelProvider.chat(modelName, {
93
- user: userId?.toString() || undefined,
94
- ...additionalChatSettings,
95
- });
94
+ const model = await vercelProvider.chat(modelName);
96
95
 
97
96
  const rawPromptContent = templateParameters(content, { ...parameters, modelName });
98
97
 
@@ -132,14 +131,9 @@ export function createExecutionToolsFromVercelProvider(options: VercelExecutionT
132
131
 
133
132
  const rawRequest: Parameters<typeof model.doGenerate>[0] = {
134
133
  // <- TODO: [☂]
135
- inputFormat: 'messages',
136
- mode: {
137
- type: 'regular',
138
- tools: [
139
- /* <- TODO: Pass the tools */
140
- ],
141
- },
142
134
  prompt: promptMessages,
135
+ // <- TODO: Pass the tools via `tools`
136
+ ...additionalChatSettings,
143
137
  };
144
138
 
145
139
  const start: string_date_iso8601 = $getCurrentDate();
@@ -161,10 +155,17 @@ export function createExecutionToolsFromVercelProvider(options: VercelExecutionT
161
155
  console.info(colors.bgWhite('rawResponse'), JSON.stringify(rawResponse, null, 4));
162
156
  }
163
157
 
164
- if (rawResponse.text === undefined) {
158
+ // Note: Vercel AI SDK returns ordered content parts, the chat message is made only of the text parts
159
+ const responseTextParts = rawResponse.content.flatMap((contentPart) =>
160
+ contentPart.type === 'text' ? [contentPart.text] : [],
161
+ );
162
+
163
+ if (responseTextParts.length === 0) {
165
164
  throw new PipelineExecutionError('No response message');
166
165
  }
167
166
 
167
+ const responseText = responseTextParts.join('');
168
+
168
169
  const complete: string_date_iso8601 = $getCurrentDate();
169
170
 
170
171
  const duration = uncertainNumber((new Date(complete).getTime() - new Date(start).getTime()) / 1000);
@@ -173,15 +174,15 @@ export function createExecutionToolsFromVercelProvider(options: VercelExecutionT
173
174
  price: UNCERTAIN_ZERO_VALUE, // <- TODO: [🕘] Price count
174
175
  duration,
175
176
  input: {
176
- tokensCount: uncertainNumber(rawResponse.usage.promptTokens),
177
+ tokensCount: uncertainNumber(rawResponse.usage.inputTokens),
177
178
  ...computeUsageCounts(
178
179
  rawPromptContent,
179
180
  // <- TODO: [🕘][🙀] What about system message
180
181
  ),
181
182
  },
182
183
  output: {
183
- tokensCount: uncertainNumber(rawResponse.usage.completionTokens),
184
- ...computeUsageCounts(rawResponse.text),
184
+ tokensCount: uncertainNumber(rawResponse.usage.outputTokens),
185
+ ...computeUsageCounts(responseText),
185
186
  },
186
187
  };
187
188
 
@@ -189,7 +190,7 @@ export function createExecutionToolsFromVercelProvider(options: VercelExecutionT
189
190
  name: 'promptResult',
190
191
  message: `Result of \`createExecutionToolsFromVercelProvider.callChatModel\``,
191
192
  value: {
192
- content: rawResponse.text,
193
+ content: responseText,
193
194
  modelName,
194
195
  timing: {
195
196
  start,