@promptbook/cli 0.114.0-48 → 0.114.0-49

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 (153) hide show
  1. package/README.md +59 -25
  2. package/apps/agents-server/tests/e2e/mockSupabaseServer.cjs +79 -2
  3. package/apps/agents-server/tests/e2e/support/ChatHistoryNavigationSupport.ts +12 -2
  4. package/apps/agents-server/tests/e2e/support/auth.ts +6 -0
  5. package/esm/index.es.js +1327 -478
  6. package/esm/index.es.js.map +1 -1
  7. package/esm/scripts/run-codex-prompts/checks/CheckBeforeMode.d.ts +20 -0
  8. package/esm/scripts/run-codex-prompts/checks/checkRepairInstructions.d.ts +4 -0
  9. package/esm/scripts/run-codex-prompts/checks/createCheckBeforeRepairPrompt.d.ts +9 -0
  10. package/esm/scripts/run-codex-prompts/checks/limitCheckOutput.d.ts +4 -0
  11. package/esm/scripts/run-codex-prompts/checks/projectCheck.d.ts +26 -0
  12. package/esm/scripts/run-codex-prompts/checks/projectScriptReferences.d.ts +7 -0
  13. package/esm/scripts/run-codex-prompts/checks/runCheckBefore.d.ts +26 -0
  14. package/esm/scripts/run-codex-prompts/checks/runPromptCheckCommand.d.ts +16 -0
  15. package/esm/scripts/run-codex-prompts/{testing/runPromptWithTestFeedback.d.ts → checks/runPromptWithCheckFeedback.d.ts} +9 -9
  16. package/esm/scripts/run-codex-prompts/common/resolveCoderContext.d.ts +1 -1
  17. package/esm/scripts/run-codex-prompts/common/resolveCoderProjectContext.d.ts +17 -0
  18. package/esm/scripts/run-codex-prompts/common/resolveInlineOrFileText.d.ts +2 -0
  19. package/esm/scripts/run-codex-prompts/common/runGoScript/quoteBashArgument.d.ts +2 -0
  20. package/esm/scripts/run-codex-prompts/isolation/mapProjectReferenceToWorktree.d.ts +5 -0
  21. package/esm/scripts/run-codex-prompts/main/runPromptRound.d.ts +3 -1
  22. package/esm/scripts/run-codex-prompts/prompts/buildPromptLabel.d.ts +1 -1
  23. package/esm/scripts/run-codex-prompts/prompts/buildPromptLabelForDisplay.d.ts +1 -1
  24. package/esm/scripts/run-codex-prompts/prompts/buildPromptRunTraceContent.d.ts +3 -1
  25. package/esm/scripts/run-codex-prompts/prompts/formatCoderRunSteps.d.ts +2 -2
  26. package/esm/scripts/run-codex-prompts/prompts/listUpcomingTasks.d.ts +1 -1
  27. package/esm/scripts/run-codex-prompts/prompts/printPromptsToBeWritten.d.ts +1 -1
  28. package/esm/scripts/run-codex-prompts/server/buildCoderServerPromptResponse.d.ts +2 -0
  29. package/esm/scripts/run-codex-prompts/team/createCoderTeamPromptRunner.d.ts +1 -1
  30. package/esm/scripts/run-codex-prompts/ui/CoderRunUiState.d.ts +1 -1
  31. package/esm/src/cli/cli-commands/coder/agentCliOptions.d.ts +5 -0
  32. package/esm/src/cli/cli-commands/coder/coderAgentRole.d.ts +5 -0
  33. package/esm/src/cli/cli-commands/coder/coderReferencedArtifacts.d.ts +2 -2
  34. package/esm/src/cli/cli-commands/coder/ensureCoderPackageJsonFile.d.ts +3 -2
  35. package/esm/src/cli/cli-commands/coder/ensureCoderPackageJsonFile.test.d.ts +1 -0
  36. package/esm/src/cli/cli-commands/coder/findLegacyCoderCheckCallers.d.ts +5 -0
  37. package/esm/src/cli/cli-commands/coder/initializeCoderProjectConfiguration.d.ts +6 -0
  38. package/esm/src/cli/cli-commands/coder/mergeStringRecordJsonFile.d.ts +5 -3
  39. package/esm/src/cli/cli-commands/coder/planning/runPlanningSession.d.ts +3 -0
  40. package/esm/src/cli/cli-commands/coder/prepareCoderPackageJsonScripts.d.ts +12 -0
  41. package/esm/src/cli/cli-commands/coder.d.ts +1 -1
  42. package/esm/src/cli/cli-commands/common/coderCheckCliOptions.d.ts +21 -0
  43. package/esm/src/cli/cli-commands/common/coderCheckCliOptions.test.d.ts +1 -0
  44. package/esm/src/cli/cli-commands/common/projectCliOptions.d.ts +30 -0
  45. package/esm/src/cli/cli-commands/common/projectCliOptions.test.d.ts +1 -0
  46. package/esm/src/cli/cli-commands/common/promptbook-cli/$checkPromptbookCliInstallations.d.ts +1 -1
  47. package/esm/src/cli/cli-commands/common/promptbook-cli/$ensurePromptbookCliInstallations.d.ts +1 -1
  48. package/esm/src/cli/cli-commands/common/promptbook-cli/$resolvePromptbookCliInstallations.d.ts +1 -1
  49. package/esm/src/cli/cli-commands/common/promptbook-cli/$updatePromptbookCliInstallation.d.ts +1 -1
  50. package/esm/src/version.d.ts +1 -1
  51. package/package.json +1 -1
  52. package/src/_packages/cli.readme.md +15 -0
  53. package/src/cli/cli-commands/agent/chat.ts +11 -2
  54. package/src/cli/cli-commands/agent/exec.ts +11 -2
  55. package/src/cli/cli-commands/agent-folder/init.ts +6 -2
  56. package/src/cli/cli-commands/agent-folder/initializeAgentRunnerCommand.ts +9 -2
  57. package/src/cli/cli-commands/coder/add.ts +7 -1
  58. package/src/cli/cli-commands/coder/agentCliOptions.ts +11 -1
  59. package/src/cli/cli-commands/coder/coderAgentRole.ts +6 -0
  60. package/src/cli/cli-commands/coder/coderReferencedArtifacts.ts +3 -3
  61. package/src/cli/cli-commands/coder/ensureCoderPackageJsonFile.ts +22 -3
  62. package/src/cli/cli-commands/coder/find-fresh-emoji-tags.ts +3 -0
  63. package/src/cli/cli-commands/coder/find-refactor-candidates.ts +3 -0
  64. package/src/cli/cli-commands/coder/find-unwritten.ts +3 -0
  65. package/src/cli/cli-commands/coder/findLegacyCoderCheckCallers.ts +87 -0
  66. package/src/cli/cli-commands/coder/generate-boilerplates.ts +3 -0
  67. package/src/cli/cli-commands/coder/getDefaultCoderPackageJsonScripts.ts +6 -7
  68. package/src/cli/cli-commands/coder/init.ts +8 -2
  69. package/src/cli/cli-commands/coder/initializeCoderProjectConfiguration.ts +16 -4
  70. package/src/cli/cli-commands/coder/list.ts +6 -1
  71. package/src/cli/cli-commands/coder/mergeStringRecordJsonFile.ts +14 -4
  72. package/src/cli/cli-commands/coder/ping.ts +7 -1
  73. package/src/cli/cli-commands/coder/plan.ts +17 -5
  74. package/src/cli/cli-commands/coder/planning/README.md +5 -3
  75. package/src/cli/cli-commands/coder/planning/fixtures/coding.cjs +22 -0
  76. package/src/cli/cli-commands/coder/planning/runPlanningSession.ts +14 -3
  77. package/src/cli/cli-commands/coder/planning/savePlanningChanges.ts +1 -3
  78. package/src/cli/cli-commands/coder/prepareCoderPackageJsonScripts.ts +304 -0
  79. package/src/cli/cli-commands/coder/printInitializationSummary.ts +5 -1
  80. package/src/cli/cli-commands/coder/promptsReadmeTemplate.ts +31 -13
  81. package/src/cli/cli-commands/coder/run.ts +31 -65
  82. package/src/cli/cli-commands/coder/server.ts +21 -39
  83. package/src/cli/cli-commands/coder/verify.ts +3 -0
  84. package/src/cli/cli-commands/coder.ts +2 -2
  85. package/src/cli/cli-commands/common/coderCheckCliOptions.ts +107 -0
  86. package/src/cli/cli-commands/common/projectCliOptions.ts +78 -0
  87. package/src/cli/cli-commands/common/promptbook-cli/$checkPromptbookCliInstallations.ts +4 -2
  88. package/src/cli/cli-commands/common/promptbook-cli/$ensurePromptbookCliInstallations.ts +3 -2
  89. package/src/cli/cli-commands/common/promptbook-cli/$resolvePromptbookCliInstallations.ts +8 -4
  90. package/src/cli/cli-commands/common/promptbook-cli/$updatePromptbookCliInstallation.ts +5 -2
  91. package/src/cli/cli-commands/common/validateCoderRunOptions.ts +12 -5
  92. package/src/cli/cli-commands/common/workspaceRepository.ts +7 -19
  93. package/src/cli/cli-commands/common/workspaceRepositoryCliOptions.ts +2 -0
  94. package/src/execution/translation/automatic-translate/translateMessages.ts +1 -3
  95. package/src/other/templates/getTemplatesPipelineCollection.ts +1074 -1210
  96. package/src/version.ts +2 -2
  97. package/src/versions.txt +1 -0
  98. package/umd/index.umd.js +1324 -475
  99. package/umd/index.umd.js.map +1 -1
  100. package/umd/scripts/run-codex-prompts/checks/CheckBeforeMode.d.ts +20 -0
  101. package/umd/scripts/run-codex-prompts/checks/checkRepairInstructions.d.ts +4 -0
  102. package/umd/scripts/run-codex-prompts/checks/createCheckBeforeRepairPrompt.d.ts +9 -0
  103. package/umd/scripts/run-codex-prompts/checks/limitCheckOutput.d.ts +4 -0
  104. package/umd/scripts/run-codex-prompts/checks/projectCheck.d.ts +26 -0
  105. package/umd/scripts/run-codex-prompts/checks/projectScriptReferences.d.ts +7 -0
  106. package/umd/scripts/run-codex-prompts/checks/runCheckBefore.d.ts +26 -0
  107. package/umd/scripts/run-codex-prompts/checks/runPromptCheckCommand.d.ts +16 -0
  108. package/umd/scripts/run-codex-prompts/{testing/runPromptWithTestFeedback.d.ts → checks/runPromptWithCheckFeedback.d.ts} +9 -9
  109. package/umd/scripts/run-codex-prompts/common/resolveCoderContext.d.ts +1 -1
  110. package/umd/scripts/run-codex-prompts/common/resolveCoderProjectContext.d.ts +17 -0
  111. package/umd/scripts/run-codex-prompts/common/resolveInlineOrFileText.d.ts +2 -0
  112. package/umd/scripts/run-codex-prompts/common/runGoScript/quoteBashArgument.d.ts +2 -0
  113. package/umd/scripts/run-codex-prompts/isolation/mapProjectReferenceToWorktree.d.ts +5 -0
  114. package/umd/scripts/run-codex-prompts/main/runPromptRound.d.ts +3 -1
  115. package/umd/scripts/run-codex-prompts/prompts/buildPromptLabel.d.ts +1 -1
  116. package/umd/scripts/run-codex-prompts/prompts/buildPromptLabelForDisplay.d.ts +1 -1
  117. package/umd/scripts/run-codex-prompts/prompts/buildPromptRunTraceContent.d.ts +3 -1
  118. package/umd/scripts/run-codex-prompts/prompts/formatCoderRunSteps.d.ts +2 -2
  119. package/umd/scripts/run-codex-prompts/prompts/listUpcomingTasks.d.ts +1 -1
  120. package/umd/scripts/run-codex-prompts/prompts/printPromptsToBeWritten.d.ts +1 -1
  121. package/umd/scripts/run-codex-prompts/server/buildCoderServerPromptResponse.d.ts +2 -0
  122. package/umd/scripts/run-codex-prompts/team/createCoderTeamPromptRunner.d.ts +1 -1
  123. package/umd/scripts/run-codex-prompts/ui/CoderRunUiState.d.ts +1 -1
  124. package/umd/src/cli/cli-commands/coder/agentCliOptions.d.ts +5 -0
  125. package/umd/src/cli/cli-commands/coder/coderAgentRole.d.ts +5 -0
  126. package/umd/src/cli/cli-commands/coder/coderReferencedArtifacts.d.ts +2 -2
  127. package/umd/src/cli/cli-commands/coder/ensureCoderPackageJsonFile.d.ts +3 -2
  128. package/umd/src/cli/cli-commands/coder/ensureCoderPackageJsonFile.test.d.ts +1 -0
  129. package/umd/src/cli/cli-commands/coder/findLegacyCoderCheckCallers.d.ts +5 -0
  130. package/umd/src/cli/cli-commands/coder/initializeCoderProjectConfiguration.d.ts +6 -0
  131. package/umd/src/cli/cli-commands/coder/mergeStringRecordJsonFile.d.ts +5 -3
  132. package/umd/src/cli/cli-commands/coder/planning/runPlanningSession.d.ts +3 -0
  133. package/umd/src/cli/cli-commands/coder/prepareCoderPackageJsonScripts.d.ts +12 -0
  134. package/umd/src/cli/cli-commands/coder.d.ts +1 -1
  135. package/umd/src/cli/cli-commands/common/coderCheckCliOptions.d.ts +21 -0
  136. package/umd/src/cli/cli-commands/common/coderCheckCliOptions.test.d.ts +1 -0
  137. package/umd/src/cli/cli-commands/common/projectCliOptions.d.ts +30 -0
  138. package/umd/src/cli/cli-commands/common/projectCliOptions.test.d.ts +1 -0
  139. package/umd/src/cli/cli-commands/common/promptbook-cli/$checkPromptbookCliInstallations.d.ts +1 -1
  140. package/umd/src/cli/cli-commands/common/promptbook-cli/$ensurePromptbookCliInstallations.d.ts +1 -1
  141. package/umd/src/cli/cli-commands/common/promptbook-cli/$resolvePromptbookCliInstallations.d.ts +1 -1
  142. package/umd/src/cli/cli-commands/common/promptbook-cli/$updatePromptbookCliInstallation.d.ts +1 -1
  143. package/umd/src/version.d.ts +1 -1
  144. package/esm/scripts/run-codex-prompts/testing/TestBeforeMode.d.ts +0 -16
  145. package/esm/scripts/run-codex-prompts/testing/createTestBeforeRepairPrompt.d.ts +0 -9
  146. package/esm/scripts/run-codex-prompts/testing/limitTestOutput.d.ts +0 -4
  147. package/esm/scripts/run-codex-prompts/testing/runPromptTestCommand.d.ts +0 -14
  148. package/esm/scripts/run-codex-prompts/testing/runTestBefore.d.ts +0 -24
  149. package/umd/scripts/run-codex-prompts/testing/TestBeforeMode.d.ts +0 -16
  150. package/umd/scripts/run-codex-prompts/testing/createTestBeforeRepairPrompt.d.ts +0 -9
  151. package/umd/scripts/run-codex-prompts/testing/limitTestOutput.d.ts +0 -4
  152. package/umd/scripts/run-codex-prompts/testing/runPromptTestCommand.d.ts +0 -14
  153. package/umd/scripts/run-codex-prompts/testing/runTestBefore.d.ts +0 -24
@@ -0,0 +1,20 @@
1
+ /**
2
+ * Modes supported by `ptbk coder run --check-before`.
3
+ */
4
+ export declare const CHECK_BEFORE_MODE_VALUES: readonly ["no", "yes-and-fail", "yes-and-fix"];
5
+ /**
6
+ * Behavior requested for the pre-coding check run.
7
+ */
8
+ export type CheckBeforeMode = (typeof CHECK_BEFORE_MODE_VALUES)[number];
9
+ /**
10
+ * Default check command used when a pre-coding mode is enabled without an explicit `--check` command.
11
+ */
12
+ export declare const DEFAULT_CODER_CHECK_COMMAND = "npm run check";
13
+ /**
14
+ * Resolves the shared command without enabling checks when both command and preflight mode are absent.
15
+ */
16
+ export declare function resolveCoderCheckCommand(checkCommand?: string, checkBefore?: CheckBeforeMode): string | undefined;
17
+ /**
18
+ * Checks whether a value is a supported `--check-before` mode.
19
+ */
20
+ export declare function isCheckBeforeMode(value: string): value is CheckBeforeMode;
@@ -0,0 +1,4 @@
1
+ /**
2
+ * Shared constraints for initial repair PRDs and post-prompt check feedback.
3
+ */
4
+ export declare const CHECK_REPAIR_INSTRUCTIONS: string;
@@ -0,0 +1,9 @@
1
+ import type { PromptSelection } from '../prompts/types/PromptSelection';
2
+ /**
3
+ * Creates the one queue prompt used to repair a pre-existing project check failure.
4
+ */
5
+ export declare function createCheckBeforeRepairPrompt(options: {
6
+ readonly projectPath: string;
7
+ readonly checkCommand: string;
8
+ readonly checkOutput: string;
9
+ }): Promise<PromptSelection>;
@@ -0,0 +1,4 @@
1
+ /**
2
+ * Limits check output while keeping the end of the output, where check tools usually print the failure summary.
3
+ */
4
+ export declare function limitCheckOutput(checkOutput: string): string;
@@ -0,0 +1,26 @@
1
+ import { NotAllowed } from '../../../src/errors/NotAllowed';
2
+ /**
3
+ * Failing setup placeholder used only when initialization finds no usable project validation scripts.
4
+ */
5
+ export declare const CHECK_SETUP_PLACEHOLDER_COMMAND = "node -e \"console.error('Configure package.json scripts.check with project validation commands before running Coder.'); process.exit(1)\"";
6
+ /**
7
+ * A missing or unconfigured project check needs project-owner setup, rather than model repair retries.
8
+ */
9
+ export declare class CoderCheckSetupError extends NotAllowed {
10
+ /** Creates an actionable project check setup error. */
11
+ constructor(details: string);
12
+ }
13
+ /**
14
+ * Detects the generated setup placeholder and the conventional npm unconfigured-test placeholder.
15
+ */
16
+ export declare function isCheckSetupRequired(command: string): boolean;
17
+ /**
18
+ * Inspects root project check references before an initial check or repair loop can start.
19
+ * Flags and shell composition do not bypass setup validation; execution still uses the existing shell runner.
20
+ */
21
+ export declare function assertProjectCheckIsConfigured(command: string | undefined, projectPath: string): Promise<void>;
22
+ /**
23
+ * Validates the project-owned check definition without running commands or changing its scope.
24
+ * Initialization and execution use this same setup diagnostic for missing leaves and recursive callers.
25
+ */
26
+ export declare function assertProjectCheckScriptsAreConfigured(scripts: Readonly<Record<string, unknown>>, name?: string): void;
@@ -0,0 +1,7 @@
1
+ /**
2
+ * Reads conventional npm/pnpm/yarn script references for configuration inspection.
3
+ * Commands are still executed verbatim by the existing shell runner; this helper neither parses nor rewrites shells.
4
+ * Options selecting other workspaces remain opaque so their scripts are not mistaken for root validation.
5
+ * Inspection stops at the first directory change; quoted examples do not change the inspected workspace.
6
+ */
7
+ export declare function projectScriptReferences(command: string): string[];
@@ -0,0 +1,26 @@
1
+ import type { WaitForCoderRunPauseCheckpoint } from '../common/CoderRunPauseCheckpoint';
2
+ import { runPromptCheckCommand } from './runPromptCheckCommand';
3
+ /**
4
+ * Result of the check command executed before coding starts.
5
+ */
6
+ export type CheckBeforeResult = {
7
+ /**
8
+ * Whether the check command completed successfully.
9
+ */
10
+ readonly isPassed: boolean;
11
+ /**
12
+ * Combined output produced by the check command.
13
+ */
14
+ readonly checkOutput: string;
15
+ };
16
+ /**
17
+ * Runs the configured check command before the first coding prompt.
18
+ */
19
+ export declare function runCheckBefore(options: {
20
+ readonly checkCommand: string;
21
+ readonly projectPath: string;
22
+ readonly waitForPauseCheckpoint?: WaitForCoderRunPauseCheckpoint;
23
+ readonly runPromptCheckCommandExecutor?: typeof runPromptCheckCommand;
24
+ /** Optional cancellation forwarded to the shared command runner. */
25
+ readonly signal?: AbortSignal;
26
+ }): Promise<CheckBeforeResult>;
@@ -0,0 +1,16 @@
1
+ /**
2
+ * Options for running one check command after a coding attempt.
3
+ */
4
+ export type RunPromptCheckCommandOptions = {
5
+ command: string;
6
+ projectPath: string;
7
+ scriptPath: string;
8
+ logPath?: string;
9
+ preserveArtifactsOnSuccess?: boolean;
10
+ /** Cancels the same shared shell runner used for other Coder processes. */
11
+ signal?: AbortSignal;
12
+ };
13
+ /**
14
+ * Runs the configured check command inside the project root and returns its output.
15
+ */
16
+ export declare function runPromptCheckCommand(options: RunPromptCheckCommandOptions): Promise<string>;
@@ -3,29 +3,29 @@ import { type OnCoderRunStepStarted } from '../common/createCoderRunStepTracker'
3
3
  import type { PromptRunOptions } from '../runners/types/PromptRunOptions';
4
4
  import type { PromptRunResult } from '../runners/types/PromptRunResult';
5
5
  import type { PromptRunner } from '../runners/types/PromptRunner';
6
- import { runPromptTestCommand } from './runPromptTestCommand';
6
+ import { runPromptCheckCommand } from './runPromptCheckCommand';
7
7
  /**
8
- * Options for running one prompt with optional verification feedback retries.
8
+ * Options for running one prompt with optional check feedback retries.
9
9
  */
10
- type RunPromptWithTestFeedbackOptions = PromptRunOptions & {
10
+ type RunPromptWithCheckFeedbackOptions = PromptRunOptions & {
11
11
  runner: PromptRunner;
12
12
  promptLabel: string;
13
- testCommand?: string;
13
+ checkCommand?: string;
14
14
  onAttemptStarted?: (attemptCount: number) => void;
15
15
  /**
16
- * Notified right before each implementation, testing and fixing step starts, so the caller can
16
+ * Notified right before each implementation, checking and fixing step starts, so the caller can
17
17
  * record the in-progress state of the prompt.
18
18
  */
19
19
  onStepStarted?: OnCoderRunStepStarted;
20
- runPromptTestCommandExecutor?: typeof runPromptTestCommand;
20
+ runPromptCheckCommandExecutor?: typeof runPromptCheckCommand;
21
21
  };
22
22
  /**
23
23
  * Successful prompt execution result enriched with the number of attempts it took and its per-step usage breakdown.
24
24
  */
25
- export type RunPromptWithTestFeedbackResult = PromptRunResult & {
25
+ export type RunPromptWithCheckFeedbackResult = PromptRunResult & {
26
26
  attemptCount: number;
27
27
  /**
28
- * Ordered steps performed while producing this result (implementation, testing and fixing), each carrying
28
+ * Ordered steps performed while producing this result (implementation, checking and fixing), each carrying
29
29
  * its own price and duration so the finished prompt can report usage step by step.
30
30
  */
31
31
  steps: ReadonlyArray<CoderRunStep>;
@@ -33,5 +33,5 @@ export type RunPromptWithTestFeedbackResult = PromptRunResult & {
33
33
  /**
34
34
  * Runs one coding prompt and, when configured, verifies it with a shell command that can feed failures back.
35
35
  */
36
- export declare function runPromptWithTestFeedback(options: RunPromptWithTestFeedbackOptions): Promise<RunPromptWithTestFeedbackResult>;
36
+ export declare function runPromptWithCheckFeedback(options: RunPromptWithCheckFeedbackOptions): Promise<RunPromptWithCheckFeedbackResult>;
37
37
  export {};
@@ -1,4 +1,4 @@
1
1
  /**
2
- * Resolves optional coding context provided inline or via a file path.
2
+ * Resolves project AGENTS.md on omission; explicit text, files and intentional empty values replace it.
3
3
  */
4
4
  export declare function resolveCoderContext(contextReference: string | undefined, currentWorkingDirectory: string): Promise<string | undefined>;
@@ -0,0 +1,17 @@
1
+ import { type ResolvedCoderAgentBook } from './resolveCoderAgent';
2
+ /** Read-only inputs resolved once before installations, Book initialization or execution. */
3
+ export type ResolvedCoderProjectContext = {
4
+ readonly projectPath: string;
5
+ readonly agentBook?: ResolvedCoderAgentBook;
6
+ readonly context?: string;
7
+ };
8
+ /**
9
+ * Resolves single-agent execution/authoring defaults without compiling Books or creating artifacts.
10
+ * Execution previews use the same identity and routing. Utilities and all-agent discovery resolve
11
+ * only the project directory and must not call this service to manufacture a primary-agent filter.
12
+ */
13
+ export declare function resolveCoderProjectContext(options: {
14
+ readonly projectPath: string;
15
+ readonly agent?: string;
16
+ readonly context?: string;
17
+ }): Promise<ResolvedCoderProjectContext>;
@@ -6,6 +6,8 @@ type ResolveInlineOrFileTextOptions = {
6
6
  readonly currentWorkingDirectory: string;
7
7
  readonly contextLabel: string;
8
8
  readonly optionName: string;
9
+ /** Reject missing values that unambiguously look like paths instead of sending them as prose. */
10
+ readonly isMissingFileAnError?: boolean;
9
11
  };
10
12
  /**
11
13
  * Resolves optional CLI text provided inline or via a file path.
@@ -0,0 +1,2 @@
1
+ /** Quotes one literal argument, including spaces and shell metacharacters, for a generated Bash script. */
2
+ export declare function quoteBashArgument(value: string): string;
@@ -0,0 +1,5 @@
1
+ /**
2
+ * Rebinds an absolute reference inside a project/repository to its worktree copy. Relative references
3
+ * already resolve against the execution project; explicit references outside that checkout remain explicit.
4
+ */
5
+ export declare function mapProjectReferenceToWorktree(reference: string | undefined, originalProjectPath: string, worktreeProjectPath: string): string | undefined;
@@ -27,10 +27,12 @@ export type RunPromptRoundOptions = {
27
27
  * when the round is isolated through `--isolate`.
28
28
  */
29
29
  projectPath?: string;
30
+ /** Explicit durable artifact location when a temporary execution worktree will be deleted. */
31
+ artifactsProjectPath?: string;
30
32
  };
31
33
  /**
32
34
  * Runs one prompt round from prompt construction through commit or failure logging.
33
35
  *
34
36
  * @private function of runCodexPrompts
35
37
  */
36
- export declare function runPromptRound({ options, runner, runnerMetadata, nextPrompt, promptLabel, resolvedCoderContext, resolvedAgentSystemMessage, isRichUiEnabled, progressDisplay, uiHandle, waitForRequestedPause, projectPath, }: RunPromptRoundOptions): Promise<void>;
38
+ export declare function runPromptRound({ options, runner, runnerMetadata, nextPrompt, promptLabel, resolvedCoderContext, resolvedAgentSystemMessage, isRichUiEnabled, progressDisplay, uiHandle, waitForRequestedPause, projectPath, artifactsProjectPath, }: RunPromptRoundOptions): Promise<void>;
@@ -3,4 +3,4 @@ import type { PromptSection } from './types/PromptSection';
3
3
  /**
4
4
  * Builds a label that identifies the prompt section by index.
5
5
  */
6
- export declare function buildPromptLabel(file: PromptFile, section: PromptSection): string;
6
+ export declare function buildPromptLabel(file: PromptFile, section: PromptSection, projectPath?: string): string;
@@ -3,4 +3,4 @@ import type { PromptSection } from './types/PromptSection';
3
3
  /**
4
4
  * Builds a display label using the prompt line number for easier navigation.
5
5
  */
6
- export declare function buildPromptLabelForDisplay(file: PromptFile, section: PromptSection): string;
6
+ export declare function buildPromptLabelForDisplay(file: PromptFile, section: PromptSection, projectPath?: string): string;
@@ -30,12 +30,14 @@ export type PromptRunTraceOutcome = {
30
30
  * Everything one run trace says about the prompt round it describes.
31
31
  */
32
32
  export type BuildPromptRunTraceContentOptions = FormatRunnerSignatureOptions & {
33
+ /** Selected execution project used for trace links, including in temporary worktrees. */
34
+ readonly projectPath?: string;
33
35
  readonly file: PromptFile;
34
36
  readonly section: PromptSection;
35
37
  /**
36
38
  * Verification command the round ran after each coding attempt, when one is configured.
37
39
  */
38
- readonly testCommand?: string;
40
+ readonly checkCommand?: string;
39
41
  /**
40
42
  * How many coding attempts the round has taken.
41
43
  */
@@ -3,10 +3,10 @@ import type { CoderRunStep, CoderRunStepKind } from '../common/CoderRunStep';
3
3
  * Formats the per-step usage breakdown recorded for one prompt.
4
4
  *
5
5
  * Produces a `; `-separated summary such as
6
- * `Implementation $8.01 6 hours; Testing 1 hour; Fixing $3.14 2 hours` where each coding step carries its
6
+ * `Implementation $8.01 6 hours; Checking 1 hour; Fixing $3.14 2 hours` where each coding step carries its
7
7
  * price and duration and each verification step carries only its duration.
8
8
  *
9
9
  * @param steps - Steps which have already finished
10
- * @param inProgressStepKind - Step which has started but has not finished yet, appended as `Testing in progress`
10
+ * @param inProgressStepKind - Step which has started but has not finished yet, appended as `Checking in progress`
11
11
  */
12
12
  export declare function formatCoderRunSteps(steps: ReadonlyArray<CoderRunStep>, inProgressStepKind?: CoderRunStepKind): string;
@@ -5,4 +5,4 @@ import type { PriorityFilter } from './priorityFilter';
5
5
  /**
6
6
  * Lists upcoming tasks that are ready to run (no authoring placeholders).
7
7
  */
8
- export declare function listUpcomingTasks(files: PromptFile[], priorityFilter?: PriorityFilter, promptRunnerIdentity?: PromptRunnerIdentity): UpcomingTask[];
8
+ export declare function listUpcomingTasks(files: PromptFile[], priorityFilter?: PriorityFilter, promptRunnerIdentity?: PromptRunnerIdentity, projectPath?: string): UpcomingTask[];
@@ -3,4 +3,4 @@ import type { PromptFile } from './types/PromptFile';
3
3
  /**
4
4
  * Prints the list of prompts that still need to be written.
5
5
  */
6
- export declare function printPromptsToBeWritten(files: PromptFile[], priorityFilter?: PriorityFilter): void;
6
+ export declare function printPromptsToBeWritten(files: PromptFile[], priorityFilter?: PriorityFilter, projectPath?: string): void;
@@ -40,6 +40,8 @@ export type CoderServerPromptFileResponse = {
40
40
  * Input for converting parsed prompt files into the browser API shape.
41
41
  */
42
42
  export type BuildCoderServerPromptFileResponsesOptions = {
43
+ /** Resolved project directory shared by the queue, runner and HTTP server. */
44
+ readonly projectPath?: string;
43
45
  readonly promptFiles: readonly PromptFile[];
44
46
  readonly finishedPromptFiles: readonly PromptFile[];
45
47
  readonly priorityFilter: PriorityFilter;
@@ -4,6 +4,6 @@ import { type CoderTeamEvent } from './CoderTeamRuntime';
4
4
  * Adds a scoped consultation transport around an existing adapter. Both primary and advisers keep exactly
5
5
  * that adapter's permissions and authentication. Only the enclosing Coder round owns tests, queues and Git operations.
6
6
  */
7
- export declare function createCoderTeamPromptRunner(runner: PromptRunner, agentBookReference?: string): PromptRunner;
7
+ export declare function createCoderTeamPromptRunner(runner: PromptRunner, agentBookReference?: string, originalProjectPath?: string, originalRepositoryRoot?: string | undefined): PromptRunner;
8
8
  /** Appends attributed machine-readable events to the existing runtime log consumed by run traces. */
9
9
  export declare function appendCoderTeamEvent(logPath: string | undefined, event: CoderTeamEvent): Promise<void>;
@@ -31,7 +31,7 @@ export type CoderRunConfig = {
31
31
  readonly serverUrl?: string;
32
32
  readonly priorityFilter?: PriorityFilter;
33
33
  readonly limit?: number;
34
- readonly testCommand?: string;
34
+ readonly checkCommand?: string;
35
35
  };
36
36
  /**
37
37
  * Re-exported shared progress snapshot type used by the coder run UI.
@@ -20,3 +20,8 @@ export declare const CODER_AGENT_OPTION_DESCRIPTION = "Book agent providing pers
20
20
  * @private internal utility of `ptbk coder`
21
21
  */
22
22
  export declare function addCoderAgentOption(command: Program, defaultRole?: CoderAgentRole): void;
23
+ /**
24
+ * Registers the shared optional persona and context for single-agent execution or authoring.
25
+ * @private internal CLI registration helper
26
+ */
27
+ export declare function addCoderExecutionOptions(command: Program): void;
@@ -14,3 +14,8 @@ export declare const CODER_DEFAULT_AGENT_BOOK_PATHS: {
14
14
  * @private internal type of `ptbk coder`
15
15
  */
16
16
  export type CoderAgentRole = keyof typeof CODER_DEFAULT_AGENT_BOOK_PATHS;
17
+ /**
18
+ * Shared persona for optional single-agent execution and authoring; capabilities belong to the command.
19
+ * @private internal constant of project CLI commands
20
+ */
21
+ export declare const DEFAULT_CODER_AGENT_ROLE: CoderAgentRole;
@@ -25,9 +25,9 @@ export type EnsuredCoderReferencedArtifact = {
25
25
  readonly diagnostic?: string;
26
26
  };
27
27
  /**
28
- * Initializes artifacts referenced by freshly added scripts. Default Books are ensured separately.
28
+ * Initializes essential context and artifacts referenced by freshly added scripts. Books are ensured separately.
29
29
  *
30
- * For artifacts other than role Books, an existing project script does not cause default files to be created.
30
+ * AGENTS.md is essential even when every script already exists or uses implicit defaults.
31
31
  *
32
32
  * @private function of `initializeCoderProjectConfiguration`
33
33
  */
@@ -1,9 +1,10 @@
1
1
  import type { MergedStringRecordJsonFile } from './mergeStringRecordJsonFile';
2
+ import { type PreparedCoderPackageJsonScripts } from './prepareCoderPackageJsonScripts';
2
3
  /**
3
4
  * Ensures `package.json` contains the standalone Promptbook coder helper scripts.
4
5
  *
5
- * Scripts which the project already defines are kept as they are, only missing ones are added.
6
+ * Project definitions are preserved; missing scripts and narrowly recognized generated migrations are applied.
6
7
  *
7
8
  * @private function of `initializeCoderProjectConfiguration`
8
9
  */
9
- export declare function ensureCoderPackageJsonFile(projectPath: string): Promise<MergedStringRecordJsonFile>;
10
+ export declare function ensureCoderPackageJsonFile(projectPath: string): Promise<MergedStringRecordJsonFile & Omit<PreparedCoderPackageJsonScripts, 'scripts'>>;
@@ -0,0 +1,5 @@
1
+ /**
2
+ * Finds external project callers conservatively; it never rewrites their shell expressions.
3
+ * @private migration safety check for the Coder initializer
4
+ */
5
+ export declare function findLegacyCoderCheckCallers(projectPath: string, legacyNames: ReadonlyArray<string>): Promise<Readonly<Record<string, ReadonlyArray<string>>>>;
@@ -20,6 +20,12 @@ export type CoderInitializationSummary = {
20
20
  readonly addedPackageJsonScriptNames: ReadonlyArray<string>;
21
21
  readonly referencedArtifactStatuses: ReadonlyArray<EnsuredCoderReferencedArtifact>;
22
22
  readonly initializedEnvVariableNames: ReadonlyArray<string>;
23
+ /** Actual preserved or generated scope of the project check. */
24
+ readonly checkScriptSummary: string;
25
+ /** Manual steps needed for custom or conflicting legacy entries. */
26
+ readonly migrationInstructions: ReadonlyArray<string>;
27
+ /** Whether validation is configured rather than still requiring setup. */
28
+ readonly isCheckConfigured: boolean;
23
29
  };
24
30
  /**
25
31
  * Creates or updates all coder configuration artifacts required in the current project.
@@ -8,6 +8,8 @@ type MergeStringRecordJsonFileOptions = {
8
8
  readonly fieldPath: string;
9
9
  readonly nextEntries: Readonly<Record<string, string>>;
10
10
  readonly ensureParentDirectoryPath?: string;
11
+ /** Optional narrowly scoped migration of existing entries before missing defaults are added. */
12
+ readonly transformExistingEntries?: (entries: Readonly<Record<string, string>>) => Readonly<Record<string, string>> | Promise<Readonly<Record<string, string>>>;
11
13
  };
12
14
  /**
13
15
  * Result of one additive string-record merge into a JSON file.
@@ -27,10 +29,10 @@ export type MergedStringRecordJsonFile = {
27
29
  /**
28
30
  * Ensures one JSON object field contains the provided string-record entries.
29
31
  *
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
+ * Entries are additive unless a caller explicitly supplies a scoped migration callback.
33
+ * Hand-tuned scripts and settings survive repeated `ptbk coder init`; migrations recognize generated entries only.
32
34
  *
33
35
  * @private function of `initializeCoderProjectConfiguration`
34
36
  */
35
- export declare function mergeStringRecordJsonFile({ projectPath, relativeFilePath, fieldPath, nextEntries, ensureParentDirectoryPath, }: MergeStringRecordJsonFileOptions): Promise<MergedStringRecordJsonFile>;
37
+ export declare function mergeStringRecordJsonFile({ projectPath, relativeFilePath, fieldPath, nextEntries, ensureParentDirectoryPath, transformExistingEntries, }: MergeStringRecordJsonFileOptions): Promise<MergedStringRecordJsonFile>;
36
38
  export {};
@@ -1,3 +1,4 @@
1
+ import { type ResolvedCoderProjectContext } from '../../../../../scripts/run-codex-prompts/common/resolveCoderProjectContext';
1
2
  import type { NormalizedPromptRunnerSelectionCliOptions } from '../../common/promptRunnerCliOptions';
2
3
  import { runPlanningHarness } from './runPlanningHarness';
3
4
  /**
@@ -16,6 +17,8 @@ export type PlanningSessionIo = {
16
17
  export declare function runPlanningSession(options: NormalizedPromptRunnerSelectionCliOptions & {
17
18
  readonly projectPath: string;
18
19
  readonly agent?: string;
20
+ readonly context?: string;
21
+ readonly projectContext?: ResolvedCoderProjectContext;
19
22
  readonly template?: string;
20
23
  readonly preexistingChangedPaths?: ReadonlySet<string>;
21
24
  }, io: PlanningSessionIo, harness?: typeof runPlanningHarness): Promise<ReadonlyMap<string, string>>;
@@ -0,0 +1,12 @@
1
+ /** Result of preparing project-owned checks and migrating recognized generated callers. @private internal initializer result */
2
+ export type PreparedCoderPackageJsonScripts = {
3
+ readonly scripts: Readonly<Record<string, string>>;
4
+ readonly checkScriptSummary: string;
5
+ readonly migrationInstructions: ReadonlyArray<string>;
6
+ readonly isCheckConfigured: boolean;
7
+ };
8
+ /**
9
+ * Preserves project scripts, creates one canonical check, and migrates only exact generated caller forms.
10
+ * @private shared package-script preparation for Coder initialization
11
+ */
12
+ export declare function prepareCoderPackageJsonScripts(existing: Readonly<Record<string, string>>, externalCallers?: Readonly<Record<string, ReadonlyArray<string>>>): PreparedCoderPackageJsonScripts;
@@ -6,7 +6,7 @@ import type { $side_effect } from '../../utils/organization/$side_effect';
6
6
  * The coder command provides utilities for automated coding:
7
7
  * - init: Initialize coder configuration in current project
8
8
  * - add: Add one ready-to-run prompt file to the queue
9
- * - plan: Discuss features with Planner and author reviewed PRDs
9
+ * - plan: Discuss features with Developer and author reviewed PRDs
10
10
  * - generate-boilerplates: Generate prompt boilerplate files
11
11
  * - find-refactor-candidates: Find files that need refactoring
12
12
  * - list: List ready prompts in priority order without running them
@@ -0,0 +1,21 @@
1
+ import { Command } from 'commander';
2
+ /**
3
+ * Retired aggregate option spellings and their canonical replacements, used only for migration diagnostics.
4
+ * @private shared CLI migration definitions for Coder execution
5
+ */
6
+ export declare const LEGACY_CODER_CHECK_OPTIONS: readonly [readonly ["--test", "--check"], readonly ["--test-before", "--check-before"]];
7
+ /**
8
+ * Registers the shared project check command and rejects retired aggregate-test spellings.
9
+ * @private shared CLI registration for Coder execution
10
+ */
11
+ export declare function addCoderCheckOptions(command: Command, isCheckBeforeSupported: boolean): void;
12
+ /**
13
+ * Builds the same actionable migration diagnostic for registered and direct-script entrypoints.
14
+ * @private shared CLI diagnostic for Coder execution
15
+ */
16
+ export declare function formatLegacyCoderCheckOptionError(legacyFlag: string, replacementFlag: string): string;
17
+ /**
18
+ * Normalizes shell command tokens without parsing a quoted command again or losing spaced argument boundaries.
19
+ * @private shared command normalization for Coder execution
20
+ */
21
+ export declare function normalizeCheckCommandOption(value: string | ReadonlyArray<string> | undefined): string | undefined;
@@ -0,0 +1,30 @@
1
+ import type { Command } from 'commander';
2
+ /**
3
+ * Optional project selection shared by workspace actions, independently of Book and harness selection.
4
+ * @private internal CLI options
5
+ */
6
+ export type ProjectCliOptions = {
7
+ readonly path?: string;
8
+ };
9
+ /**
10
+ * Registers project selection without capturing a directory during command registration.
11
+ * @private internal CLI registration helper
12
+ */
13
+ export declare function addProjectPathOption(command: Command): void;
14
+ /**
15
+ * Registers additional context independently of primary-agent selection.
16
+ * @private internal CLI registration helper
17
+ */
18
+ export declare function addProjectContextOption(command: Command): void;
19
+ /**
20
+ * Captures an invocation's directory at action time. No process-global state is changed.
21
+ * @private internal CLI normalization helper
22
+ */
23
+ export declare function normalizeProjectCliOptions(options: ProjectCliOptions, invocationDirectory?: string): {
24
+ readonly projectDirectory: string;
25
+ };
26
+ /**
27
+ * Validates the selected directory before any setup writes, without selecting an enclosing Git root.
28
+ * @private shared project resolution for CLI services
29
+ */
30
+ export declare function resolveProjectDirectory(projectDirectory: string): Promise<string>;
@@ -6,4 +6,4 @@ import type { PromptbookCliInstallationStatus } from './PromptbookCliInstallatio
6
6
  *
7
7
  * @private internal utility of `promptbookCli`
8
8
  */
9
- export declare function $checkPromptbookCliInstallations(): Promise<ReadonlyArray<PromptbookCliInstallationStatus>>;
9
+ export declare function $checkPromptbookCliInstallations(projectPath?: string): Promise<ReadonlyArray<PromptbookCliInstallationStatus>>;
@@ -12,4 +12,4 @@ import type { NormalizedQuestionsCliOptions } from '../questionsCliOptions';
12
12
  * @returns `true` when at least one installation was updated and the current coder run should stop
13
13
  * @private internal utility of `promptbookCli`
14
14
  */
15
- export declare function $ensurePromptbookCliInstallations(questionsOptions: NormalizedQuestionsCliOptions): Promise<boolean>;
15
+ export declare function $ensurePromptbookCliInstallations(questionsOptions: NormalizedQuestionsCliOptions, projectPath?: string): Promise<boolean>;
@@ -9,4 +9,4 @@ import { type PromptbookCliInstallation } from './PromptbookCliInstallation';
9
9
  *
10
10
  * @private internal utility of `promptbookCli`
11
11
  */
12
- export declare function $resolvePromptbookCliInstallations(): Promise<ReadonlyArray<PromptbookCliInstallation>>;
12
+ export declare function $resolvePromptbookCliInstallations(projectPath?: string): Promise<ReadonlyArray<PromptbookCliInstallation>>;
@@ -7,4 +7,4 @@ import type { PromptbookCliInstallationStatus } from './PromptbookCliInstallatio
7
7
  * @returns `true` when the package update succeeds, `false` when it fails
8
8
  * @private internal utility of `promptbookCli`
9
9
  */
10
- export declare function $updatePromptbookCliInstallation(status: PromptbookCliInstallationStatus): Promise<boolean>;
10
+ export declare function $updatePromptbookCliInstallation(status: PromptbookCliInstallationStatus, projectPath?: string): Promise<boolean>;
@@ -15,7 +15,7 @@ export declare const BOOK_LANGUAGE_VERSION: string_semantic_version;
15
15
  export declare const PROMPTBOOK_ENGINE_VERSION: string_promptbook_version;
16
16
  /**
17
17
  * Represents the version string of the Promptbook engine.
18
- * It follows semantic versioning (e.g., `0.114.0-47`).
18
+ * It follows semantic versioning (e.g., `0.114.0-48`).
19
19
  *
20
20
  * @generated
21
21
  */
@@ -1,16 +0,0 @@
1
- /**
2
- * Modes supported by `ptbk coder run --test-before`.
3
- */
4
- export declare const TEST_BEFORE_MODE_VALUES: readonly ["no", "yes-and-fail", "yes-and-fix"];
5
- /**
6
- * Behavior requested for the pre-coding verification run.
7
- */
8
- export type TestBeforeMode = (typeof TEST_BEFORE_MODE_VALUES)[number];
9
- /**
10
- * Default verification command used when a pre-coding mode is enabled without an explicit `--test` command.
11
- */
12
- export declare const DEFAULT_CODER_TEST_COMMAND = "npm test";
13
- /**
14
- * Checks whether a value is a supported `--test-before` mode.
15
- */
16
- export declare function isTestBeforeMode(value: string): value is TestBeforeMode;
@@ -1,9 +0,0 @@
1
- import type { PromptSelection } from '../prompts/types/PromptSelection';
2
- /**
3
- * Creates the one queue prompt used to repair a pre-existing test failure.
4
- */
5
- export declare function createTestBeforeRepairPrompt(options: {
6
- readonly projectPath: string;
7
- readonly testCommand: string;
8
- readonly testOutput: string;
9
- }): Promise<PromptSelection>;
@@ -1,4 +0,0 @@
1
- /**
2
- * Limits test output while keeping the end of the output, where test runners usually print the failure summary.
3
- */
4
- export declare function limitTestOutput(testOutput: string): string;
@@ -1,14 +0,0 @@
1
- /**
2
- * Options for running one verification command after a coding attempt.
3
- */
4
- export type RunPromptTestCommandOptions = {
5
- command: string;
6
- projectPath: string;
7
- scriptPath: string;
8
- logPath?: string;
9
- preserveArtifactsOnSuccess?: boolean;
10
- };
11
- /**
12
- * Runs the configured verification command inside the project root and returns its output.
13
- */
14
- export declare function runPromptTestCommand(options: RunPromptTestCommandOptions): Promise<string>;