@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
@@ -1,6 +1,6 @@
1
1
  import { spaceTrim } from 'spacetrim';
2
2
  import type { RunOptions } from '../../../../scripts/run-codex-prompts/cli/RunOptions';
3
- import { isTestBeforeMode } from '../../../../scripts/run-codex-prompts/testing/TestBeforeMode';
3
+ import { isCheckBeforeMode } from '../../../../scripts/run-codex-prompts/checks/CheckBeforeMode';
4
4
  import { DatabaseError } from '../../../errors/DatabaseError';
5
5
  import { NotAllowed } from '../../../errors/NotAllowed';
6
6
 
@@ -9,10 +9,17 @@ import { NotAllowed } from '../../../errors/NotAllowed';
9
9
  * @private shared validation for Coder execution commands
10
10
  */
11
11
  export function validateCoderRunOptions(options: RunOptions): void {
12
- if (!isTestBeforeMode(options.testBefore ?? 'no')) {
12
+ if (options.checkCommand !== undefined && !options.checkCommand.trim()) {
13
13
  throw new NotAllowed(
14
14
  spaceTrim(`
15
- Invalid ${'`--test-before`'} mode: \`${String(options.testBefore)}\`.
15
+ Option \`--check\` requires a non-empty shell command, for example \`npm run check\`.
16
+ `),
17
+ );
18
+ }
19
+ if (!isCheckBeforeMode(options.checkBefore ?? 'no')) {
20
+ throw new NotAllowed(
21
+ spaceTrim(`
22
+ Invalid ${'`--check-before`'} mode: \`${String(options.checkBefore)}\`.
16
23
 
17
24
  Use one of: \`no\`, \`yes-and-fail\`, \`yes-and-fix\`.
18
25
  `),
@@ -67,10 +74,10 @@ export function validateCoderRunOptions(options: RunOptions): void {
67
74
  );
68
75
  }
69
76
 
70
- if (options.gitChanges === 'continue' && options.testBefore === 'yes-and-fix') {
77
+ if (options.gitChanges === 'continue' && options.checkBefore === 'yes-and-fix') {
71
78
  throw new NotAllowed(
72
79
  spaceTrim(`
73
- Flag \`--git-changes continue\` cannot be combined with \`--test-before yes-and-fix\`.
80
+ Flag \`--git-changes continue\` cannot be combined with \`--check-before yes-and-fix\`.
74
81
 
75
82
  An interrupted prompt already has changes in progress, so there is no unmodified project state for pre-coding verification to repair.
76
83
  `),
@@ -1,12 +1,13 @@
1
1
  import { execFile } from 'child_process';
2
- import { lstat, realpath, stat } from 'fs/promises';
3
- import { dirname, join, resolve } from 'path';
2
+ import { lstat, realpath } from 'fs/promises';
3
+ import { dirname, join } from 'path';
4
4
  import { spaceTrim } from 'spacetrim';
5
5
  import { promisify } from 'util';
6
6
  import { EnvironmentMismatchError } from '../../../errors/EnvironmentMismatchError';
7
7
  import { NotAllowed } from '../../../errors/NotAllowed';
8
8
  import { loadPromptsModule } from '../../common/loadPromptsModule';
9
9
  import type { NormalizedQuestionsCliOptions } from './questionsCliOptions';
10
+ import { resolveProjectDirectory } from './projectCliOptions';
10
11
 
11
12
  /** Shell-free Git execution, also usable from the packaged CLI. */
12
13
  const EXECUTE_FILE = promisify(execFile);
@@ -40,22 +41,7 @@ export type WorkspaceRepositoryPolicy = 'initialize' | 'mutate' | 'read-only';
40
41
  export async function $resolveWorkspaceRepository(
41
42
  projectDirectory = process.cwd(),
42
43
  ): Promise<WorkspaceRepositoryContext> {
43
- const requestedPath = resolve(projectDirectory);
44
- let projectPath: string;
45
- try {
46
- projectPath = await realpath(requestedPath);
47
- if (!(await stat(projectPath)).isDirectory()) {
48
- throw new EnvironmentMismatchError(`The project path \`${requestedPath}\` is not a directory.`);
49
- }
50
- } catch (error) {
51
- throw new EnvironmentMismatchError(
52
- spaceTrim(
53
- `Cannot access project directory \`${requestedPath}\`. Check that it exists and is accessible.\n\n${describeWorkspaceError(
54
- error,
55
- )}`,
56
- ),
57
- );
58
- }
44
+ const projectPath = await resolveProjectDirectory(projectDirectory);
59
45
  return $inspectWorkspaceRepository(projectPath);
60
46
  }
61
47
 
@@ -192,7 +178,9 @@ async function $inspectWorkspaceRepository(projectPath: string): Promise<Workspa
192
178
  // Git may skip damaged inner metadata and find a valid parent. Do not silently use that parent
193
179
  // for a project whose own checkout needs repair.
194
180
  await $assertNoBrokenRepositoryMetadata(projectPath, repositoryRoot);
195
- const gitDirectory = (await $runWorkspaceGit(projectPath, ['rev-parse', '--absolute-git-dir'])).trim();
181
+ const gitDirectory = await realpath(
182
+ (await $runWorkspaceGit(projectPath, ['rev-parse', '--absolute-git-dir'])).trim(),
183
+ );
196
184
  // Also validate the index and metadata, without refreshing the index or depending on an existing commit.
197
185
  await $runWorkspaceGit(projectPath, ['status', '--porcelain', '--untracked-files=no']);
198
186
  return { projectPath, repositoryRoot, gitDirectory, repositoryStatus: 'reused' };
@@ -1,6 +1,7 @@
1
1
  import type { Command } from 'commander';
2
2
  import { spaceTrim } from 'spacetrim';
3
3
  import { addQuestionsOption } from './questionsCliOptions';
4
+ import { addProjectPathOption } from './projectCliOptions';
4
5
 
5
6
  /**
6
7
  * Shared explanation of the workspace prerequisite, independent of commit and synchronization settings.
@@ -21,6 +22,7 @@ export const WORKSPACE_REPOSITORY_DESCRIPTION = spaceTrim(`
21
22
  * @private internal registration helper for workspace CLI commands
22
23
  */
23
24
  export function addWorkspaceRepositoryOptions(command: Command): void {
25
+ addProjectPathOption(command);
24
26
  if (!command.options.some((option) => option.long === '--no-questions')) addQuestionsOption(command);
25
27
  command.addHelpText('after', `\n${WORKSPACE_REPOSITORY_DESCRIPTION}\n`);
26
28
  }
@@ -19,9 +19,7 @@ export async function translateMessages({
19
19
  from,
20
20
  to,
21
21
  }: { automaticTranslator: AutomaticTranslator } & TranslatorOptions) {
22
- for (const filename of await findFilesByGlob(
23
- join(__dirname, '../../translations/', from || 'en', '/**/*.json5'),
24
- )) {
22
+ for (const filename of await findFilesByGlob(join(__dirname, '../../translations/', from || 'en', '/**/*.json5'))) {
25
23
  // <- TODO: [😶]
26
24
  const fileData = JSON5.parse(await promisify(readFile)(filename, 'utf-8'));
27
25