@promptbook/cli 0.112.0-112 → 0.112.0-113
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 +7 -7
- package/apps/agents-server/README.md +1 -1
- package/apps/agents-server/next.config.ts +20 -1
- package/apps/agents-server/src/app/api/admin/code-runners/route.ts +1 -1
- package/apps/agents-server/src/app/api/internal/user-chat-jobs/run/route.ts +1 -1
- package/apps/agents-server/src/instrumentation-client.ts +28 -0
- package/apps/agents-server/src/instrumentation.ts +16 -0
- package/apps/agents-server/src/sentry.edge.config.ts +18 -0
- package/apps/agents-server/src/sentry.server.config.ts +19 -0
- package/apps/agents-server/src/utils/codeRunnerConfiguration.ts +1 -1
- package/apps/agents-server/src/utils/errorReporting/agentsServerSentryContext.ts +203 -0
- package/apps/agents-server/src/utils/errorReporting/registerServerErrorSentryLogging.ts +59 -9
- package/apps/agents-server/src/utils/errorReporting/sendApplicationErrorReportToSentry.ts +39 -3
- package/apps/agents-server/src/utils/errorReporting/sentrySdkConfig.ts +237 -0
- package/apps/agents-server/src/utils/errorReporting/sentryStore.ts +10 -0
- package/apps/agents-server/src/utils/externalChatRunner/createExternalAgentRepositoryFiles.ts +2 -2
- package/apps/agents-server/src/utils/userChat/triggerUserChatJobWorker.ts +54 -19
- package/apps/agents-server/src/utils/vpsConfiguration.ts +1 -1
- package/esm/index.es.js +9325 -8883
- package/esm/index.es.js.map +1 -1
- package/esm/scripts/run-agent-chat/executeAgentChatTurn.d.ts +28 -0
- package/esm/scripts/run-agent-chat/runAgentChat.d.ts +5 -0
- package/esm/scripts/run-agent-chat/runAgentExec.d.ts +11 -0
- package/esm/scripts/run-agent-messages/messages/createAgentRunnerSystemMessage.d.ts +10 -0
- package/esm/scripts/run-codex-prompts/common/resolveInlineOrFileText.d.ts +14 -0
- package/esm/src/_packages/node.index.d.ts +20 -0
- package/esm/src/_packages/types.index.d.ts +16 -0
- package/esm/src/book-3.0/BookNodeAgentSource.d.ts +38 -0
- package/esm/src/book-3.0/CliAgent.d.ts +68 -0
- package/esm/src/book-3.0/LiteAgent.d.ts +68 -0
- package/esm/src/book-components/BookEditor/BookEditorAboutPromptbookInformation.d.ts +12 -0
- package/esm/src/cli/cli-commands/agent/agentCliOptions.d.ts +29 -0
- package/esm/src/cli/cli-commands/agent/chat.d.ts +10 -0
- package/esm/src/cli/cli-commands/agent/exec.d.ts +10 -0
- package/esm/src/cli/cli-commands/agent/run.test.d.ts +1 -0
- package/esm/src/cli/cli-commands/agent.d.ts +14 -0
- package/esm/src/cli/cli-commands/agents-server/startAgentsServer.d.ts +3 -4
- package/esm/src/cli/cli-commands/common/promptRunnerCliOptions.d.ts +9 -9
- package/esm/src/version.d.ts +1 -1
- package/package.json +2 -1
- package/src/_packages/node.index.ts +20 -0
- package/src/_packages/types.index.ts +16 -0
- package/src/book-3.0/BookNodeAgentSource.ts +135 -0
- package/src/book-3.0/CliAgent.ts +236 -0
- package/src/book-3.0/LiteAgent.ts +463 -0
- package/src/book-components/BookEditor/BookEditor.module.css +61 -0
- package/src/book-components/BookEditor/BookEditorAboutPromptbookInformation.tsx +74 -0
- package/src/book-components/BookEditor/BookEditorActionbar.tsx +3 -3
- package/src/cli/cli-commands/agent/agentCliOptions.ts +63 -0
- package/src/cli/cli-commands/agent/chat.ts +54 -0
- package/src/cli/cli-commands/agent/exec.ts +60 -0
- package/src/cli/cli-commands/agent.ts +45 -0
- package/src/cli/cli-commands/agents-server/startAgentsServer.ts +3 -19
- package/src/cli/cli-commands/coder/getDefaultCoderPackageJsonScripts.ts +1 -1
- package/src/cli/cli-commands/common/promptRunnerCliOptions.ts +27 -23
- package/src/cli/promptbookCli.ts +2 -0
- package/src/other/templates/getTemplatesPipelineCollection.ts +836 -774
- package/src/version.ts +2 -2
- package/src/versions.txt +1 -0
- package/umd/index.umd.js +9325 -8883
- package/umd/index.umd.js.map +1 -1
- package/umd/scripts/run-agent-chat/executeAgentChatTurn.d.ts +28 -0
- package/umd/scripts/run-agent-chat/runAgentChat.d.ts +5 -0
- package/umd/scripts/run-agent-chat/runAgentExec.d.ts +11 -0
- package/umd/scripts/run-agent-messages/messages/createAgentRunnerSystemMessage.d.ts +10 -0
- package/umd/scripts/run-codex-prompts/common/resolveInlineOrFileText.d.ts +14 -0
- package/umd/src/_packages/node.index.d.ts +20 -0
- package/umd/src/_packages/types.index.d.ts +16 -0
- package/umd/src/book-3.0/BookNodeAgentSource.d.ts +38 -0
- package/umd/src/book-3.0/CliAgent.d.ts +68 -0
- package/umd/src/book-3.0/CliAgent.test.d.ts +1 -0
- package/umd/src/book-3.0/LiteAgent.d.ts +68 -0
- package/umd/src/book-3.0/LiteAgent.test.d.ts +1 -0
- package/umd/src/book-components/BookEditor/BookEditorAboutPromptbookInformation.d.ts +12 -0
- package/umd/src/cli/cli-commands/agent/agentCliOptions.d.ts +29 -0
- package/umd/src/cli/cli-commands/agent/chat.d.ts +10 -0
- package/umd/src/cli/cli-commands/agent/exec.d.ts +10 -0
- package/umd/src/cli/cli-commands/agent/run.test.d.ts +1 -0
- package/umd/src/cli/cli-commands/agent.d.ts +14 -0
- package/umd/src/cli/cli-commands/agents-server/startAgentsServer.d.ts +3 -4
- package/umd/src/cli/cli-commands/common/promptRunnerCliOptions.d.ts +9 -9
- package/umd/src/version.d.ts +1 -1
- /package/esm/src/{cli/cli-commands/agents-server/startAgentsServer.test.d.ts → book-3.0/CliAgent.test.d.ts} +0 -0
- /package/{umd/src/cli/cli-commands/agents-server/startAgentsServer.test.d.ts → esm/src/book-3.0/LiteAgent.test.d.ts} +0 -0
|
@@ -0,0 +1,54 @@
|
|
|
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 type { $side_effect } from '../../../utils/organization/$side_effect';
|
|
6
|
+
import { handleActionErrors } from '../common/handleActionErrors';
|
|
7
|
+
import {
|
|
8
|
+
addPromptRunnerRuntimeOptions,
|
|
9
|
+
addPromptRunnerSelectionOptions,
|
|
10
|
+
PROMPT_RUNNER_DESCRIPTION,
|
|
11
|
+
} from '../common/promptRunnerCliOptions';
|
|
12
|
+
import type { AgentCommandCliOptions } from './agentCliOptions';
|
|
13
|
+
import { normalizeAgentCommandRunnerOptions, resolveRequiredAgentPath } from './agentCliOptions';
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Initializes `agent chat` command for Promptbook CLI utilities.
|
|
17
|
+
*
|
|
18
|
+
* Note: `$` is used to indicate that this function is not a pure function - it registers a command in the CLI.
|
|
19
|
+
*
|
|
20
|
+
* @private internal function of `promptbookCli`
|
|
21
|
+
*/
|
|
22
|
+
export function $initializeAgentChatCommand(program: Program): $side_effect {
|
|
23
|
+
const command = program.command('chat');
|
|
24
|
+
command.description(
|
|
25
|
+
spaceTrim(`
|
|
26
|
+
Run an interactive CLI chat with one Promptbook agent book
|
|
27
|
+
|
|
28
|
+
${PROMPT_RUNNER_DESCRIPTION}
|
|
29
|
+
`),
|
|
30
|
+
);
|
|
31
|
+
|
|
32
|
+
command.requiredOption('--agent <agent-book-path>', 'Path to the agent .book file');
|
|
33
|
+
addPromptRunnerSelectionOptions(command);
|
|
34
|
+
addPromptRunnerRuntimeOptions(command);
|
|
35
|
+
command.option('--context <context-or-file>', 'Append extra context either inline or from a file path');
|
|
36
|
+
|
|
37
|
+
command.action(
|
|
38
|
+
handleActionErrors(async (cliOptions) => {
|
|
39
|
+
const options = cliOptions as AgentCommandCliOptions;
|
|
40
|
+
const runnerOptions = normalizeAgentCommandRunnerOptions(options);
|
|
41
|
+
const { runAgentChat } = await import('../../../../scripts/run-agent-chat/runAgentChat');
|
|
42
|
+
|
|
43
|
+
await runAgentChat({
|
|
44
|
+
agentPath: resolveRequiredAgentPath(options),
|
|
45
|
+
context: options.context,
|
|
46
|
+
currentWorkingDirectory: process.cwd(),
|
|
47
|
+
...runnerOptions,
|
|
48
|
+
});
|
|
49
|
+
}),
|
|
50
|
+
);
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
// Note: [🟡] Code for CLI command [agent chat](src/cli/cli-commands/agent/chat.ts) should never be published outside of `@promptbook/cli`
|
|
54
|
+
// Note: [💞] Ignore a discrepancy between file name and entity name
|
|
@@ -0,0 +1,60 @@
|
|
|
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 type { $side_effect } from '../../../utils/organization/$side_effect';
|
|
6
|
+
import { handleActionErrors } from '../common/handleActionErrors';
|
|
7
|
+
import {
|
|
8
|
+
addPromptRunnerRuntimeOptions,
|
|
9
|
+
addPromptRunnerSelectionOptions,
|
|
10
|
+
PROMPT_RUNNER_DESCRIPTION,
|
|
11
|
+
} from '../common/promptRunnerCliOptions';
|
|
12
|
+
import type { AgentCommandCliOptions } from './agentCliOptions';
|
|
13
|
+
import {
|
|
14
|
+
normalizeAgentCommandRunnerOptions,
|
|
15
|
+
resolveRequiredAgentMessage,
|
|
16
|
+
resolveRequiredAgentPath,
|
|
17
|
+
} from './agentCliOptions';
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Initializes `agent exec` command for Promptbook CLI utilities.
|
|
21
|
+
*
|
|
22
|
+
* Note: `$` is used to indicate that this function is not a pure function - it registers a command in the CLI.
|
|
23
|
+
*
|
|
24
|
+
* @private internal function of `promptbookCli`
|
|
25
|
+
*/
|
|
26
|
+
export function $initializeAgentExecCommand(program: Program): $side_effect {
|
|
27
|
+
const command = program.command('exec');
|
|
28
|
+
command.description(
|
|
29
|
+
spaceTrim(`
|
|
30
|
+
Run one non-interactive message with a Promptbook agent book and print the answer
|
|
31
|
+
|
|
32
|
+
${PROMPT_RUNNER_DESCRIPTION}
|
|
33
|
+
`),
|
|
34
|
+
);
|
|
35
|
+
|
|
36
|
+
command.requiredOption('--agent <agent-book-path>', 'Path to the agent .book file');
|
|
37
|
+
command.requiredOption('--message <message>', 'User message to send to the agent');
|
|
38
|
+
addPromptRunnerSelectionOptions(command);
|
|
39
|
+
addPromptRunnerRuntimeOptions(command);
|
|
40
|
+
command.option('--context <context-or-file>', 'Append extra context either inline or from a file path');
|
|
41
|
+
|
|
42
|
+
command.action(
|
|
43
|
+
handleActionErrors(async (cliOptions) => {
|
|
44
|
+
const options = cliOptions as AgentCommandCliOptions;
|
|
45
|
+
const runnerOptions = normalizeAgentCommandRunnerOptions(options);
|
|
46
|
+
const { runAgentExec } = await import('../../../../scripts/run-agent-chat/runAgentExec');
|
|
47
|
+
|
|
48
|
+
await runAgentExec({
|
|
49
|
+
agentPath: resolveRequiredAgentPath(options),
|
|
50
|
+
context: options.context,
|
|
51
|
+
message: resolveRequiredAgentMessage(options),
|
|
52
|
+
currentWorkingDirectory: process.cwd(),
|
|
53
|
+
...runnerOptions,
|
|
54
|
+
});
|
|
55
|
+
}),
|
|
56
|
+
);
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
// Note: [🟡] Code for CLI command [agent exec](src/cli/cli-commands/agent/exec.ts) should never be published outside of `@promptbook/cli`
|
|
60
|
+
// Note: [💞] Ignore a discrepancy between file name and entity name
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import colors from 'colors';
|
|
2
|
+
import type {
|
|
3
|
+
Command as Program /* <- Note: [🔸] Using Program because Command is misleading name */,
|
|
4
|
+
} from 'commander';
|
|
5
|
+
import { spaceTrim } from 'spacetrim';
|
|
6
|
+
import type { $side_effect } from '../../utils/organization/$side_effect';
|
|
7
|
+
import { $initializeAgentChatCommand } from './agent/chat';
|
|
8
|
+
import { $initializeAgentExecCommand } from './agent/exec';
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Initializes `agent` command with subcommands for Promptbook CLI utilities.
|
|
12
|
+
*
|
|
13
|
+
* The agent command runs one `.book` source directly through a selected CLI harness:
|
|
14
|
+
* - chat: Run an interactive terminal chat session
|
|
15
|
+
* - exec: Send one message and print the response
|
|
16
|
+
*
|
|
17
|
+
* Note: `$` is used to indicate that this function is not a pure function - it registers a command in the CLI.
|
|
18
|
+
*
|
|
19
|
+
* @private internal function of `promptbookCli`
|
|
20
|
+
*/
|
|
21
|
+
export function $initializeAgentCommand(program: Program): $side_effect {
|
|
22
|
+
const agentCommand = program.command('agent');
|
|
23
|
+
agentCommand.description(
|
|
24
|
+
spaceTrim(`
|
|
25
|
+
Run a Promptbook agent book directly in the terminal
|
|
26
|
+
|
|
27
|
+
Subcommands:
|
|
28
|
+
- chat: Run an interactive terminal chat session
|
|
29
|
+
- exec: Send one message and print the response
|
|
30
|
+
`),
|
|
31
|
+
);
|
|
32
|
+
|
|
33
|
+
$initializeAgentChatCommand(agentCommand);
|
|
34
|
+
$initializeAgentExecCommand(agentCommand);
|
|
35
|
+
|
|
36
|
+
agentCommand.action(() => {
|
|
37
|
+
console.info(colors.yellow('Please specify a subcommand.'));
|
|
38
|
+
console.info('');
|
|
39
|
+
agentCommand.help();
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
// Note: [🟡] Code for CLI command [agent](src/cli/cli-commands/agent.ts) should never be published outside of `@promptbook/cli`
|
|
44
|
+
// Note: [💞] Ignore a discrepancy between file name and entity name
|
|
45
|
+
|
|
@@ -6,7 +6,7 @@ import { join } from 'path';
|
|
|
6
6
|
import * as dotenv from 'dotenv';
|
|
7
7
|
import { spaceTrim } from 'spacetrim';
|
|
8
8
|
import type { ThinkingLevel } from '../coder/ThinkingLevel';
|
|
9
|
-
import type {
|
|
9
|
+
import type { PromptRunnerHarnessName } from '../common/promptRunnerCliOptions';
|
|
10
10
|
import { NotAllowed } from '../../../errors/NotAllowed';
|
|
11
11
|
import type { number_port } from '../../../types/number_positive';
|
|
12
12
|
import { resolvePromptbookTemporaryPath } from '../../../utils/filesystem/promptbookTemporaryPath';
|
|
@@ -107,13 +107,6 @@ const PTBK_AGENTS_SERVER_SQLITE_PATH_ENV = 'PTBK_AGENTS_SERVER_SQLITE_PATH';
|
|
|
107
107
|
*/
|
|
108
108
|
const PTBK_HOSTNAME_ENV = 'PTBK_HOSTNAME';
|
|
109
109
|
|
|
110
|
-
/**
|
|
111
|
-
* Explicit installed `.env` file passed by standalone VPS pm2/runtime launchers.
|
|
112
|
-
*
|
|
113
|
-
* @private internal constant of `ptbk agents-server`
|
|
114
|
-
*/
|
|
115
|
-
const PTBK_AGENTS_SERVER_ENV_FILE_ENV = 'PTBK_AGENTS_SERVER_ENV_FILE';
|
|
116
|
-
|
|
117
110
|
/**
|
|
118
111
|
* Entropy size for the local-only token shared by the CLI pump and the Next app.
|
|
119
112
|
*
|
|
@@ -135,7 +128,7 @@ export type AgentsServerNextRuntimeMode = 'start' | 'dev';
|
|
|
135
128
|
*/
|
|
136
129
|
export type StartAgentsServerOptions = {
|
|
137
130
|
readonly port: number_port;
|
|
138
|
-
readonly agentName:
|
|
131
|
+
readonly agentName: PromptRunnerHarnessName;
|
|
139
132
|
readonly model?: string;
|
|
140
133
|
readonly noUi: boolean;
|
|
141
134
|
readonly thinkingLevel?: ThinkingLevel;
|
|
@@ -362,20 +355,11 @@ async function prepareAgentsServerDevelopmentRuntime(
|
|
|
362
355
|
}
|
|
363
356
|
|
|
364
357
|
/**
|
|
365
|
-
* Loads
|
|
366
|
-
* to the launch-directory `.env`.
|
|
358
|
+
* Loads launch-directory `.env` values without overriding explicit process environment.
|
|
367
359
|
*
|
|
368
360
|
* @private internal utility of `ptbk agents-server`
|
|
369
361
|
*/
|
|
370
362
|
export function loadAgentsServerProjectEnvironment(launchWorkingDirectory: string): void {
|
|
371
|
-
const explicitEnvFilePath = process.env[PTBK_AGENTS_SERVER_ENV_FILE_ENV]?.trim();
|
|
372
|
-
if (explicitEnvFilePath) {
|
|
373
|
-
const explicitLoadResult = dotenv.config({ path: explicitEnvFilePath, override: true });
|
|
374
|
-
if (!explicitLoadResult.error) {
|
|
375
|
-
return;
|
|
376
|
-
}
|
|
377
|
-
}
|
|
378
|
-
|
|
379
363
|
dotenv.config({ path: join(launchWorkingDirectory, AGENTS_SERVER_PROJECT_ENV_FILE_NAME) });
|
|
380
364
|
}
|
|
381
365
|
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
const DEFAULT_CODER_PACKAGE_JSON_SCRIPTS = {
|
|
5
5
|
'coder:generate-boilerplates': 'ptbk coder generate-boilerplates --template ./prompts/templates/common.md',
|
|
6
6
|
'coder:run':
|
|
7
|
-
'ptbk coder run --
|
|
7
|
+
'ptbk coder run --harness github-copilot --model gpt-5.4 --thinking-level xhigh --context AGENTS.md --no-wait',
|
|
8
8
|
'coder:find-refactor-candidates': 'ptbk coder find-refactor-candidates',
|
|
9
9
|
'coder:verify': 'ptbk coder verify',
|
|
10
10
|
} as const satisfies Readonly<Record<string, string>>;
|
|
@@ -12,7 +12,7 @@ import { THINKING_LEVEL_VALUES } from '../coder/ThinkingLevel';
|
|
|
12
12
|
*
|
|
13
13
|
* @private internal utility of `promptbookCli`
|
|
14
14
|
*/
|
|
15
|
-
export const
|
|
15
|
+
export const PROMPT_RUNNER_HARNESS_NAMES = [
|
|
16
16
|
'openai-codex',
|
|
17
17
|
'github-copilot',
|
|
18
18
|
'cline',
|
|
@@ -22,11 +22,11 @@ export const PROMPT_RUNNER_AGENT_NAMES = [
|
|
|
22
22
|
] as const;
|
|
23
23
|
|
|
24
24
|
/**
|
|
25
|
-
* Environment variable used as the default runner identifier when `--
|
|
25
|
+
* Environment variable used as the default runner identifier when `--harness` is omitted.
|
|
26
26
|
*
|
|
27
27
|
* @private internal utility of `promptbookCli`
|
|
28
28
|
*/
|
|
29
|
-
export const
|
|
29
|
+
export const PTBK_HARNESS_ENV = 'PTBK_HARNESS';
|
|
30
30
|
|
|
31
31
|
/**
|
|
32
32
|
* Environment variable used as the default runner model when `--model` is omitted.
|
|
@@ -47,7 +47,7 @@ export const PTBK_THINKING_LEVEL_ENV = 'PTBK_THINKING_LEVEL';
|
|
|
47
47
|
*
|
|
48
48
|
* @private internal utility of `promptbookCli`
|
|
49
49
|
*/
|
|
50
|
-
export type
|
|
50
|
+
export type PromptRunnerHarnessName = (typeof PROMPT_RUNNER_HARNESS_NAMES)[number];
|
|
51
51
|
|
|
52
52
|
/**
|
|
53
53
|
* Commander option bag for shared runner flags.
|
|
@@ -55,7 +55,7 @@ export type PromptRunnerAgentName = (typeof PROMPT_RUNNER_AGENT_NAMES)[number];
|
|
|
55
55
|
* @private internal utility of `promptbookCli`
|
|
56
56
|
*/
|
|
57
57
|
export type PromptRunnerCliOptions = {
|
|
58
|
-
readonly
|
|
58
|
+
readonly harness?: string;
|
|
59
59
|
readonly model?: string;
|
|
60
60
|
readonly ui: boolean;
|
|
61
61
|
readonly thinkingLevel?: ThinkingLevel;
|
|
@@ -74,7 +74,7 @@ export type PromptRunnerCliOptions = {
|
|
|
74
74
|
*/
|
|
75
75
|
export type PromptRunnerSelectionCliOptions = Pick<
|
|
76
76
|
PromptRunnerCliOptions,
|
|
77
|
-
'
|
|
77
|
+
'harness' | 'model' | 'ui' | 'thinkingLevel' | 'allowCredits'
|
|
78
78
|
>;
|
|
79
79
|
|
|
80
80
|
/**
|
|
@@ -83,7 +83,7 @@ export type PromptRunnerSelectionCliOptions = Pick<
|
|
|
83
83
|
* @private internal utility of `promptbookCli`
|
|
84
84
|
*/
|
|
85
85
|
export type NormalizedPromptRunnerCliOptions = {
|
|
86
|
-
readonly agentName?:
|
|
86
|
+
readonly agentName?: PromptRunnerHarnessName;
|
|
87
87
|
readonly model?: string;
|
|
88
88
|
readonly noUi: boolean;
|
|
89
89
|
readonly thinkingLevel?: ThinkingLevel;
|
|
@@ -121,11 +121,11 @@ export const PROMPT_RUNNER_DESCRIPTION = spaceTrim(`
|
|
|
121
121
|
`);
|
|
122
122
|
|
|
123
123
|
/**
|
|
124
|
-
* Commander description for the `--
|
|
124
|
+
* Commander description for the `--harness` option.
|
|
125
125
|
*
|
|
126
126
|
* @private internal utility of `promptbookCli`
|
|
127
127
|
*/
|
|
128
|
-
export const
|
|
128
|
+
export const PROMPT_RUNNER_HARNESS_OPTION_DESCRIPTION =
|
|
129
129
|
'Select runner: openai-codex, github-copilot, cline, claude-code, opencode, gemini (required for non-dry-run)';
|
|
130
130
|
|
|
131
131
|
/**
|
|
@@ -146,7 +146,9 @@ export const PROMPT_RUNNER_MODEL_OPTION_DESCRIPTION = spaceTrim(`
|
|
|
146
146
|
* @private internal utility of `promptbookCli`
|
|
147
147
|
*/
|
|
148
148
|
export function addPromptRunnerSelectionOptions(command: Program): void {
|
|
149
|
-
command.addOption(
|
|
149
|
+
command.addOption(
|
|
150
|
+
new Option('--harness <harness-name>', PROMPT_RUNNER_HARNESS_OPTION_DESCRIPTION).env(PTBK_HARNESS_ENV),
|
|
151
|
+
);
|
|
150
152
|
command.addOption(new Option('--model <model>', PROMPT_RUNNER_MODEL_OPTION_DESCRIPTION).env(PTBK_MODEL_ENV));
|
|
151
153
|
}
|
|
152
154
|
|
|
@@ -227,7 +229,7 @@ export function normalizePromptRunnerSelectionCliOptions(
|
|
|
227
229
|
},
|
|
228
230
|
): NormalizedPromptRunnerSelectionCliOptions {
|
|
229
231
|
return {
|
|
230
|
-
agentName:
|
|
232
|
+
agentName: resolvePromptRunnerHarnessName(cliOptions.harness, options),
|
|
231
233
|
model: cliOptions.model,
|
|
232
234
|
noUi: !cliOptions.ui,
|
|
233
235
|
thinkingLevel: cliOptions.thinkingLevel,
|
|
@@ -236,38 +238,40 @@ export function normalizePromptRunnerSelectionCliOptions(
|
|
|
236
238
|
}
|
|
237
239
|
|
|
238
240
|
/**
|
|
239
|
-
* Parses and validates one runner
|
|
241
|
+
* Parses and validates one runner harness name.
|
|
240
242
|
*/
|
|
241
|
-
function
|
|
242
|
-
|
|
243
|
+
function resolvePromptRunnerHarnessName(
|
|
244
|
+
harness: string | undefined,
|
|
243
245
|
options: {
|
|
244
246
|
readonly isAgentRequired: boolean;
|
|
245
247
|
},
|
|
246
|
-
):
|
|
247
|
-
if (!
|
|
248
|
+
): PromptRunnerHarnessName | undefined {
|
|
249
|
+
if (!harness) {
|
|
248
250
|
if (!options.isAgentRequired) {
|
|
249
251
|
return undefined;
|
|
250
252
|
}
|
|
251
253
|
|
|
252
254
|
throw new Error(
|
|
253
255
|
colors.red(
|
|
254
|
-
'You must choose
|
|
256
|
+
'You must choose a harness using --harness <openai-codex|github-copilot|cline|claude-code|opencode|gemini>',
|
|
255
257
|
),
|
|
256
258
|
);
|
|
257
259
|
}
|
|
258
260
|
|
|
259
|
-
if (
|
|
260
|
-
return
|
|
261
|
+
if (isPromptRunnerHarnessName(harness)) {
|
|
262
|
+
return harness;
|
|
261
263
|
}
|
|
262
264
|
|
|
263
|
-
throw new Error(
|
|
265
|
+
throw new Error(
|
|
266
|
+
colors.red(`Invalid harness "${harness}". Must be one of: ${PROMPT_RUNNER_HARNESS_NAMES.join(', ')}`),
|
|
267
|
+
);
|
|
264
268
|
}
|
|
265
269
|
|
|
266
270
|
/**
|
|
267
|
-
* Checks whether a string is one supported runner
|
|
271
|
+
* Checks whether a string is one supported runner harness name.
|
|
268
272
|
*/
|
|
269
|
-
function
|
|
270
|
-
return
|
|
273
|
+
function isPromptRunnerHarnessName(harness: string): harness is PromptRunnerHarnessName {
|
|
274
|
+
return PROMPT_RUNNER_HARNESS_NAMES.includes(harness as PromptRunnerHarnessName);
|
|
271
275
|
}
|
|
272
276
|
|
|
273
277
|
// Note: [🟡] Code for CLI runner options [promptRunnerCliOptions](src/cli/cli-commands/common/promptRunnerCliOptions.ts) should never be published outside of `@promptbook/cli`
|
package/src/cli/promptbookCli.ts
CHANGED
|
@@ -6,6 +6,7 @@ import { EnvironmentMismatchError } from '../errors/EnvironmentMismatchError';
|
|
|
6
6
|
import { $isRunningInNode } from '../utils/environment/$isRunningInNode';
|
|
7
7
|
import { PROMPTBOOK_ENGINE_VERSION } from '../version';
|
|
8
8
|
import { $initializeAboutCommand } from './cli-commands/about';
|
|
9
|
+
import { $initializeAgentCommand } from './cli-commands/agent';
|
|
9
10
|
import { $initializeAgentFolderCommand } from './cli-commands/agent-folder';
|
|
10
11
|
import { $initializeAgentsServerCommand } from './cli-commands/agents-server';
|
|
11
12
|
import { $initializeCoderCommand } from './cli-commands/coder';
|
|
@@ -93,6 +94,7 @@ export async function promptbookCli(): Promise<void> {
|
|
|
93
94
|
$initializeListScrapersCommand(program);
|
|
94
95
|
$initializeStartAgentsServerCommand(program);
|
|
95
96
|
$initializeStartPipelinesServerCommand(program);
|
|
97
|
+
$initializeAgentCommand(program);
|
|
96
98
|
$initializeAgentFolderCommand(program);
|
|
97
99
|
$initializeAgentsServerCommand(program);
|
|
98
100
|
$initializeCoderCommand(program);
|