@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
@@ -0,0 +1,25 @@
1
+ /**
2
+ * Measures the free disk space of a run which is already in progress and requests a pause when it became critical.
3
+ *
4
+ * @private internal utility of `ptbk coder` free disk space handling
5
+ */
6
+ export type FreeDiskSpaceGuard = () => Promise<void>;
7
+ /**
8
+ * Creates the guard which watches the free disk space while one `ptbk coder` run is in progress.
9
+ *
10
+ * The guard runs at every pause checkpoint of the run. When the disk became critically full it reports the
11
+ * warning and requests a pause, so the run stops at that checkpoint instead of failing in the middle of a
12
+ * coding round, and continues once the user has freed some space and pressed `P`.
13
+ *
14
+ * @private internal utility of `ptbk coder` free disk space handling
15
+ */
16
+ export declare function createFreeDiskSpaceGuard(options: {
17
+ /**
18
+ * Path whose filesystem is watched, usually the project the coder runs in.
19
+ */
20
+ readonly inspectedPath: string;
21
+ /**
22
+ * Whether the run may stop and wait for somebody to free the disk space, disabled by `--no-questions`.
23
+ */
24
+ readonly isAskingQuestionsEnabled: boolean;
25
+ }): FreeDiskSpaceGuard;
@@ -1,4 +1,8 @@
1
1
  /**
2
2
  * Formats one unknown error-like value into readable text for logs and feedback.
3
+ *
4
+ * An `AuthenticationError` is reported without its stack, because its message is written for the user - it
5
+ * says which harness has to be signed in again and how - and the frames of a failure nobody can debug would
6
+ * only push those instructions out of sight.
3
7
  */
4
8
  export declare function formatUnknownErrorDetails(error: unknown): string;
@@ -1,20 +1,38 @@
1
1
  import type { string_book } from '../../../src/book-2.0/agent-source/string_book';
2
2
  /**
3
- * Agent data resolved from the optional `--agent` book file.
3
+ * Source and prompt-routing references resolved from an optional `--agent` book file.
4
4
  */
5
- export type ResolvedCoderAgent = {
5
+ export type ResolvedCoderAgentBook = {
6
6
  /**
7
7
  * Raw source of the agent `.book` file.
8
8
  */
9
9
  readonly agentSource: string_book;
10
+ /**
11
+ * Equivalent references by which a prompt may target this agent.
12
+ *
13
+ * Includes the configured path, relative path, filename, filename without `.book`, and the
14
+ * normalized Book title from its first line.
15
+ */
16
+ readonly agentReferences: ReadonlyArray<string>;
17
+ };
18
+ /**
19
+ * Agent data resolved from the optional `--agent` book file.
20
+ */
21
+ export type ResolvedCoderAgent = ResolvedCoderAgentBook & {
10
22
  /**
11
23
  * Compiled system message injected into each coding prompt.
12
24
  */
13
25
  readonly systemMessage: string;
14
26
  };
27
+ /**
28
+ * Reads an optional agent `.book` file and prepares the references that route prompts to it.
29
+ *
30
+ * Returns `undefined` when no agent path is provided.
31
+ */
32
+ export declare function resolveCoderAgentBook(agentBookReference: string | undefined, currentWorkingDirectory: string): Promise<ResolvedCoderAgentBook | undefined>;
15
33
  /**
16
34
  * Reads an optional agent `.book` file and compiles its system message for injection into coder prompts.
17
35
  *
18
36
  * Returns `undefined` when no agent path is provided.
19
37
  */
20
- export declare function resolveCoderAgent(agentPath: string | undefined, currentWorkingDirectory: string): Promise<ResolvedCoderAgent | undefined>;
38
+ export declare function resolveCoderAgent(agentBookReference: string | undefined, currentWorkingDirectory: string): Promise<ResolvedCoderAgent | undefined>;
@@ -0,0 +1,20 @@
1
+ import { type PriorityFilterInput } from '../prompts/priorityFilter';
2
+ import type { PromptRunnerIdentity } from '../prompts/isPromptCompatibleWithRunner';
3
+ /**
4
+ * Options which select the ready prompts listed by `ptbk coder list`.
5
+ *
6
+ * @public exported from `@promptbook/cli`
7
+ */
8
+ export type ListCoderPromptsOptions = PriorityFilterInput & {
9
+ /**
10
+ * Optional harness, model and Book-agent selection used to omit prompts routed to other runners.
11
+ */
12
+ readonly promptRunnerIdentity?: PromptRunnerIdentity;
13
+ };
14
+ /**
15
+ * Lists ready, fully authored coding prompts in descending priority groups without starting a coding harness.
16
+ *
17
+ * @returns The number of prompts printed.
18
+ * @public exported from `@promptbook/cli`
19
+ */
20
+ export declare function listCoderPrompts(options?: ListCoderPromptsOptions): Promise<number>;
@@ -0,0 +1,77 @@
1
+ import moment from 'moment';
2
+ import { type CodexLoginMethod } from '../../../src/book-3.0/codexLoginMethod';
3
+ import type { ThinkingLevel } from '../../../src/cli/cli-commands/coder/ThinkingLevel';
4
+ import type { CoderRunStep } from '../common/CoderRunStep';
5
+ import type { PromptFile } from './types/PromptFile';
6
+ import type { PromptSection } from './types/PromptSection';
7
+ /**
8
+ * How one prompt round the trace describes has ended.
9
+ *
10
+ * A successful round reports the steps it is made of, a failed round reports the error which ended it.
11
+ */
12
+ export type PromptRunTraceOutcome = {
13
+ readonly kind: 'succeeded';
14
+ /**
15
+ * Ordered steps of the round, each with its own price and duration.
16
+ */
17
+ readonly steps: ReadonlyArray<CoderRunStep>;
18
+ /**
19
+ * Authentication method the harness reported, when it could be determined.
20
+ */
21
+ readonly loginMethod?: CodexLoginMethod;
22
+ } | {
23
+ readonly kind: 'failed';
24
+ /**
25
+ * Error which ended the round after its last retry.
26
+ */
27
+ readonly error: unknown;
28
+ };
29
+ /**
30
+ * Everything one run trace says about the prompt round it describes.
31
+ */
32
+ export type BuildPromptRunTraceContentOptions = {
33
+ readonly file: PromptFile;
34
+ readonly section: PromptSection;
35
+ /**
36
+ * Harness which ran the prompt.
37
+ */
38
+ readonly runnerName?: string;
39
+ /**
40
+ * Model the harness ran the prompt with.
41
+ */
42
+ readonly modelName?: string;
43
+ /**
44
+ * Reasoning effort the harness ran the prompt with.
45
+ */
46
+ readonly thinkingLevel?: ThinkingLevel;
47
+ /**
48
+ * Verification command the round ran after each coding attempt, when one is configured.
49
+ */
50
+ readonly testCommand?: string;
51
+ /**
52
+ * How many coding attempts the round has taken.
53
+ */
54
+ readonly attemptCount: number;
55
+ /**
56
+ * Moment the round started at.
57
+ */
58
+ readonly startedDate: moment.Moment;
59
+ /**
60
+ * Moment the round was recorded as finished or failed at.
61
+ */
62
+ readonly finishedDate: moment.Moment;
63
+ readonly outcome: PromptRunTraceOutcome;
64
+ /**
65
+ * Raw runtime log of the round, holding the generated shell scripts and everything the harness and the
66
+ * verification command have written. Empty when the round produced no readable runtime log.
67
+ */
68
+ readonly runtimeLog: string;
69
+ };
70
+ /**
71
+ * Renders the markdown run trace of one finished or failed prompt round.
72
+ *
73
+ * The trace pairs the metadata of the round - which harness, model and thinking level ran it, how long each of
74
+ * its steps took and what it cost - with the untouched runtime log, so a finished round can still be analyzed
75
+ * after its temporary artifacts are cleaned up.
76
+ */
77
+ export declare function buildPromptRunTraceContent(options: BuildPromptRunTraceContentOptions): string;
@@ -0,0 +1,10 @@
1
+ import type { PromptFile } from './types/PromptFile';
2
+ import type { PromptSection } from './types/PromptSection';
3
+ /**
4
+ * Builds the path of the run trace which belongs to one prompt section.
5
+ *
6
+ * The trace is stored in the `traces` directory of the very same prompts directory the prompt itself lives in,
7
+ * and it carries the name of its prompt file. A prompt file holding more than one section appends the section
8
+ * suffix, exactly like the temporary scripts and the isolation worktrees of the same section do.
9
+ */
10
+ export declare function buildPromptRunTracePath(file: PromptFile, section: PromptSection): string;
@@ -1,7 +1,7 @@
1
1
  import type { PromptFile } from './types/PromptFile';
2
2
  import type { PromptSection } from './types/PromptSection';
3
3
  /**
4
- * Names of the harness and model currently selected for a coder run.
4
+ * Names of the harness, model and Book agent currently selected for a coder run.
5
5
  */
6
6
  export type PromptRunnerIdentity = {
7
7
  /**
@@ -12,16 +12,21 @@ export type PromptRunnerIdentity = {
12
12
  * Effective model identifier, for example `gpt-5.5`.
13
13
  */
14
14
  readonly modelName?: string;
15
+ /**
16
+ * Equivalent agent path and name references, including the Book title from its first line.
17
+ */
18
+ readonly agentReferences?: ReadonlyArray<string>;
15
19
  };
16
20
  /**
17
- * Checks whether a prompt is unrestricted or matches the selected harness/model.
21
+ * Checks whether a prompt is unrestricted or matches the selected harness, model or Book agent.
18
22
  *
19
- * A prompt status line can contain one or more backtick-delimited model or harness
20
- * names. Matching is intentionally based on normalized substrings so a token such as
21
- * `gpt` selects any `gpt-*` model and `opus` selects a `claude-opus-*` model.
23
+ * A prompt status line can contain one or more backtick-delimited model, harness or agent
24
+ * references. Matching is intentionally based on normalized substrings so a token such as
25
+ * `gpt` selects any `gpt-*` model, `developer` selects an agent Book named `developer.book`,
26
+ * and `opus` selects a `claude-opus-*` model.
22
27
  */
23
28
  export declare function isPromptCompatibleWithRunner(file: PromptFile, section: PromptSection, promptRunnerIdentity?: PromptRunnerIdentity): boolean;
24
29
  /**
25
- * Extracts model and harness tokens from a prompt status line.
30
+ * Extracts model, harness and Book-agent tokens from a prompt status line.
26
31
  */
27
32
  export declare function extractPromptRunnerTokens(statusLine: string): string[];
@@ -1,5 +1,5 @@
1
1
  import type { PromptFile } from './types/PromptFile';
2
2
  /**
3
- * Loads and parses prompt files from the prompts directory.
3
+ * Loads and parses prompt files from the prompts directory, excluding files marked for `ptbk coder` to ignore.
4
4
  */
5
5
  export declare function loadPromptFiles(promptsDir: string): Promise<PromptFile[]>;
@@ -0,0 +1,19 @@
1
+ import { type BuildPromptRunTraceContentOptions } from './buildPromptRunTraceContent';
2
+ /**
3
+ * Everything needed to persist the run trace of one prompt round.
4
+ *
5
+ * The runtime log is not passed as text but as the path of the live log the round has been writing into, because
6
+ * the trace is the only place where that log survives - it is deleted as soon as the round is over.
7
+ */
8
+ export type WritePromptRunTraceOptions = Omit<BuildPromptRunTraceContentOptions, 'runtimeLog'> & {
9
+ /**
10
+ * Path of the temporary live runtime log of the round, when the round has one.
11
+ */
12
+ readonly logPath?: string;
13
+ };
14
+ /**
15
+ * Writes the run trace of one prompt round into the `traces` directory of the prompts directory.
16
+ *
17
+ * Returns the path of the written trace so callers can include it in a commit.
18
+ */
19
+ export declare function writePromptRunTrace(options: WritePromptRunTraceOptions): Promise<string>;
@@ -0,0 +1,20 @@
1
+ import type { PromptRunnerHarnessName } from '../../../../src/cli/cli-commands/common/promptRunnerCliOptions';
2
+ import { AuthenticationError } from '../../../../src/errors/AuthenticationError';
3
+ /**
4
+ * Options for building the error reported when a harness is not logged in.
5
+ */
6
+ type BuildHarnessAuthenticationErrorOptions = {
7
+ /**
8
+ * Harness which refused to work.
9
+ */
10
+ readonly harnessName: PromptRunnerHarnessName;
11
+ /**
12
+ * Short reason the harness itself reported, as extracted from its output.
13
+ */
14
+ readonly reason: string;
15
+ };
16
+ /**
17
+ * Builds the branded error which tells the user that the selected harness has to be signed in again.
18
+ */
19
+ export declare function buildHarnessAuthenticationError(options: BuildHarnessAuthenticationErrorOptions): AuthenticationError;
20
+ export {};
@@ -0,0 +1,11 @@
1
+ import type { PromptRunnerHarnessName } from '../../../../src/cli/cli-commands/common/promptRunnerCliOptions';
2
+ import type { PromptRunner } from '../types/PromptRunner';
3
+ /**
4
+ * Wraps one prompt runner so a failure caused by a missing or expired harness login is reported as a branded
5
+ * `AuthenticationError` which tells the user how to sign in again.
6
+ *
7
+ * Each harness reports its own failures differently, but all of them report them by failing `runPrompt` with
8
+ * the raw CLI output as the message. Translating the failure here therefore keeps exactly one place which has
9
+ * to recognize an unauthenticated harness, for every harness and for every command which runs prompts.
10
+ */
11
+ export declare function createAuthenticationAwarePromptRunner(runner: PromptRunner, harnessName: PromptRunnerHarnessName): PromptRunner;
@@ -0,0 +1,9 @@
1
+ /**
2
+ * Reads the reason why a harness refused to work because it is not logged in, from its raw CLI output.
3
+ *
4
+ * Messages the harness reports in machine-readable output are preferred over its raw output lines, so the
5
+ * reason is the sentence the harness wrote for a human and not the JSON event which transported it.
6
+ *
7
+ * @returns One short single-line reason, or `undefined` when the failure was not caused by authentication.
8
+ */
9
+ export declare function extractHarnessAuthenticationFailureReason(harnessOutput: string): string | undefined;
@@ -11,6 +11,9 @@ export type { CoderRunPauseState };
11
11
  * Snapshot consumed by the pure coder-run frame builder.
12
12
  */
13
13
  export type BuildCoderRunUiFrameOptions = {
14
+ /**
15
+ * Number of physical columns currently available in the terminal.
16
+ */
14
17
  readonly terminalWidth: number;
15
18
  readonly animationFrame: number;
16
19
  readonly animationTimeMs: number;
@@ -5,6 +5,6 @@
5
5
  * @param language - Optional info-string language label.
6
6
  * @returns Fenced code block.
7
7
  *
8
- * @private internal utility of `createStandaloneBookLanguageMarkdown`
8
+ * @private internal utility of `createStandaloneBookLanguageMarkdown` and of the `ptbk coder` run traces
9
9
  */
10
10
  export declare function getSafeCodeBlock(content: string, language?: string): string;
@@ -0,0 +1,2 @@
1
+ /** @jest-environment jsdom */
2
+ export {};
@@ -1,4 +1,5 @@
1
1
  import type { PromptRunnerHarnessName } from '../common/promptRunnerCliOptions';
2
+ import type { NormalizedQuestionsCliOptions } from '../common/questionsCliOptions';
2
3
  /**
3
4
  * Offers to add missing project-local ignore rules for the selected coding harness.
4
5
  *
@@ -6,4 +7,4 @@ import type { PromptRunnerHarnessName } from '../common/promptRunnerCliOptions';
6
7
  *
7
8
  * @private internal utility of `ptbk coder`
8
9
  */
9
- export declare function $ensureCoderHarnessGitignoreRules(projectPath: string, harnessName: PromptRunnerHarnessName | undefined): Promise<void>;
10
+ export declare function $ensureCoderHarnessGitignoreRules(projectPath: string, harnessName: PromptRunnerHarnessName | undefined, questionsOptions: NormalizedQuestionsCliOptions): Promise<void>;
@@ -0,0 +1,21 @@
1
+ import type { Command as Program } from 'commander';
2
+ /**
3
+ * Commander option bag for an optional Book agent used by coder commands.
4
+ *
5
+ * @private internal utility of `ptbk coder`
6
+ */
7
+ export type CoderAgentCliOptions = {
8
+ readonly agent?: string;
9
+ };
10
+ /**
11
+ * Description shared by coder commands which accept an agent Book.
12
+ *
13
+ * @private internal utility of `ptbk coder`
14
+ */
15
+ export declare const CODER_AGENT_OPTION_DESCRIPTION = "Path to a .book file used to personalize coding prompts and select agent-specific tasks";
16
+ /**
17
+ * Registers the shared `--agent` option for coder commands.
18
+ *
19
+ * @private internal utility of `ptbk coder`
20
+ */
21
+ export declare function addCoderAgentOption(command: Program): void;
@@ -16,6 +16,12 @@ export declare const PROMPTS_DONE_DIRECTORY_PATH: string;
16
16
  * @private internal utility of `ptbk coder`
17
17
  */
18
18
  export declare const PROMPTS_TEMPLATES_DIRECTORY_PATH: string;
19
+ /**
20
+ * Relative path to the project-agnostic `common` boilerplate template referenced by the default coder scripts.
21
+ *
22
+ * @private internal utility of `ptbk coder`
23
+ */
24
+ export declare const COMMON_PROMPT_TEMPLATE_FILE_PATH: string;
19
25
  /**
20
26
  * Initialization statuses used when creating or updating coder configuration artifacts.
21
27
  *
@@ -55,25 +61,6 @@ export type CoderPromptTemplateDefinition = {
55
61
  */
56
62
  readonly isDefaultProjectTemplate: boolean;
57
63
  };
58
- /**
59
- * Result of ensuring one default coder template file exists inside a project.
60
- *
61
- * @private internal utility of `ptbk coder`
62
- */
63
- export type EnsuredCoderPromptTemplateFile = {
64
- /**
65
- * Stable built-in identifier of the template.
66
- */
67
- readonly id: BuiltInCoderPromptTemplate;
68
- /**
69
- * Project-relative path of the materialized template file.
70
- */
71
- readonly relativeFilePath: string;
72
- /**
73
- * Status describing whether the file had to be created.
74
- */
75
- readonly status: InitializationStatus;
76
- };
77
64
  /**
78
65
  * Fully resolved boilerplate template used by `coder generate-boilerplates`.
79
66
  *
@@ -116,11 +103,11 @@ export declare function getDefaultCoderProjectPromptTemplateDefinitions(): Reado
116
103
  */
117
104
  export declare function getDefaultCoderPromptTemplateDefinition(template: BuiltInCoderPromptTemplate): CoderPromptTemplateDefinition;
118
105
  /**
119
- * Ensures the default project-owned coder template files exist without overwriting user customizations.
106
+ * Ensures one project-owned coder template file exists without overwriting user customizations.
120
107
  *
121
108
  * @private internal utility of `ptbk coder`
122
109
  */
123
- export declare function ensureDefaultCoderPromptTemplateFiles(projectPath: string): Promise<ReadonlyArray<EnsuredCoderPromptTemplateFile>>;
110
+ export declare function ensureDefaultCoderPromptTemplateFile(projectPath: string, definition: CoderPromptTemplateDefinition): Promise<InitializationStatus>;
124
111
  /**
125
112
  * Resolves the template requested by `coder generate-boilerplates`.
126
113
  *
@@ -0,0 +1,33 @@
1
+ import type { InitializationStatus } from './boilerplateTemplates';
2
+ /**
3
+ * Status of one artifact referenced by the default coder scripts.
4
+ *
5
+ * `not-referenced` means that no newly added script points at the artifact, so `ptbk coder init` left it alone.
6
+ *
7
+ * @private internal utility of `coder init` command
8
+ */
9
+ export type CoderReferencedArtifactStatus = InitializationStatus | 'not-referenced';
10
+ /**
11
+ * Result of ensuring one artifact referenced by the default coder scripts.
12
+ *
13
+ * @private internal utility of `coder init` command
14
+ */
15
+ export type EnsuredCoderReferencedArtifact = {
16
+ /**
17
+ * Project-relative path of the referenced artifact.
18
+ */
19
+ readonly relativeFilePath: string;
20
+ /**
21
+ * Status describing whether the artifact had to be created.
22
+ */
23
+ readonly status: CoderReferencedArtifactStatus;
24
+ };
25
+ /**
26
+ * Creates only those referenced artifacts which the freshly added coder scripts point at.
27
+ *
28
+ * An artifact of a script which the project already defines is intentionally **not** created - the project-owned
29
+ * script is kept as is, so it does not reference the default artifact in the first place.
30
+ *
31
+ * @private function of `initializeCoderProjectConfiguration`
32
+ */
33
+ export declare function ensureCoderReferencedArtifacts(projectPath: string, referencedArtifactPaths: ReadonlySet<string>): Promise<ReadonlyArray<EnsuredCoderReferencedArtifact>>;
@@ -1,7 +1,9 @@
1
- import type { InitializationStatus } from './boilerplateTemplates';
1
+ import type { MergedStringRecordJsonFile } from './mergeStringRecordJsonFile';
2
2
  /**
3
3
  * Ensures `package.json` contains the standalone Promptbook coder helper scripts.
4
4
  *
5
+ * Scripts which the project already defines are kept as they are, only missing ones are added.
6
+ *
5
7
  * @private function of `initializeCoderProjectConfiguration`
6
8
  */
7
- export declare function ensureCoderPackageJsonFile(projectPath: string): Promise<InitializationStatus>;
9
+ export declare function ensureCoderPackageJsonFile(projectPath: string): Promise<MergedStringRecordJsonFile>;
@@ -2,6 +2,8 @@ import type { InitializationStatus } from './boilerplateTemplates';
2
2
  /**
3
3
  * Ensures VS Code routes pasted prompt images into `prompts/screenshots`.
4
4
  *
5
+ * Settings which the project already defines are kept as they are, only missing ones are added.
6
+ *
5
7
  * @private function of `initializeCoderProjectConfiguration`
6
8
  */
7
9
  export declare function ensureCoderVscodeSettingsFile(projectPath: string): Promise<InitializationStatus>;
@@ -5,3 +5,9 @@ import type { InitializationStatus } from './boilerplateTemplates';
5
5
  * @private function of `initializeCoderProjectConfiguration`
6
6
  */
7
7
  export declare function ensureDirectory(projectPath: string, relativeDirectoryPath: string): Promise<InitializationStatus>;
8
+ /**
9
+ * Checks whether a project-relative directory is missing or contains no entries.
10
+ *
11
+ * @private internal utility of `coder init` command
12
+ */
13
+ export declare function isDirectoryEmpty(projectPath: string, relativeDirectoryPath: string): Promise<boolean>;
@@ -4,3 +4,9 @@
4
4
  * @private internal utility of `coder init` command
5
5
  */
6
6
  export declare function getDefaultCoderPackageJsonScripts(): Readonly<Record<string, string>>;
7
+ /**
8
+ * Collects the project-relative artifact paths referenced by the given default coder scripts.
9
+ *
10
+ * @private internal utility of `coder init` command
11
+ */
12
+ export declare function resolveCoderPackageJsonScriptReferencedArtifactPaths(scriptNames: ReadonlyArray<string>): ReadonlySet<string>;
@@ -1,4 +1,5 @@
1
- import type { EnsuredCoderPromptTemplateFile, InitializationStatus } from './boilerplateTemplates';
1
+ import type { InitializationStatus } from './boilerplateTemplates';
2
+ import type { EnsuredCoderReferencedArtifact } from './coderReferencedArtifacts';
2
3
  /**
3
4
  * Result summary returned after coder configuration initialization.
4
5
  *
@@ -8,20 +9,21 @@ export type CoderInitializationSummary = {
8
9
  readonly promptsDirectoryStatus: InitializationStatus;
9
10
  readonly promptsDoneDirectoryStatus: InitializationStatus;
10
11
  readonly promptsTemplatesDirectoryStatus: InitializationStatus;
11
- readonly promptTemplateFileStatuses: ReadonlyArray<EnsuredCoderPromptTemplateFile>;
12
12
  readonly agentsDirectoryStatus: InitializationStatus;
13
- readonly developerAgentFileStatus: InitializationStatus;
14
- readonly agentsFileStatus: InitializationStatus;
15
- readonly agentCodingFileStatus: InitializationStatus;
16
13
  readonly envFileStatus: InitializationStatus;
17
14
  readonly gitignoreFileStatus: InitializationStatus;
18
15
  readonly packageJsonFileStatus: InitializationStatus;
19
16
  readonly vscodeSettingsFileStatus: InitializationStatus;
17
+ readonly addedPackageJsonScriptNames: ReadonlyArray<string>;
18
+ readonly referencedArtifactStatuses: ReadonlyArray<EnsuredCoderReferencedArtifact>;
20
19
  readonly initializedEnvVariableNames: ReadonlyArray<string>;
21
20
  };
22
21
  /**
23
22
  * Creates or updates all coder configuration artifacts required in the current project.
24
23
  *
24
+ * Nothing the project already owns is ever overwritten - existing scripts, settings and files are kept as they are,
25
+ * and the artifacts they would reference are created only together with the scripts which actually reference them.
26
+ *
25
27
  * @private internal utility of `coder init` command
26
28
  */
27
29
  export declare function initializeCoderProjectConfiguration(projectPath: string): Promise<CoderInitializationSummary>;
@@ -0,0 +1,10 @@
1
+ import type { Command as Program } from 'commander';
2
+ import type { $side_effect } from '../../../utils/organization/$side_effect';
3
+ /**
4
+ * Initializes `coder list` command for Promptbook CLI utilities.
5
+ *
6
+ * Note: `$` is used to indicate that this function is not a pure function - it registers a command in the CLI.
7
+ *
8
+ * @private internal function of `promptbookCli`
9
+ */
10
+ export declare function $initializeCoderListCommand(program: Program): $side_effect;
@@ -9,10 +9,28 @@ type MergeStringRecordJsonFileOptions = {
9
9
  readonly nextEntries: Readonly<Record<string, string>>;
10
10
  readonly ensureParentDirectoryPath?: string;
11
11
  };
12
+ /**
13
+ * Result of one additive string-record merge into a JSON file.
14
+ *
15
+ * @private internal utility of `coder init` command
16
+ */
17
+ export type MergedStringRecordJsonFile = {
18
+ /**
19
+ * Status describing whether the JSON file had to be created or updated.
20
+ */
21
+ readonly status: InitializationStatus;
22
+ /**
23
+ * Keys which were missing in the JSON file and therefore added by the merge.
24
+ */
25
+ readonly addedEntryKeys: ReadonlyArray<string>;
26
+ };
12
27
  /**
13
28
  * Ensures one JSON object field contains the provided string-record entries.
14
29
  *
30
+ * Entries which the project already defines are **never** overridden - only missing keys are added,
31
+ * so hand-tuned scripts and settings survive every repeated `ptbk coder init`.
32
+ *
15
33
  * @private function of `initializeCoderProjectConfiguration`
16
34
  */
17
- export declare function mergeStringRecordJsonFile({ projectPath, relativeFilePath, fieldPath, nextEntries, ensureParentDirectoryPath, }: MergeStringRecordJsonFileOptions): Promise<InitializationStatus>;
35
+ export declare function mergeStringRecordJsonFile({ projectPath, relativeFilePath, fieldPath, nextEntries, ensureParentDirectoryPath, }: MergeStringRecordJsonFileOptions): Promise<MergedStringRecordJsonFile>;
18
36
  export {};
@@ -0,0 +1,6 @@
1
+ /**
2
+ * Prints why a coder run has ended to the terminal.
3
+ *
4
+ * @private internal utility of `coder run` and `coder server` commands
5
+ */
6
+ export declare function printCoderRunFailure(error: Error): void;
@@ -8,6 +8,7 @@ import type { $side_effect } from '../../utils/organization/$side_effect';
8
8
  * - add: Add one ready-to-run prompt file to the queue
9
9
  * - generate-boilerplates: Generate prompt boilerplate files
10
10
  * - find-refactor-candidates: Find files that need refactoring
11
+ * - list: List ready prompts in priority order without running them
11
12
  * - run: Run coding prompts with AI agents
12
13
  * - ping: Test one harness and model with a tiny dummy prompt
13
14
  * - verify: Verify completed prompts
@@ -1,9 +1,11 @@
1
+ import type { NormalizedQuestionsCliOptions } from './questionsCliOptions';
1
2
  /**
2
3
  * Asks the user in the terminal to confirm one optional change.
3
4
  *
4
5
  * Note: `$` is used to indicate that this function is not a pure function - it reads the answer from stdin.
5
6
  *
6
- * @returns `true` when the user confirms, `false` when the user declines or the terminal is not interactive.
7
+ * @returns `true` when the user confirms, `false` when the user declines, the terminal is not interactive
8
+ * or the questions are disabled by `--no-questions`.
7
9
  * @private internal utility of `promptbookCli`
8
10
  */
9
- export declare function $askForConfirmation(question: string): Promise<boolean>;
11
+ export declare function $askForConfirmation(question: string, { isAskingQuestionsEnabled }: NormalizedQuestionsCliOptions): Promise<boolean>;
@@ -0,0 +1,12 @@
1
+ /**
2
+ * Refuses to start one `ptbk coder` command when the disk which hosts the project is nearly full.
3
+ *
4
+ * A run which starts without enough free disk space fails somewhere in the middle, after the coding agent has
5
+ * already rewritten a part of the project, so it is stopped before it writes anything at all.
6
+ *
7
+ * Note: `$` is used to indicate that this function is not a pure function - it reads the state of the filesystem
8
+ *
9
+ * @throws {LimitReachedError} when there is not enough free disk space left to start
10
+ * @private internal utility of `promptbookCli`
11
+ */
12
+ export declare function $assertSufficientFreeDiskSpace(inspectedPath: string): Promise<void>;
@@ -0,0 +1,11 @@
1
+ import type { FreeDiskSpaceStatus } from './FreeDiskSpaceStatus';
2
+ /**
3
+ * Measures the free disk space on the filesystem which hosts the given path.
4
+ *
5
+ * Note: `$` is used to indicate that this function is not a pure function - it reads the state of the filesystem
6
+ *
7
+ * @returns the measurement, or `null` when the filesystem can not be measured, for example on a platform which
8
+ * does not report filesystem statistics - a run is never stopped by a measurement which could not be taken
9
+ * @private internal utility of `promptbookCli`
10
+ */
11
+ export declare function $readFreeDiskSpaceStatus(inspectedPath: string): Promise<FreeDiskSpaceStatus | null>;