@promptbook/cli 0.114.0-0 → 0.114.0-2
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.
- package/README.md +16 -15
- package/apps/agents-server/package.json +6 -4
- package/apps/agents-server/playwright.config.ts +28 -38
- package/apps/agents-server/scripts/build-agents-server.js +62 -0
- package/apps/agents-server/scripts/build-e2e.js +38 -0
- package/apps/agents-server/scripts/ensure-root-dependencies.js +86 -0
- package/apps/agents-server/scripts/prerender-homepage.js +1 -1
- package/apps/agents-server/scripts/run-e2e-tests.js +34 -0
- package/apps/agents-server/scripts/run-npm.js +42 -0
- package/apps/agents-server/src/app/admin/email-server/page.tsx +14 -6
- package/apps/agents-server/src/app/api/elevenlabs/tts/route.ts +3 -3
- package/apps/agents-server/src/app/api/onboarding/book/route.ts +7 -6
- package/apps/agents-server/src/app/superadmin/servers/ServersRegistryTable.tsx +105 -102
- package/apps/agents-server/src/app/superadmin/servers/useServersRegistryState.ts +15 -7
- package/apps/agents-server/src/components/AgentProjectDnsInstructions/AgentProjectDnsInstructions.tsx +11 -11
- package/apps/agents-server/src/components/NewAgentDialog/ManGoNewAgentWizard/components/ManGoBookEditor.tsx +82 -0
- package/apps/agents-server/src/components/NewAgentDialog/ManGoNewAgentWizard/components/WizardShell.tsx +2 -2
- package/apps/agents-server/src/components/NewAgentDialog/ManGoNewAgentWizard/components/steps/BookStep.tsx +13 -16
- package/apps/agents-server/src/components/NewAgentDialog/ManGoNewAgentWizard/components/steps/ZadaniStep.tsx +4 -4
- package/apps/agents-server/src/components/NewAgentDialog/ManGoNewAgentWizard/config/bookSections.ts +23 -16
- package/apps/agents-server/src/components/NewAgentDialog/ManGoNewAgentWizard/lib/bookSource.ts +54 -0
- package/apps/agents-server/src/components/NewAgentDialog/ManGoNewAgentWizard/services/bookService.ts +15 -8
- package/apps/agents-server/src/components/NewAgentDialog/ManGoNewAgentWizard/services/createManGoAgentSource.ts +3 -37
- package/apps/agents-server/src/components/NewAgentDialog/ManGoNewAgentWizard/services/createManGoOpenEditorRequest.ts +1 -1
- package/apps/agents-server/src/components/NewAgentDialog/ManGoNewAgentWizard/state/OnboardingProvider.tsx +2 -2
- package/apps/agents-server/src/components/UsersList/CreateUserDialog.tsx +13 -22
- package/apps/agents-server/src/components/UsersList/PasswordGeneratorDialog.tsx +216 -0
- package/apps/agents-server/src/components/UsersList/UsersList.tsx +16 -11
- package/apps/agents-server/src/components/UsersList/generateSecurePassword.ts +112 -24
- package/apps/agents-server/src/components/UsersList/userDialogClassNames.ts +11 -0
- package/apps/agents-server/src/languages/ServerTranslationKeys.ts +11 -0
- package/apps/agents-server/src/languages/translations/czech.yaml +11 -0
- package/apps/agents-server/src/languages/translations/english.yaml +11 -0
- package/apps/agents-server/src/utils/agentProjects/agentProjectHrefs.ts +11 -0
- package/apps/agents-server/src/utils/agentProjects/createAgentProjectDnsRecords.ts +53 -7
- package/apps/agents-server/src/utils/agentProjects/createAgentProjectMarkdownReferences.ts +37 -27
- package/apps/agents-server/src/utils/manGoOnboarding/manGoOnboardingAgentBooks.ts +2 -13
- package/apps/agents-server/src/utils/manGoOnboarding/manGoOnboardingAgentRuntime.ts +21 -73
- package/apps/agents-server/src/utils/stalwart/createEmailDnsInstructions.ts +9 -5
- package/apps/agents-server/src/utils/stalwart/readStalwartEmailSnapshot.ts +23 -5
- package/apps/agents-server/src/utils/stalwart/stalwartBootstrap.ts +2 -1
- package/apps/agents-server/src/utils/stalwart/stalwartMailBridge.ts +7 -0
- package/apps/agents-server/tests/e2e/e2eEnvironment.cjs +49 -0
- package/esm/index.es.js +523 -169
- package/esm/index.es.js.map +1 -1
- package/esm/scripts/run-agent-chat/runCoderPing.d.ts +48 -0
- package/esm/scripts/run-codex-prompts/prompts/findNextTodoPrompt.d.ts +2 -1
- package/esm/scripts/run-codex-prompts/prompts/isPromptCompatibleWithRunner.d.ts +27 -0
- package/esm/scripts/run-codex-prompts/prompts/listRunnablePrompts.d.ts +2 -1
- package/esm/scripts/run-codex-prompts/prompts/listUpcomingTasks.d.ts +2 -1
- package/esm/scripts/run-codex-prompts/prompts/replacePromptTodoStatusLine.d.ts +7 -0
- package/esm/scripts/run-codex-prompts/testing/TestBeforeMode.d.ts +16 -0
- package/esm/scripts/run-codex-prompts/testing/createTestBeforeRepairPrompt.d.ts +9 -0
- package/esm/scripts/run-codex-prompts/testing/limitTestOutput.d.ts +4 -0
- package/esm/scripts/run-codex-prompts/testing/runPromptTestCommand.d.ts +1 -2
- package/esm/scripts/run-codex-prompts/testing/runTestBefore.d.ts +24 -0
- package/esm/scripts/run-codex-prompts/ui/buildRunUiFrameShared.d.ts +1 -0
- package/esm/src/book-2.0/book-language-documentation/BookLanguageManualDictionary.d.ts +1 -15
- package/esm/src/book-2.0/book-language-documentation/getBookLanguageManualCommitmentGroups.d.ts +1 -1
- package/esm/src/book-2.0/book-language-documentation/renderCommitmentCatalogSection.d.ts +0 -4
- package/esm/src/book-components/Chat/utils/renderMarkdown.d.ts +7 -0
- package/esm/src/cli/cli-commands/coder/agentCodingFile.d.ts +2 -3
- package/esm/src/cli/cli-commands/coder/ping.d.ts +13 -0
- package/esm/src/cli/cli-commands/coder/ping.test.d.ts +1 -0
- package/esm/src/cli/cli-commands/coder.d.ts +1 -0
- package/package.json +1 -1
- package/src/book-2.0/book-language-documentation/BookLanguageManualDictionary.ts +1 -15
- package/src/book-2.0/book-language-documentation/bookLanguageDocumentationExamples.ts +1 -2
- package/src/book-2.0/book-language-documentation/createStandaloneBookLanguageMarkdown.ts +92 -32
- package/src/book-2.0/book-language-documentation/czechBookLanguageManualDictionary.ts +16 -39
- package/src/book-2.0/book-language-documentation/englishBookLanguageManualDictionary.ts +16 -36
- package/src/book-2.0/book-language-documentation/getBookLanguageManualCommitmentGroups.ts +9 -1
- package/src/book-2.0/book-language-documentation/renderCommitmentCatalogSection.ts +4 -51
- package/src/book-2.0/book-language-documentation/renderGroupedCommitmentDocumentationMarkdown.ts +291 -4
- package/src/book-components/Chat/utils/renderMarkdown.ts +133 -9
- package/src/cli/cli-commands/agents-server/startAgentsServer/createLocalAgentRunOptions.ts +1 -0
- package/src/cli/cli-commands/coder/agentCodingFile.ts +6 -129
- package/src/cli/cli-commands/coder/getDefaultCoderPackageJsonScripts.ts +1 -1
- package/src/cli/cli-commands/coder/initializeCoderProjectConfiguration.ts +1 -4
- package/src/cli/cli-commands/coder/ping.ts +94 -0
- package/src/cli/cli-commands/coder/run.ts +25 -2
- package/src/cli/cli-commands/coder.ts +4 -0
- package/src/other/templates/getTemplatesPipelineCollection.ts +805 -842
- package/src/utils/agent-message-runtime/resolveAgentMessageRuntimeActivity.ts +101 -0
- package/src/version.ts +1 -1
- package/src/versions.txt +1 -1
- package/umd/index.umd.js +525 -171
- package/umd/index.umd.js.map +1 -1
- package/umd/scripts/run-agent-chat/runCoderPing.d.ts +48 -0
- package/umd/scripts/run-codex-prompts/prompts/findNextTodoPrompt.d.ts +2 -1
- package/umd/scripts/run-codex-prompts/prompts/isPromptCompatibleWithRunner.d.ts +27 -0
- package/umd/scripts/run-codex-prompts/prompts/listRunnablePrompts.d.ts +2 -1
- package/umd/scripts/run-codex-prompts/prompts/listUpcomingTasks.d.ts +2 -1
- package/umd/scripts/run-codex-prompts/prompts/replacePromptTodoStatusLine.d.ts +7 -0
- package/umd/scripts/run-codex-prompts/testing/TestBeforeMode.d.ts +16 -0
- package/umd/scripts/run-codex-prompts/testing/createTestBeforeRepairPrompt.d.ts +9 -0
- package/umd/scripts/run-codex-prompts/testing/limitTestOutput.d.ts +4 -0
- package/umd/scripts/run-codex-prompts/testing/runPromptTestCommand.d.ts +1 -2
- package/umd/scripts/run-codex-prompts/testing/runTestBefore.d.ts +24 -0
- package/umd/scripts/run-codex-prompts/ui/buildRunUiFrameShared.d.ts +1 -0
- package/umd/src/book-2.0/book-language-documentation/BookLanguageManualDictionary.d.ts +1 -15
- package/umd/src/book-2.0/book-language-documentation/getBookLanguageManualCommitmentGroups.d.ts +1 -1
- package/umd/src/book-2.0/book-language-documentation/renderCommitmentCatalogSection.d.ts +0 -4
- package/umd/src/book-components/Chat/utils/renderMarkdown.d.ts +7 -0
- package/umd/src/cli/cli-commands/coder/agentCodingFile.d.ts +2 -3
- package/umd/src/cli/cli-commands/coder/ping.d.ts +13 -0
- package/umd/src/cli/cli-commands/coder/ping.test.d.ts +1 -0
- package/umd/src/cli/cli-commands/coder.d.ts +1 -0
- package/apps/agents-server/src/app/api/onboarding/draft/route.ts +0 -23
- package/apps/agents-server/src/components/NewAgentDialog/ManGoNewAgentWizard/components/BookLanguagePanel.tsx +0 -125
- package/apps/agents-server/src/components/NewAgentDialog/ManGoNewAgentWizard/components/MarkdownBookEditor.tsx +0 -154
- package/apps/agents-server/src/components/NewAgentDialog/ManGoNewAgentWizard/components/MarkdownPreview.tsx +0 -188
- package/apps/agents-server/src/components/NewAgentDialog/ManGoNewAgentWizard/services/draftService.ts +0 -32
|
@@ -1,13 +1,5 @@
|
|
|
1
1
|
import { spaceTrim } from 'spacetrim';
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
getDefaultCoderProjectPromptTemplateDefinitions,
|
|
5
|
-
getDefaultCoderPromptTemplateDefinitions,
|
|
6
|
-
PROMPTS_DIRECTORY_PATH,
|
|
7
|
-
PROMPTS_DONE_DIRECTORY_PATH,
|
|
8
|
-
PROMPTS_TEMPLATES_DIRECTORY_PATH,
|
|
9
|
-
} from './boilerplateTemplates';
|
|
10
|
-
import { formatDisplayPath } from './formatDisplayPath';
|
|
2
|
+
import { string_markdown } from '../../../types/typeAliases';
|
|
11
3
|
|
|
12
4
|
/**
|
|
13
5
|
* Relative path to the Promptbook Coder quick-reference file initialized in project roots.
|
|
@@ -21,127 +13,12 @@ export const AGENT_CODING_FILE_PATH = 'AGENT_CODING.md';
|
|
|
21
13
|
*
|
|
22
14
|
* @private internal utility of `ptbk coder`
|
|
23
15
|
*/
|
|
24
|
-
export function getDefaultCoderAgentCodingFileContent({
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
readonly packageJsonScripts: Readonly<Record<string, string>>;
|
|
28
|
-
}): string {
|
|
29
|
-
return spaceTrim(
|
|
30
|
-
(block) => `
|
|
31
|
-
# Promptbook Coder quick reference
|
|
16
|
+
export function getDefaultCoderAgentCodingFileContent(): string_markdown {
|
|
17
|
+
return spaceTrim(`
|
|
18
|
+
# ✨ Promptbook Coder agent coding
|
|
32
19
|
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
)}/\`.
|
|
36
|
-
|
|
37
|
-
## Workflow
|
|
38
|
-
1. Put repository-wide coding rules into \`${AGENTS_FILE_PATH}\`. The default \`npm run coder:run\` script already passes \`--context ${AGENTS_FILE_PATH}\`.
|
|
39
|
-
2. Create or customize prompt templates in \`${formatDisplayPath(
|
|
40
|
-
PROMPTS_TEMPLATES_DIRECTORY_PATH,
|
|
41
|
-
)}/\`. ${buildStarterTemplateSentence()}
|
|
42
|
-
3. Generate prompt files with \`npm run coder:generate-boilerplates\` or \`ptbk coder generate-boilerplates --template <template> --count <count>\`. To append a single ready-to-run prompt straight from a description, use \`npm run coder:add\` or \`ptbk coder add "some new feature"\`.
|
|
43
|
-
4. Replace every \`@@@\`, keep drafts as \`[-]\`, and switch prompts to \`[ ]\` when they are ready to run. Completed prompts are marked \`[x]\`.
|
|
44
|
-
5. Run \`npm run coder:run\` to execute the next ready prompt with the configured coding agent.
|
|
45
|
-
6. Use \`npm run coder:verify\` to archive finished prompts into \`${formatDisplayPath(
|
|
46
|
-
PROMPTS_DONE_DIRECTORY_PATH,
|
|
47
|
-
)}/\` and append repair follow-up prompts when more work is needed.
|
|
48
|
-
7. Use \`ptbk coder find-refactor-candidates\` when you want Promptbook to suggest refactor prompts automatically.
|
|
49
|
-
|
|
50
|
-
## Templates
|
|
51
|
-
- Project-owned templates created by \`ptbk coder init\`: ${formatInlineCodeList(
|
|
52
|
-
getDefaultCoderProjectPromptTemplateDefinitions().map(({ relativeFilePath }) =>
|
|
53
|
-
formatDisplayPath(relativeFilePath),
|
|
54
|
-
),
|
|
55
|
-
)}
|
|
56
|
-
- Built-in \`--template\` aliases: ${formatInlineCodeList(
|
|
57
|
-
getDefaultCoderPromptTemplateDefinitions().map(({ id }) => id),
|
|
58
|
-
)}
|
|
59
|
-
- To add a custom template, create a markdown file such as \`${formatDisplayPath(
|
|
60
|
-
PROMPTS_TEMPLATES_DIRECTORY_PATH,
|
|
61
|
-
)}/backend.md\`.
|
|
62
|
-
- To use a project template, run \`ptbk coder generate-boilerplates --template ${formatDisplayPath(
|
|
63
|
-
PROMPTS_TEMPLATES_DIRECTORY_PATH,
|
|
64
|
-
)}/backend.md\`.
|
|
65
|
-
- Keep shared repository rules in \`${AGENTS_FILE_PATH}\` and recurring task-family rules in template files so individual prompt files stay focused on the actual task.
|
|
66
|
-
|
|
67
|
-
## Created npm scripts
|
|
68
|
-
| Script | Purpose |
|
|
69
|
-
| --- | --- |
|
|
70
|
-
${block(buildPackageJsonScriptTableLines(packageJsonScripts).join('\n'))}
|
|
71
|
-
|
|
72
|
-
## Customizing the workflow
|
|
73
|
-
- Edit \`package.json\` if you want \`npm run coder:run\` to use another coding agent, model, thinking level, context file, or wait mode.
|
|
74
|
-
- Use direct CLI commands when you need one-off flags such as \`--min-priority\`, \`--max-priority\`, \`--ignore-git-changes\`, \`--no-commit\`, \`--dry-run\`, \`--test\`, \`--allow-credits\`, or \`--auto-migrate\`.
|
|
75
|
-
- Use \`ptbk coder --help\` and \`ptbk coder <command> --help\` for the full CLI reference.
|
|
76
|
-
`,
|
|
77
|
-
);
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
/**
|
|
81
|
-
* Builds the sentence describing the starter templates created during initialization.
|
|
82
|
-
*/
|
|
83
|
-
function buildStarterTemplateSentence(): string {
|
|
84
|
-
const starterTemplatePaths = getDefaultCoderProjectPromptTemplateDefinitions().map(({ relativeFilePath }) =>
|
|
85
|
-
formatDisplayPath(relativeFilePath),
|
|
86
|
-
);
|
|
87
|
-
|
|
88
|
-
if (starterTemplatePaths.length === 1) {
|
|
89
|
-
return `The starter project template created by \`ptbk coder init\` is \`${starterTemplatePaths[0]}\`.`;
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
return `The starter project templates created by \`ptbk coder init\` are ${formatInlineCodeList(
|
|
93
|
-
starterTemplatePaths,
|
|
94
|
-
)}.`;
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
/**
|
|
98
|
-
* Builds the markdown table rows describing the initialized npm scripts.
|
|
99
|
-
*/
|
|
100
|
-
function buildPackageJsonScriptTableLines(packageJsonScripts: Readonly<Record<string, string>>): Array<string> {
|
|
101
|
-
return Object.entries(packageJsonScripts).map(
|
|
102
|
-
([scriptName, scriptCommand]) =>
|
|
103
|
-
`| \`npm run ${scriptName}\` | ${describeDefaultCoderPackageJsonScript(scriptName, scriptCommand)} |`,
|
|
104
|
-
);
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
/**
|
|
108
|
-
* Describes one initialized npm script in human-readable terms.
|
|
109
|
-
*/
|
|
110
|
-
function describeDefaultCoderPackageJsonScript(scriptName: string, scriptCommand: string): string {
|
|
111
|
-
if (scriptName === 'coder:generate-boilerplates') {
|
|
112
|
-
return `Runs \`${scriptCommand}\` to create new prompt files in \`${formatDisplayPath(
|
|
113
|
-
PROMPTS_DIRECTORY_PATH,
|
|
114
|
-
)}/\`.`;
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
if (scriptName === 'coder:add') {
|
|
118
|
-
return `Runs \`${scriptCommand}\` to add one ready-to-run prompt file to \`${formatDisplayPath(
|
|
119
|
-
PROMPTS_DIRECTORY_PATH,
|
|
120
|
-
)}/\` from a plain-language description.`;
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
if (scriptName === 'coder:run') {
|
|
124
|
-
return `Runs \`${scriptCommand}\` to execute the next ready prompt with shared repository context from \`${AGENTS_FILE_PATH}\`.`;
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
if (scriptName === 'coder:find-refactor-candidates') {
|
|
128
|
-
return `Runs \`${scriptCommand}\` to generate prompt candidates for large or crowded files.`;
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
if (scriptName === 'coder:verify') {
|
|
132
|
-
return `Runs \`${scriptCommand}\` to archive verified prompts into \`${formatDisplayPath(
|
|
133
|
-
PROMPTS_DONE_DIRECTORY_PATH,
|
|
134
|
-
)}/\` and append repair prompts when needed.`;
|
|
135
|
-
}
|
|
136
|
-
|
|
137
|
-
return `Runs \`${scriptCommand}\`.`;
|
|
138
|
-
}
|
|
139
|
-
|
|
140
|
-
/**
|
|
141
|
-
* Formats one inline code list for human-readable markdown.
|
|
142
|
-
*/
|
|
143
|
-
function formatInlineCodeList(values: ReadonlyArray<string>): string {
|
|
144
|
-
return values.map((value) => `\`${value}\``).join(', ');
|
|
20
|
+
This project is using [Promptbook Coder](https://coder.ptbk.io) or run \`ptbk coder\`!
|
|
21
|
+
`);
|
|
145
22
|
}
|
|
146
23
|
|
|
147
24
|
// Note: [🟡] Code for coder AGENT_CODING file boilerplate [agentCodingFile](src/cli/cli-commands/coder/agentCodingFile.ts) should never be published outside of `@promptbook/cli`
|
|
@@ -5,7 +5,7 @@ const DEFAULT_CODER_PACKAGE_JSON_SCRIPTS = {
|
|
|
5
5
|
'coder:generate-boilerplates': 'ptbk coder generate-boilerplates --template ./prompts/templates/common.md',
|
|
6
6
|
'coder:add': 'ptbk coder add --template ./prompts/templates/common.md',
|
|
7
7
|
'coder:run':
|
|
8
|
-
'ptbk coder run --harness openai-codex --model gpt-5.
|
|
8
|
+
'ptbk coder run --harness openai-codex --model gpt-5.6-terra --thinking-level max --agent agents/developer.book --context AGENTS.md --test-before yes-and-fix',
|
|
9
9
|
// 'coder:find-refactor-candidates': 'npx ptbk coder find-refactor-candidates',
|
|
10
10
|
'coder:verify': 'ptbk coder verify',
|
|
11
11
|
} as const satisfies Readonly<Record<string, string>>;
|
|
@@ -14,7 +14,6 @@ import { ensureCoderMarkdownFile } from './ensureCoderMarkdownFile';
|
|
|
14
14
|
import { ensureCoderPackageJsonFile } from './ensureCoderPackageJsonFile';
|
|
15
15
|
import { ensureCoderVscodeSettingsFile } from './ensureCoderVscodeSettingsFile';
|
|
16
16
|
import { ensureDirectory } from './ensureDirectory';
|
|
17
|
-
import { getDefaultCoderPackageJsonScripts } from './getDefaultCoderPackageJsonScripts';
|
|
18
17
|
|
|
19
18
|
/**
|
|
20
19
|
* Result summary returned after coder configuration initialization.
|
|
@@ -57,9 +56,7 @@ export async function initializeCoderProjectConfiguration(projectPath: string):
|
|
|
57
56
|
const agentCodingFileStatus = await ensureCoderMarkdownFile(
|
|
58
57
|
projectPath,
|
|
59
58
|
AGENT_CODING_FILE_PATH,
|
|
60
|
-
getDefaultCoderAgentCodingFileContent(
|
|
61
|
-
packageJsonScripts: getDefaultCoderPackageJsonScripts(),
|
|
62
|
-
}),
|
|
59
|
+
getDefaultCoderAgentCodingFileContent(),
|
|
63
60
|
);
|
|
64
61
|
const { envFileStatus, initializedEnvVariableNames } = await ensureCoderEnvFile(projectPath);
|
|
65
62
|
const gitignoreFileStatus = await ensureCoderGitignoreFile(projectPath);
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
import type {
|
|
2
|
+
Command as Program /* <- Note: [🔸] Using Program because Command is misleading name */,
|
|
3
|
+
} from 'commander';
|
|
4
|
+
import { spaceTrim } from 'spacetrim';
|
|
5
|
+
import { NotAllowed } from '../../../errors/NotAllowed';
|
|
6
|
+
import type { $side_effect } from '../../../utils/organization/$side_effect';
|
|
7
|
+
import { $ensureHarnessInstallations } from '../common/harness/$ensureHarnessInstallations';
|
|
8
|
+
import { handleActionErrors } from '../common/handleActionErrors';
|
|
9
|
+
import type { PromptRunnerSelectionCliOptions } from '../common/promptRunnerCliOptions';
|
|
10
|
+
import {
|
|
11
|
+
addPromptRunnerRuntimeOptions,
|
|
12
|
+
addPromptRunnerSelectionOptions,
|
|
13
|
+
normalizePromptRunnerSelectionCliOptions,
|
|
14
|
+
PROMPT_RUNNER_DESCRIPTION,
|
|
15
|
+
} from '../common/promptRunnerCliOptions';
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Initializes `coder ping` command for Promptbook CLI utilities.
|
|
19
|
+
*
|
|
20
|
+
* The command makes one small, isolated harness/model call, prints its result
|
|
21
|
+
* and reports how long the harness/model turn took.
|
|
22
|
+
*
|
|
23
|
+
* Note: `$` is used to indicate that this function is not a pure function - it registers a command in the CLI.
|
|
24
|
+
*
|
|
25
|
+
* @private internal function of `promptbookCli`
|
|
26
|
+
*/
|
|
27
|
+
export function $initializeCoderPingCommand(program: Program): $side_effect {
|
|
28
|
+
const command = program.command('ping');
|
|
29
|
+
command.description(
|
|
30
|
+
spaceTrim(`
|
|
31
|
+
Test one harness and model connection with a small disposable task
|
|
32
|
+
|
|
33
|
+
${PROMPT_RUNNER_DESCRIPTION}
|
|
34
|
+
|
|
35
|
+
Features:
|
|
36
|
+
- Runs the dummy task in a temporary directory outside the current project
|
|
37
|
+
- Prints the result returned by the selected harness and model
|
|
38
|
+
- Reports the elapsed harness/model response time in milliseconds
|
|
39
|
+
- Can be used to start consuming an applicable harness/model quota before a longer run
|
|
40
|
+
`),
|
|
41
|
+
);
|
|
42
|
+
|
|
43
|
+
addPromptRunnerSelectionOptions(command);
|
|
44
|
+
addPromptRunnerRuntimeOptions(command);
|
|
45
|
+
|
|
46
|
+
command.action(
|
|
47
|
+
handleActionErrors(async (cliOptions) => {
|
|
48
|
+
const normalizedOptions = normalizePromptRunnerSelectionCliOptions(
|
|
49
|
+
cliOptions as PromptRunnerSelectionCliOptions,
|
|
50
|
+
{ isAgentRequired: true },
|
|
51
|
+
);
|
|
52
|
+
|
|
53
|
+
const agentName = normalizedOptions.agentName;
|
|
54
|
+
if (!agentName) {
|
|
55
|
+
throw new NotAllowed(
|
|
56
|
+
spaceTrim(`
|
|
57
|
+
A harness is required for \`ptbk coder ping\`.
|
|
58
|
+
|
|
59
|
+
Pass one with \`--harness <harness-name>\`.
|
|
60
|
+
`),
|
|
61
|
+
);
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
await $ensureHarnessInstallations([agentName]);
|
|
65
|
+
|
|
66
|
+
// Note: Import the runner-backed implementation dynamically to avoid loading heavy dependencies until needed.
|
|
67
|
+
const { runCoderPing } = await import('../../../../scripts/run-agent-chat/runCoderPing');
|
|
68
|
+
const pingResult = await runCoderPing({
|
|
69
|
+
agentName,
|
|
70
|
+
model: normalizedOptions.model,
|
|
71
|
+
thinkingLevel: normalizedOptions.thinkingLevel,
|
|
72
|
+
isUiDisabled: normalizedOptions.noUi,
|
|
73
|
+
isCreditsAllowed: normalizedOptions.allowCredits,
|
|
74
|
+
});
|
|
75
|
+
|
|
76
|
+
printCoderPingResult(pingResult);
|
|
77
|
+
}),
|
|
78
|
+
);
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
/**
|
|
82
|
+
* Prints the result and duration of one completed coder ping.
|
|
83
|
+
*/
|
|
84
|
+
function printCoderPingResult(pingResult: { readonly result: string; readonly elapsedTimeMs: number }): void {
|
|
85
|
+
console.info(
|
|
86
|
+
spaceTrim(`
|
|
87
|
+
Result: ${pingResult.result}
|
|
88
|
+
Time: ${pingResult.elapsedTimeMs.toFixed(0)} ms
|
|
89
|
+
`),
|
|
90
|
+
);
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
// Note: [🟡] Code for CLI command [ping](src/cli/cli-commands/coder/ping.ts) should never be published outside of `@promptbook/cli`
|
|
94
|
+
// Note: [💞] Ignore a discrepancy between file name and entity name
|
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
import colors from 'colors';
|
|
2
|
-
import {
|
|
2
|
+
import {
|
|
3
|
+
Command as Program /* <- Note: [🔸] Using Program because Command is misleading name */,
|
|
4
|
+
Option,
|
|
5
|
+
} from 'commander';
|
|
3
6
|
import { spaceTrim } from 'spacetrim';
|
|
4
7
|
import { assertsError } from '../../../errors/assertsError';
|
|
5
8
|
import type { $side_effect } from '../../../utils/organization/$side_effect';
|
|
@@ -14,6 +17,11 @@ import {
|
|
|
14
17
|
normalizePromptRunnerCliOptions,
|
|
15
18
|
PROMPT_RUNNER_DESCRIPTION,
|
|
16
19
|
} from '../common/promptRunnerCliOptions';
|
|
20
|
+
import {
|
|
21
|
+
DEFAULT_CODER_TEST_COMMAND,
|
|
22
|
+
TEST_BEFORE_MODE_VALUES,
|
|
23
|
+
type TestBeforeMode,
|
|
24
|
+
} from '../../../../scripts/run-codex-prompts/testing/TestBeforeMode';
|
|
17
25
|
import { DEFAULT_WAIT_AFTER_ERROR_MS, parseOptionalWaitDuration } from './waitOptions';
|
|
18
26
|
|
|
19
27
|
/**
|
|
@@ -40,6 +48,7 @@ export function $initializeCoderRunCommand(program: Program): $side_effect {
|
|
|
40
48
|
- Optional --no-ui keeps plain streaming console output for logging and debugging
|
|
41
49
|
- Checks that the selected harness is installed globally and up to date before the first prompt
|
|
42
50
|
- Supports GPG signing of commits
|
|
51
|
+
- Optional pre-coding test run that can stop or repair pre-existing failures
|
|
43
52
|
- Optional post-prompt verification with test-feedback retries
|
|
44
53
|
- Progress tracking and interactive P/S/X terminal controls
|
|
45
54
|
- Dry-run mode to preview prompts
|
|
@@ -60,6 +69,16 @@ export function $initializeCoderRunCommand(program: Program): $side_effect {
|
|
|
60
69
|
'--test <test-command...>',
|
|
61
70
|
'Run a verification command after each prompt; quote it when the command itself contains top-level flags',
|
|
62
71
|
);
|
|
72
|
+
command.addOption(
|
|
73
|
+
new Option(
|
|
74
|
+
'--test-before <mode>',
|
|
75
|
+
`Run tests before coding: ${TEST_BEFORE_MODE_VALUES.join(
|
|
76
|
+
', ',
|
|
77
|
+
)} (defaults to no; uses npm test when --test is omitted)`,
|
|
78
|
+
)
|
|
79
|
+
.choices([...TEST_BEFORE_MODE_VALUES])
|
|
80
|
+
.default('no'),
|
|
81
|
+
);
|
|
63
82
|
command.option(
|
|
64
83
|
'--preserve-logs',
|
|
65
84
|
'Keep generated temp prompt/log artifacts after successful rounds for debugging and analytics',
|
|
@@ -138,6 +157,7 @@ export function $initializeCoderRunCommand(program: Program): $side_effect {
|
|
|
138
157
|
agent,
|
|
139
158
|
context,
|
|
140
159
|
test,
|
|
160
|
+
testBefore,
|
|
141
161
|
preserveLogs,
|
|
142
162
|
isolate: isIsolated,
|
|
143
163
|
priority,
|
|
@@ -155,6 +175,7 @@ export function $initializeCoderRunCommand(program: Program): $side_effect {
|
|
|
155
175
|
readonly agent?: string;
|
|
156
176
|
readonly context?: string;
|
|
157
177
|
readonly test?: string | string[];
|
|
178
|
+
readonly testBefore: TestBeforeMode;
|
|
158
179
|
readonly preserveLogs: boolean;
|
|
159
180
|
readonly isolate: boolean;
|
|
160
181
|
readonly priority?: number;
|
|
@@ -169,7 +190,8 @@ export function $initializeCoderRunCommand(program: Program): $side_effect {
|
|
|
169
190
|
readonly allowDestructiveAutoMigrate: boolean;
|
|
170
191
|
} & PromptRunnerCliOptions;
|
|
171
192
|
|
|
172
|
-
const
|
|
193
|
+
const configuredTestCommand = normalizeCommandOptionValue(test);
|
|
194
|
+
const testCommand = configuredTestCommand ?? (testBefore === 'no' ? undefined : DEFAULT_CODER_TEST_COMMAND);
|
|
173
195
|
const runnerOptions = normalizePromptRunnerCliOptions(cliOptions as PromptRunnerCliOptions, {
|
|
174
196
|
isAgentRequired: !dryRun,
|
|
175
197
|
});
|
|
@@ -201,6 +223,7 @@ export function $initializeCoderRunCommand(program: Program): $side_effect {
|
|
|
201
223
|
agent,
|
|
202
224
|
context,
|
|
203
225
|
testCommand,
|
|
226
|
+
testBefore,
|
|
204
227
|
preserveLogs,
|
|
205
228
|
isIsolated,
|
|
206
229
|
noUi: runnerOptions.noUi,
|
|
@@ -10,6 +10,7 @@ import { $initializeCoderFindRefactorCandidatesCommand } from './coder/find-refa
|
|
|
10
10
|
import { $initializeCoderFindUnwrittenCommand } from './coder/find-unwritten';
|
|
11
11
|
import { $initializeCoderGenerateBoilerplatesCommand } from './coder/generate-boilerplates';
|
|
12
12
|
import { $initializeCoderInitCommand } from './coder/init';
|
|
13
|
+
import { $initializeCoderPingCommand } from './coder/ping';
|
|
13
14
|
import { $initializeCoderRunCommand } from './coder/run';
|
|
14
15
|
import { $initializeCoderServerCommand } from './coder/server';
|
|
15
16
|
import { $initializeCoderVerifyCommand } from './coder/verify';
|
|
@@ -22,6 +23,7 @@ import { $initializeCoderVerifyCommand } from './coder/verify';
|
|
|
22
23
|
* - add: Add one ready-to-run prompt file to the queue
|
|
23
24
|
* - generate-boilerplates: Generate prompt boilerplate files
|
|
24
25
|
* - find-refactor-candidates: Find files that need refactoring
|
|
26
|
+
* - ping: Test one harness and model connection with a disposable task
|
|
25
27
|
* - run: Run coding prompts with AI agents
|
|
26
28
|
* - verify: Verify completed prompts
|
|
27
29
|
* - find-fresh-emoji-tags: Find unused emoji tags
|
|
@@ -42,6 +44,7 @@ export function $initializeCoderCommand(program: Program): $side_effect {
|
|
|
42
44
|
- generate-boilerplates: Generate prompt boilerplate files
|
|
43
45
|
- find-refactor-candidates: Find files that need refactoring
|
|
44
46
|
- find-unwritten: List prompt sections that still need to be authored
|
|
47
|
+
- ping: Test one harness and model connection with a disposable task
|
|
45
48
|
- run: Run coding prompts with AI agents
|
|
46
49
|
- server: Start a long-running coder server with a kanban web UI
|
|
47
50
|
- verify: Verify completed prompts
|
|
@@ -55,6 +58,7 @@ export function $initializeCoderCommand(program: Program): $side_effect {
|
|
|
55
58
|
$initializeCoderGenerateBoilerplatesCommand(coderCommand);
|
|
56
59
|
$initializeCoderFindRefactorCandidatesCommand(coderCommand);
|
|
57
60
|
$initializeCoderFindUnwrittenCommand(coderCommand);
|
|
61
|
+
$initializeCoderPingCommand(coderCommand);
|
|
58
62
|
$initializeCoderRunCommand(coderCommand);
|
|
59
63
|
$initializeCoderServerCommand(coderCommand);
|
|
60
64
|
$initializeCoderVerifyCommand(coderCommand);
|