@promptbook/cli 0.114.0-1 → 0.114.0-3
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/next.config.ts +11 -0
- 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/layout.tsx +6 -0
- 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 +1105 -273
- package/esm/index.es.js.map +1 -1
- package/esm/scripts/run-codex-prompts/common/runGoScript/scriptExecutionLog.d.ts +7 -0
- package/esm/scripts/run-codex-prompts/git/coderGitSync.d.ts +43 -0
- package/esm/scripts/run-codex-prompts/git/commitChanges.d.ts +3 -0
- package/esm/scripts/run-codex-prompts/main/resolvePromptRunner.d.ts +8 -1
- package/esm/scripts/run-codex-prompts/ping/buildCoderPingPrompt.d.ts +20 -0
- package/esm/scripts/run-codex-prompts/ping/extractCoderPingAnswer.d.ts +9 -0
- package/esm/scripts/run-codex-prompts/ping/pingCoderHarness.d.ts +23 -0
- package/esm/scripts/run-codex-prompts/ping/printCoderPingResult.d.ts +5 -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/scripts/verify-prompts/verify-prompts.d.ts +5 -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/$provideServerDomWindow.d.ts +11 -0
- package/esm/src/book-components/Chat/utils/renderMarkdown.d.ts +7 -0
- package/esm/src/cli/cli-commands/agents-server/buildAgentsServer/createAgentsServerRuntimeEnvironment.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 +10 -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/esm/src/cli/cli-commands/common/coderGitSyncCliOptions.d.ts +34 -0
- package/esm/src/cli/cli-commands/common/coderGitSyncCliOptions.test.d.ts +1 -0
- package/esm/src/cli/common/loadPromptsModule.d.ts +16 -0
- package/esm/src/llm-providers/anthropic-claude/AnthropicClaudeExecutionTools.d.ts +1 -1
- package/esm/src/llm-providers/azure-openai/AzureOpenAiExecutionTools.d.ts +1 -1
- package/esm/src/llm-providers/openai/OpenAiAgentKitExecutionTools.d.ts +1 -1
- package/esm/src/llm-providers/openai/OpenAiAgentKitExecutionToolsToolBuilder.d.ts +1 -1
- package/esm/src/llm-providers/openai/OpenAiAssistantExecutionToolsStreamRunner.d.ts +1 -1
- package/esm/src/llm-providers/openai/OpenAiAssistantExecutionToolsToolRunner.d.ts +1 -1
- package/esm/src/llm-providers/openai/OpenAiCompatibleNonChatPromptCaller.d.ts +1 -1
- package/esm/src/llm-providers/openai/OpenAiCompatibleRequestManager.d.ts +1 -1
- package/esm/src/llm-providers/openai/utils/callOpenAiCompatibleChatModel.d.ts +1 -1
- package/esm/src/llm-providers/openai/utils/loadOpenAiAgentsModule.d.ts +203 -0
- package/esm/src/llm-providers/openai/utils/uploadFilesToOpenAi.d.ts +1 -1
- package/esm/src/utils/misc/createLazyModuleLoader.d.ts +14 -0
- package/esm/src/version.d.ts +1 -1
- 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-3.0/LiteAgent.ts +11 -9
- package/src/book-components/Chat/utils/$provideServerDomWindow.ts +77 -0
- package/src/book-components/Chat/utils/renderMarkdown.ts +135 -32
- package/src/cli/cli-commands/agents-server/buildAgentsServer/createAgentsServerRuntimeEnvironment.ts +14 -0
- package/src/cli/cli-commands/agents-server/buildAgentsServer/ensureAgentsServerBuild.ts +1 -0
- package/src/cli/cli-commands/agents-server/startAgentsServer/createLocalAgentRunOptions.ts +1 -0
- package/src/cli/cli-commands/coder/add.ts +40 -12
- package/src/cli/cli-commands/coder/agentCodingFile.ts +6 -129
- package/src/cli/cli-commands/coder/generate-boilerplates.ts +31 -5
- package/src/cli/cli-commands/coder/getDefaultCoderPackageJsonScripts.ts +1 -1
- package/src/cli/cli-commands/coder/init.ts +27 -1
- package/src/cli/cli-commands/coder/initializeCoderProjectConfiguration.ts +1 -4
- package/src/cli/cli-commands/coder/ping.ts +72 -0
- package/src/cli/cli-commands/coder/run.ts +25 -2
- package/src/cli/cli-commands/coder/verify.ts +27 -12
- package/src/cli/cli-commands/coder.ts +4 -0
- package/src/cli/cli-commands/common/coderGitSyncCliOptions.ts +78 -0
- package/src/cli/cli-commands/run/prepareRunCommandResources.ts +2 -1
- package/src/cli/cli-commands/run/resolveRunInputParameters.ts +2 -1
- package/src/cli/cli-commands/runInteractiveChatbot.ts +2 -1
- package/src/cli/common/$provideLlmToolsForCli.ts +2 -1
- package/src/cli/common/loadPromptsModule.ts +13 -0
- package/src/conversion/archive/loadArchive.ts +2 -1
- package/src/conversion/archive/loadJsZipModule.ts +10 -0
- package/src/conversion/archive/saveArchive.ts +2 -1
- package/src/llm-providers/anthropic-claude/AnthropicClaudeExecutionTools.ts +13 -1
- package/src/llm-providers/azure-openai/AzureOpenAiExecutionTools.ts +13 -1
- package/src/llm-providers/openai/OpenAiAgentKitExecutionTools.ts +6 -2
- package/src/llm-providers/openai/OpenAiAgentKitExecutionToolsToolBuilder.ts +7 -5
- package/src/llm-providers/openai/OpenAiAssistantExecutionTools.ts +1 -1
- package/src/llm-providers/openai/OpenAiAssistantExecutionToolsStreamRunner.ts +1 -1
- package/src/llm-providers/openai/OpenAiAssistantExecutionToolsToolRunner.ts +1 -1
- package/src/llm-providers/openai/OpenAiCompatibleNonChatPromptCaller.ts +1 -1
- package/src/llm-providers/openai/OpenAiCompatibleRequestManager.ts +12 -1
- package/src/llm-providers/openai/utils/callOpenAiCompatibleChatModel.ts +1 -1
- package/src/llm-providers/openai/utils/loadOpenAiAgentsModule.ts +11 -0
- package/src/llm-providers/openai/utils/uploadFilesToOpenAi.ts +1 -1
- package/src/other/templates/getTemplatesPipelineCollection.ts +731 -923
- package/src/remote-server/createRemoteClient.ts +12 -1
- package/src/scrapers/website/WebsiteScraper.ts +22 -2
- package/src/utils/agent-message-runtime/resolveAgentMessageRuntimeActivity.ts +101 -0
- package/src/utils/misc/createLazyModuleLoader.ts +27 -0
- package/src/version.ts +2 -2
- package/src/versions.txt +2 -1
- package/umd/index.umd.js +1180 -342
- package/umd/index.umd.js.map +1 -1
- package/umd/scripts/run-codex-prompts/common/runGoScript/scriptExecutionLog.d.ts +7 -0
- package/umd/scripts/run-codex-prompts/git/coderGitSync.d.ts +43 -0
- package/umd/scripts/run-codex-prompts/git/commitChanges.d.ts +3 -0
- package/umd/scripts/run-codex-prompts/main/resolvePromptRunner.d.ts +8 -1
- package/umd/scripts/run-codex-prompts/ping/buildCoderPingPrompt.d.ts +20 -0
- package/umd/scripts/run-codex-prompts/ping/extractCoderPingAnswer.d.ts +9 -0
- package/umd/scripts/run-codex-prompts/ping/pingCoderHarness.d.ts +23 -0
- package/umd/scripts/run-codex-prompts/ping/printCoderPingResult.d.ts +5 -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/scripts/verify-prompts/verify-prompts.d.ts +5 -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/$provideServerDomWindow.d.ts +11 -0
- package/umd/src/book-components/Chat/utils/renderMarkdown.d.ts +7 -0
- package/umd/src/cli/cli-commands/agents-server/buildAgentsServer/createAgentsServerRuntimeEnvironment.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 +10 -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/umd/src/cli/cli-commands/common/coderGitSyncCliOptions.d.ts +34 -0
- package/umd/src/cli/cli-commands/common/coderGitSyncCliOptions.test.d.ts +1 -0
- package/umd/src/cli/common/loadPromptsModule.d.ts +16 -0
- package/umd/src/llm-providers/anthropic-claude/AnthropicClaudeExecutionTools.d.ts +1 -1
- package/umd/src/llm-providers/azure-openai/AzureOpenAiExecutionTools.d.ts +1 -1
- package/umd/src/llm-providers/openai/OpenAiAgentKitExecutionTools.d.ts +1 -1
- package/umd/src/llm-providers/openai/OpenAiAgentKitExecutionToolsToolBuilder.d.ts +1 -1
- package/umd/src/llm-providers/openai/OpenAiAssistantExecutionToolsStreamRunner.d.ts +1 -1
- package/umd/src/llm-providers/openai/OpenAiAssistantExecutionToolsToolRunner.d.ts +1 -1
- package/umd/src/llm-providers/openai/OpenAiCompatibleNonChatPromptCaller.d.ts +1 -1
- package/umd/src/llm-providers/openai/OpenAiCompatibleRequestManager.d.ts +1 -1
- package/umd/src/llm-providers/openai/utils/callOpenAiCompatibleChatModel.d.ts +1 -1
- package/umd/src/llm-providers/openai/utils/loadOpenAiAgentsModule.d.ts +203 -0
- package/umd/src/llm-providers/openai/utils/uploadFilesToOpenAi.d.ts +1 -1
- package/umd/src/utils/misc/createLazyModuleLoader.d.ts +14 -0
- package/umd/src/version.d.ts +1 -1
- 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
|
@@ -3,6 +3,12 @@ import type {
|
|
|
3
3
|
} from 'commander';
|
|
4
4
|
import { spaceTrim } from 'spacetrim';
|
|
5
5
|
import type { $side_effect } from '../../../utils/organization/$side_effect';
|
|
6
|
+
import type { CoderGitSyncCliOptions } from '../common/coderGitSyncCliOptions';
|
|
7
|
+
import {
|
|
8
|
+
addCoderGitSyncOptions,
|
|
9
|
+
CODER_GIT_SYNC_DESCRIPTION,
|
|
10
|
+
normalizeCoderGitSyncCliOptions,
|
|
11
|
+
} from '../common/coderGitSyncCliOptions';
|
|
6
12
|
import { handleActionErrors } from '../common/handleActionErrors';
|
|
7
13
|
import { $ensureHarnessInstallations } from '../common/harness/$ensureHarnessInstallations';
|
|
8
14
|
import { getHarnessDefinition } from '../common/harness/HarnessDefinition';
|
|
@@ -61,16 +67,36 @@ export function $initializeCoderInitCommand(program: Program): $side_effect {
|
|
|
61
67
|
|
|
62
68
|
Checks that the coding harnesses are installed globally and up to date:
|
|
63
69
|
${block(listCheckedHarnessLabels())}
|
|
70
|
+
|
|
71
|
+
${block(CODER_GIT_SYNC_DESCRIPTION)}
|
|
64
72
|
`,
|
|
65
73
|
),
|
|
66
74
|
);
|
|
67
75
|
|
|
76
|
+
addCoderGitSyncOptions(command);
|
|
77
|
+
|
|
68
78
|
command.action(
|
|
69
|
-
handleActionErrors(async () => {
|
|
79
|
+
handleActionErrors(async (cliOptions) => {
|
|
80
|
+
const gitSync = normalizeCoderGitSyncCliOptions(cliOptions as CoderGitSyncCliOptions);
|
|
70
81
|
const projectPath = process.cwd();
|
|
82
|
+
|
|
83
|
+
// Note: Import the git synchronization dynamically to keep the CLI fast for runs without `--commit`
|
|
84
|
+
const { $commitCoderChanges, $pullCoderChanges } = await import(
|
|
85
|
+
'../../../../scripts/run-codex-prompts/git/coderGitSync'
|
|
86
|
+
);
|
|
87
|
+
|
|
88
|
+
await $pullCoderChanges({ gitSync, projectPath });
|
|
89
|
+
|
|
71
90
|
const summary = await initializeCoderProjectConfiguration(projectPath);
|
|
72
91
|
printInitializationSummary(summary);
|
|
73
92
|
await generatePromptBoilerplate({ projectPath, filesCount: 5 });
|
|
93
|
+
|
|
94
|
+
await $commitCoderChanges({
|
|
95
|
+
gitSync,
|
|
96
|
+
projectPath,
|
|
97
|
+
commitMessage: 'Initialize Promptbook Coder',
|
|
98
|
+
});
|
|
99
|
+
|
|
74
100
|
await $ensureHarnessInstallations(CODER_INIT_CHECKED_HARNESS_NAMES);
|
|
75
101
|
}),
|
|
76
102
|
);
|
|
@@ -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,72 @@
|
|
|
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 { $ensureHarnessInstallations } from '../common/harness/$ensureHarnessInstallations';
|
|
8
|
+
import type { PromptRunnerSelectionCliOptions } from '../common/promptRunnerCliOptions';
|
|
9
|
+
import {
|
|
10
|
+
addPromptRunnerRuntimeOptions,
|
|
11
|
+
addPromptRunnerSelectionOptions,
|
|
12
|
+
normalizePromptRunnerSelectionCliOptions,
|
|
13
|
+
PROMPT_RUNNER_DESCRIPTION,
|
|
14
|
+
} from '../common/promptRunnerCliOptions';
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* Initializes `coder ping` command for Promptbook CLI utilities
|
|
18
|
+
*
|
|
19
|
+
* Note: `$` is used to indicate that this function is not a pure function - it registers a command in the CLI
|
|
20
|
+
*
|
|
21
|
+
* @private internal function of `promptbookCli`
|
|
22
|
+
*/
|
|
23
|
+
export function $initializeCoderPingCommand(program: Program): $side_effect {
|
|
24
|
+
const command = program.command('ping');
|
|
25
|
+
command.description(
|
|
26
|
+
spaceTrim(`
|
|
27
|
+
Send one tiny dummy prompt to a harness and model to measure and warm them up
|
|
28
|
+
|
|
29
|
+
${PROMPT_RUNNER_DESCRIPTION}
|
|
30
|
+
|
|
31
|
+
Features:
|
|
32
|
+
- Verifies that the selected harness, model, thinking level and authentication really work
|
|
33
|
+
- Reports the answer of the harness, the response time and the reported usage
|
|
34
|
+
- Starts the hourly/weekly quota window before you need it, so it is already refreshing when you do
|
|
35
|
+
- Leaves the project exactly as it was — nothing is read, written, changed or committed
|
|
36
|
+
- Use --no-ui to stream the raw harness output instead of only the compact result
|
|
37
|
+
`),
|
|
38
|
+
);
|
|
39
|
+
|
|
40
|
+
addPromptRunnerSelectionOptions(command);
|
|
41
|
+
addPromptRunnerRuntimeOptions(command);
|
|
42
|
+
|
|
43
|
+
command.action(
|
|
44
|
+
handleActionErrors(async (cliOptions) => {
|
|
45
|
+
const runnerOptions = normalizePromptRunnerSelectionCliOptions(
|
|
46
|
+
cliOptions as PromptRunnerSelectionCliOptions,
|
|
47
|
+
{ isAgentRequired: true },
|
|
48
|
+
);
|
|
49
|
+
|
|
50
|
+
await $ensureHarnessInstallations([runnerOptions.agentName]);
|
|
51
|
+
|
|
52
|
+
// Note: Import the ping dynamically to avoid loading heavy dependencies until needed
|
|
53
|
+
const { pingCoderHarness } = await import('../../../../scripts/run-codex-prompts/ping/pingCoderHarness');
|
|
54
|
+
const { printCoderPingResult } = await import(
|
|
55
|
+
'../../../../scripts/run-codex-prompts/ping/printCoderPingResult'
|
|
56
|
+
);
|
|
57
|
+
|
|
58
|
+
const result = await pingCoderHarness({
|
|
59
|
+
agentName: runnerOptions.agentName,
|
|
60
|
+
model: runnerOptions.model,
|
|
61
|
+
thinkingLevel: runnerOptions.thinkingLevel,
|
|
62
|
+
allowCredits: runnerOptions.allowCredits,
|
|
63
|
+
shouldPrintLiveOutput: runnerOptions.noUi,
|
|
64
|
+
});
|
|
65
|
+
|
|
66
|
+
printCoderPingResult(result);
|
|
67
|
+
}),
|
|
68
|
+
);
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
// Note: [🟡] Code for CLI command [ping](src/cli/cli-commands/coder/ping.ts) should never be published outside of `@promptbook/cli`
|
|
72
|
+
// 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,
|
|
@@ -4,6 +4,12 @@ import type {
|
|
|
4
4
|
} from 'commander';
|
|
5
5
|
import { spaceTrim } from 'spacetrim';
|
|
6
6
|
import type { $side_effect } from '../../../utils/organization/$side_effect';
|
|
7
|
+
import type { CoderGitSyncCliOptions } from '../common/coderGitSyncCliOptions';
|
|
8
|
+
import {
|
|
9
|
+
addCoderGitSyncOptions,
|
|
10
|
+
CODER_GIT_SYNC_DESCRIPTION,
|
|
11
|
+
normalizeCoderGitSyncCliOptions,
|
|
12
|
+
} from '../common/coderGitSyncCliOptions';
|
|
7
13
|
import { handleActionErrors } from '../common/handleActionErrors';
|
|
8
14
|
|
|
9
15
|
/**
|
|
@@ -16,17 +22,23 @@ import { handleActionErrors } from '../common/handleActionErrors';
|
|
|
16
22
|
export function $initializeCoderVerifyCommand(program: Program): $side_effect {
|
|
17
23
|
const command = program.command('verify');
|
|
18
24
|
command.description(
|
|
19
|
-
spaceTrim(
|
|
20
|
-
|
|
25
|
+
spaceTrim(
|
|
26
|
+
(block) => `
|
|
27
|
+
Interactive verification helper for completed prompts
|
|
21
28
|
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
29
|
+
Features:
|
|
30
|
+
- Displays list of prompt files with status counts
|
|
31
|
+
- Guides through verification of completed prompts marked [x]
|
|
32
|
+
- Archives verified prompt files to prompts/done/ directory
|
|
33
|
+
- Auto-appends repair prompts for incomplete work
|
|
34
|
+
- Processes files with all-done prompts first
|
|
35
|
+
- Supports ignoring matching prompt candidates for one verification run
|
|
36
|
+
|
|
37
|
+
${block(CODER_GIT_SYNC_DESCRIPTION)}
|
|
38
|
+
|
|
39
|
+
Note: The git synchronization is applied around each single verification, not once per run.
|
|
40
|
+
`,
|
|
41
|
+
),
|
|
30
42
|
);
|
|
31
43
|
|
|
32
44
|
command.option('--reverse', 'Process prompt files in reverse order', false);
|
|
@@ -36,19 +48,22 @@ export function $initializeCoderVerifyCommand(program: Program): $side_effect {
|
|
|
36
48
|
collectStringOption,
|
|
37
49
|
[],
|
|
38
50
|
);
|
|
51
|
+
addCoderGitSyncOptions(command);
|
|
39
52
|
|
|
40
53
|
command.action(
|
|
41
54
|
handleActionErrors(async (cliOptions) => {
|
|
42
55
|
const { reverse, ignore } = cliOptions as {
|
|
43
56
|
readonly reverse: boolean;
|
|
44
57
|
readonly ignore: ReadonlyArray<string>;
|
|
45
|
-
};
|
|
58
|
+
} & CoderGitSyncCliOptions;
|
|
59
|
+
|
|
60
|
+
const gitSync = normalizeCoderGitSyncCliOptions(cliOptions as CoderGitSyncCliOptions);
|
|
46
61
|
|
|
47
62
|
// Note: Import the main function dynamically to avoid loading heavy dependencies until needed
|
|
48
63
|
const { verifyPrompts } = await import('../../../../scripts/verify-prompts/verify-prompts');
|
|
49
64
|
|
|
50
65
|
try {
|
|
51
|
-
await verifyPrompts({ reverse, ignore });
|
|
66
|
+
await verifyPrompts({ reverse, ignore, gitSync });
|
|
52
67
|
} catch (error) {
|
|
53
68
|
console.error(colors.bgRed('Prompt verification failed:'), error);
|
|
54
69
|
return process.exit(1);
|
|
@@ -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';
|
|
@@ -23,6 +24,7 @@ import { $initializeCoderVerifyCommand } from './coder/verify';
|
|
|
23
24
|
* - generate-boilerplates: Generate prompt boilerplate files
|
|
24
25
|
* - find-refactor-candidates: Find files that need refactoring
|
|
25
26
|
* - run: Run coding prompts with AI agents
|
|
27
|
+
* - ping: Test one harness and model with a tiny dummy prompt
|
|
26
28
|
* - verify: Verify completed prompts
|
|
27
29
|
* - find-fresh-emoji-tags: Find unused emoji tags
|
|
28
30
|
*
|
|
@@ -43,6 +45,7 @@ export function $initializeCoderCommand(program: Program): $side_effect {
|
|
|
43
45
|
- find-refactor-candidates: Find files that need refactoring
|
|
44
46
|
- find-unwritten: List prompt sections that still need to be authored
|
|
45
47
|
- run: Run coding prompts with AI agents
|
|
48
|
+
- ping: Test the connection, response time and quota of one harness and model
|
|
46
49
|
- server: Start a long-running coder server with a kanban web UI
|
|
47
50
|
- verify: Verify completed prompts
|
|
48
51
|
- find-fresh-emoji-tags: Find unused emoji tags
|
|
@@ -56,6 +59,7 @@ export function $initializeCoderCommand(program: Program): $side_effect {
|
|
|
56
59
|
$initializeCoderFindRefactorCandidatesCommand(coderCommand);
|
|
57
60
|
$initializeCoderFindUnwrittenCommand(coderCommand);
|
|
58
61
|
$initializeCoderRunCommand(coderCommand);
|
|
62
|
+
$initializeCoderPingCommand(coderCommand);
|
|
59
63
|
$initializeCoderServerCommand(coderCommand);
|
|
60
64
|
$initializeCoderVerifyCommand(coderCommand);
|
|
61
65
|
$initializeCoderFindFreshEmojiTagCommand(coderCommand);
|
|
@@ -0,0 +1,78 @@
|
|
|
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 { CoderGitSyncOptions } from '../../../../scripts/run-codex-prompts/git/coderGitSync';
|
|
6
|
+
import { NotAllowed } from '../../../errors/NotAllowed';
|
|
7
|
+
|
|
8
|
+
export type { CoderGitSyncOptions };
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Commander option bag for the shared `ptbk coder` git synchronization flags.
|
|
12
|
+
*
|
|
13
|
+
* @private internal utility of `promptbookCli`
|
|
14
|
+
*/
|
|
15
|
+
export type CoderGitSyncCliOptions = {
|
|
16
|
+
readonly commit: boolean;
|
|
17
|
+
readonly autoPush: boolean;
|
|
18
|
+
readonly autoPull: boolean;
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Description block shared by the `ptbk coder` commands which can synchronize their changes with git.
|
|
23
|
+
*
|
|
24
|
+
* @private internal utility of `promptbookCli`
|
|
25
|
+
*/
|
|
26
|
+
export const CODER_GIT_SYNC_DESCRIPTION = spaceTrim(`
|
|
27
|
+
Git synchronization:
|
|
28
|
+
- --auto-pull pulls the latest changes before this command changes anything
|
|
29
|
+
- --commit commits the changes made by this command
|
|
30
|
+
- --auto-push pushes the created commit to the remote repository
|
|
31
|
+
`);
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* Registers the shared `--commit`, `--auto-push` and `--auto-pull` flags on a `ptbk coder` command.
|
|
35
|
+
*
|
|
36
|
+
* Note: Unlike `ptbk coder run`, which commits by default and opts out through `--no-commit`,
|
|
37
|
+
* these commands never touch git unless the flags are used explicitly.
|
|
38
|
+
*
|
|
39
|
+
* @private internal utility of `promptbookCli`
|
|
40
|
+
*/
|
|
41
|
+
export function addCoderGitSyncOptions(command: Program): void {
|
|
42
|
+
command.option('--commit', 'Commit the changes made by this command with the coding-agent git identity', false);
|
|
43
|
+
command.option('--auto-push', 'Automatically git push the created commit, requires --commit', false);
|
|
44
|
+
command.option(
|
|
45
|
+
'--auto-pull',
|
|
46
|
+
'Automatically git pull the latest changes before this command changes anything',
|
|
47
|
+
false,
|
|
48
|
+
);
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* Converts the Commander git synchronization flags into normalized git synchronization options.
|
|
53
|
+
*
|
|
54
|
+
* @private internal utility of `promptbookCli`
|
|
55
|
+
*/
|
|
56
|
+
export function normalizeCoderGitSyncCliOptions(cliOptions: CoderGitSyncCliOptions): CoderGitSyncOptions {
|
|
57
|
+
if (cliOptions.autoPush && !cliOptions.commit) {
|
|
58
|
+
throw new NotAllowed(
|
|
59
|
+
spaceTrim(`
|
|
60
|
+
Flag \`--auto-push\` can be used only together with \`--commit\`.
|
|
61
|
+
|
|
62
|
+
**There is nothing to push when the changes are not committed.**
|
|
63
|
+
|
|
64
|
+
Actionable hint:
|
|
65
|
+
- Add \`--commit\`, for example \`ptbk coder init --commit --auto-push\`.
|
|
66
|
+
`),
|
|
67
|
+
);
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
return {
|
|
71
|
+
isCommitEnabled: cliOptions.commit,
|
|
72
|
+
isAutoPushEnabled: cliOptions.autoPush,
|
|
73
|
+
isAutoPullEnabled: cliOptions.autoPull,
|
|
74
|
+
};
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
// Note: [🟡] Code for CLI git synchronization options [coderGitSyncCliOptions](src/cli/cli-commands/common/coderGitSyncCliOptions.ts) should never be published outside of `@promptbook/cli`
|
|
78
|
+
// Note: [💞] Ignore a discrepancy between file name and exported helper names
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import colors from 'colors';
|
|
2
2
|
import { writeFile } from 'fs/promises';
|
|
3
3
|
import { join } from 'path';
|
|
4
|
-
import prompts from 'prompts';
|
|
5
4
|
import { spaceTrim } from 'spacetrim';
|
|
6
5
|
import { getAllCommitmentsToolFunctionsForNode } from '../../../commitments/_common/getAllCommitmentsToolFunctionsForNode';
|
|
7
6
|
import { DEFAULT_MAX_EXECUTION_ATTEMPTS } from '../../../config';
|
|
@@ -24,6 +23,7 @@ import { JavascriptExecutionTools } from '../../../scripting/javascript/Javascri
|
|
|
24
23
|
import { isFileExisting } from '../../../utils/files/isFileExisting';
|
|
25
24
|
import { $getCompiledBook } from '../../../wizard/$getCompiledBook';
|
|
26
25
|
import { $provideLlmToolsForCli } from '../../common/$provideLlmToolsForCli';
|
|
26
|
+
import { loadPromptsModule } from '../../common/loadPromptsModule';
|
|
27
27
|
import type { RunCommandCliOptions } from './runCommandAction';
|
|
28
28
|
|
|
29
29
|
/**
|
|
@@ -156,6 +156,7 @@ async function resolveRunPipelineSource(pipelineSource?: string): Promise<string
|
|
|
156
156
|
return pipelineSource;
|
|
157
157
|
}
|
|
158
158
|
|
|
159
|
+
const { default: prompts } = await loadPromptsModule();
|
|
159
160
|
const response = await prompts({
|
|
160
161
|
type: 'text',
|
|
161
162
|
name: 'pipelineSource',
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import colors from 'colors';
|
|
2
|
-
import prompts from 'prompts';
|
|
3
2
|
import { spaceTrim } from 'spacetrim';
|
|
4
3
|
import type { PipelineJson } from '../../../pipeline/PipelineJson/PipelineJson';
|
|
5
4
|
import type { string_parameter_name, string_parameter_value } from '../../../types/string_name';
|
|
6
5
|
import { countLines } from '../../../utils/expectation-counters/countLines';
|
|
7
6
|
import type { TODO_any } from '../../../utils/organization/TODO_any';
|
|
7
|
+
import { loadPromptsModule } from '../../common/loadPromptsModule';
|
|
8
8
|
|
|
9
9
|
/**
|
|
10
10
|
* Resolves all missing input parameters while keeping the current interactive and non-interactive behavior.
|
|
@@ -24,6 +24,7 @@ export async function resolveRunInputParameters(options: {
|
|
|
24
24
|
return process.exit(1);
|
|
25
25
|
}
|
|
26
26
|
|
|
27
|
+
const { default: prompts } = await loadPromptsModule();
|
|
27
28
|
const response = await prompts(questions as TODO_any);
|
|
28
29
|
// <- TODO: [🧠][🍼] Change behavior according to the formfactor
|
|
29
30
|
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import colors from 'colors';
|
|
2
|
-
import prompts from 'prompts';
|
|
3
2
|
import { spaceTrim } from 'spacetrim';
|
|
4
3
|
import { forTime } from 'waitasecond';
|
|
5
4
|
import { assertsError } from '../../errors/assertsError';
|
|
6
5
|
import type { PipelineExecutor } from '../../execution/PipelineExecutor';
|
|
7
6
|
import type { PipelineJson } from '../../pipeline/PipelineJson/PipelineJson';
|
|
8
7
|
import { just } from '../../utils/organization/just';
|
|
8
|
+
import { loadPromptsModule } from '../common/loadPromptsModule';
|
|
9
9
|
|
|
10
10
|
/**
|
|
11
11
|
* Options for running the interactive chatbot
|
|
@@ -90,6 +90,7 @@ export async function runInteractiveChatbot(options: RunInteractiveChatbotOption
|
|
|
90
90
|
console.info(colors.gray(`---`));
|
|
91
91
|
}
|
|
92
92
|
|
|
93
|
+
const { default: prompts } = await loadPromptsModule();
|
|
93
94
|
const response = await prompts({
|
|
94
95
|
type: 'text',
|
|
95
96
|
name: 'userMessage',
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import colors from 'colors';
|
|
2
|
-
import prompts from 'prompts';
|
|
3
2
|
import { spaceTrim } from 'spacetrim';
|
|
4
3
|
import { CLI_APP_ID } from '../../config';
|
|
5
4
|
import { UnexpectedError } from '../../errors/UnexpectedError';
|
|
@@ -14,6 +13,7 @@ import type { really_unknown } from '../../utils/organization/really_unknown';
|
|
|
14
13
|
import { TODO_USE } from '../../utils/organization/TODO_USE';
|
|
15
14
|
import { isValidEmail } from '../../utils/validators/email/isValidEmail';
|
|
16
15
|
import { isValidUrl } from '../../utils/validators/url/isValidUrl';
|
|
16
|
+
import { loadPromptsModule } from './loadPromptsModule';
|
|
17
17
|
|
|
18
18
|
/**
|
|
19
19
|
* Options for provide Llm tools for Cli.
|
|
@@ -110,6 +110,7 @@ export async function $provideLlmToolsForCli(options: ProvideLlmToolsForCliOptio
|
|
|
110
110
|
),
|
|
111
111
|
);
|
|
112
112
|
|
|
113
|
+
const { default: prompts } = await loadPromptsModule();
|
|
113
114
|
const { username, password } = await prompts([
|
|
114
115
|
{
|
|
115
116
|
type: 'text',
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { createLazyModuleLoader } from '../../utils/misc/createLazyModuleLoader';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Loads the interactive terminal prompt library (`prompts`) on demand
|
|
5
|
+
*
|
|
6
|
+
* Note: [🐌] Loaded lazily to keep the startup of the `ptbk` CLI utility fast - most commands never ask the user
|
|
7
|
+
* anything interactively
|
|
8
|
+
*
|
|
9
|
+
* @private internal utility of Promptbook CLI
|
|
10
|
+
*/
|
|
11
|
+
export const loadPromptsModule = createLazyModuleLoader(() => import('prompts'));
|
|
12
|
+
|
|
13
|
+
// Note: [🟡] Code for CLI prompt loading [loadPromptsModule](src/cli/common/loadPromptsModule.ts) should never be published outside of `@promptbook/cli`
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import JSZip from 'jszip';
|
|
2
1
|
import { UnexpectedError } from '../../errors/UnexpectedError';
|
|
3
2
|
import type { FilesystemTools } from '../../execution/FilesystemTools';
|
|
4
3
|
import { jsonParse } from '../../formats/json/utils/jsonParse';
|
|
5
4
|
import type { PipelineJson } from '../../pipeline/PipelineJson/PipelineJson';
|
|
6
5
|
import type { string_filename } from '../../types/string_filename';
|
|
7
6
|
import { validatePipeline } from '../validation/validatePipeline';
|
|
7
|
+
import { loadJsZipModule } from './loadJsZipModule';
|
|
8
8
|
|
|
9
9
|
/**
|
|
10
10
|
* Loads the books from the archive file with `.bookc` extension
|
|
@@ -24,6 +24,7 @@ export async function loadArchive(
|
|
|
24
24
|
}
|
|
25
25
|
|
|
26
26
|
const data = await fs.readFile(filePath);
|
|
27
|
+
const { default: JSZip } = await loadJsZipModule();
|
|
27
28
|
const archive = await JSZip.loadAsync(data);
|
|
28
29
|
|
|
29
30
|
const indexFile = archive.file('index.book.json');
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { createLazyModuleLoader } from '../../utils/misc/createLazyModuleLoader';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Loads the ZIP archive library (`jszip`) on demand
|
|
5
|
+
*
|
|
6
|
+
* Note: [🐌] Loaded lazily to keep the startup of the `ptbk` CLI utility fast
|
|
7
|
+
*
|
|
8
|
+
* @private internal utility of `loadArchive` and `saveArchive`
|
|
9
|
+
*/
|
|
10
|
+
export const loadJsZipModule = createLazyModuleLoader(() => import('jszip'));
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import JSZip from 'jszip';
|
|
2
1
|
import { UnexpectedError } from '../../errors/UnexpectedError';
|
|
3
2
|
import type { FilesystemTools } from '../../execution/FilesystemTools';
|
|
4
3
|
import type { PipelineJson } from '../../pipeline/PipelineJson/PipelineJson';
|
|
5
4
|
import type { string_filename } from '../../types/string_filename';
|
|
6
5
|
import { stringifyPipelineJson } from '../../utils/editable/utils/stringifyPipelineJson';
|
|
7
6
|
import { validatePipeline } from '../validation/validatePipeline';
|
|
7
|
+
import { loadJsZipModule } from './loadJsZipModule';
|
|
8
8
|
|
|
9
9
|
/**
|
|
10
10
|
* Saves the given books into an archive file with `.bookc` extension
|
|
@@ -29,6 +29,7 @@ export async function saveArchive(
|
|
|
29
29
|
validatePipeline(pipelineJson);
|
|
30
30
|
}
|
|
31
31
|
|
|
32
|
+
const { default: JSZip } = await loadJsZipModule();
|
|
32
33
|
const archive = new JSZip();
|
|
33
34
|
|
|
34
35
|
const collectionJsonString = stringifyPipelineJson(collectionJson);
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { ClientOptions } from '@anthropic-ai/sdk';
|
|
2
|
-
import Anthropic from '@anthropic-ai/sdk';
|
|
2
|
+
import type Anthropic from '@anthropic-ai/sdk';
|
|
3
3
|
import type { MessageCreateParamsNonStreaming } from '@anthropic-ai/sdk/resources';
|
|
4
4
|
import Bottleneck from 'bottleneck';
|
|
5
5
|
import colors from 'colors'; // <- TODO: [🔶] Make system to put color and style to both node and browser
|
|
@@ -19,6 +19,7 @@ import type { string_name } from '../../types/string_name';
|
|
|
19
19
|
import type { string_title } from '../../types/string_title';
|
|
20
20
|
import type { string_date_iso8601 } from '../../types/string_token';
|
|
21
21
|
import { $getCurrentDate } from '../../utils/misc/$getCurrentDate';
|
|
22
|
+
import { createLazyModuleLoader } from '../../utils/misc/createLazyModuleLoader';
|
|
22
23
|
import type { chococake } from '../../utils/organization/really_any';
|
|
23
24
|
import type { TODO_any } from '../../utils/organization/TODO_any';
|
|
24
25
|
import { templateParameters } from '../../utils/parameters/templateParameters';
|
|
@@ -36,6 +37,15 @@ const ANTHROPIC_PROVIDER_PROFILE: ChatParticipant = {
|
|
|
36
37
|
color: '#d97706',
|
|
37
38
|
} as const;
|
|
38
39
|
|
|
40
|
+
/**
|
|
41
|
+
* Loads the Anthropic Claude SDK (`@anthropic-ai/sdk`) on demand
|
|
42
|
+
*
|
|
43
|
+
* Note: [🐌] Loaded lazily to keep the startup of the `ptbk` CLI utility fast
|
|
44
|
+
*
|
|
45
|
+
* @private internal utility of `AnthropicClaudeExecutionTools`
|
|
46
|
+
*/
|
|
47
|
+
const loadAnthropicClaudeModule = createLazyModuleLoader(() => import('@anthropic-ai/sdk'));
|
|
48
|
+
|
|
39
49
|
/**
|
|
40
50
|
* Execution Tools for calling Anthropic Claude API.
|
|
41
51
|
*
|
|
@@ -80,6 +90,8 @@ export class AnthropicClaudeExecutionTools implements LlmExecutionTools /* <- TO
|
|
|
80
90
|
const anthropicOptions: ClientOptions = { ...this.options };
|
|
81
91
|
delete (anthropicOptions as chococake).isVerbose;
|
|
82
92
|
delete (anthropicOptions as chococake).isProxied;
|
|
93
|
+
|
|
94
|
+
const { Anthropic } = await loadAnthropicClaudeModule();
|
|
83
95
|
this.client = new Anthropic(anthropicOptions);
|
|
84
96
|
}
|
|
85
97
|
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type { OpenAIClient } from '@azure/openai';
|
|
2
2
|
import Bottleneck from 'bottleneck';
|
|
3
3
|
import colors from 'colors'; // <- TODO: [🔶] Make system to put color and style to both node and browser
|
|
4
4
|
import type { ChatParticipant } from '../../book-components/Chat/types/ChatParticipant';
|
|
@@ -18,6 +18,7 @@ import type { string_completion_prompt } from '../../types/string_prompt';
|
|
|
18
18
|
import type { string_title } from '../../types/string_title';
|
|
19
19
|
import type { string_date_iso8601 } from '../../types/string_token';
|
|
20
20
|
import { $getCurrentDate } from '../../utils/misc/$getCurrentDate';
|
|
21
|
+
import { createLazyModuleLoader } from '../../utils/misc/createLazyModuleLoader';
|
|
21
22
|
import { keepTypeImported } from '../../utils/organization/keepTypeImported';
|
|
22
23
|
import { templateParameters } from '../../utils/parameters/templateParameters';
|
|
23
24
|
import { exportJson } from '../../utils/serialization/exportJson';
|
|
@@ -35,6 +36,15 @@ const AZURE_OPENAI_PROVIDER_PROFILE: ChatParticipant = {
|
|
|
35
36
|
|
|
36
37
|
keepTypeImported<Usage>();
|
|
37
38
|
|
|
39
|
+
/**
|
|
40
|
+
* Loads the Azure OpenAI SDK (`@azure/openai`) on demand
|
|
41
|
+
*
|
|
42
|
+
* Note: [🐌] Loaded lazily to keep the startup of the `ptbk` CLI utility fast
|
|
43
|
+
*
|
|
44
|
+
* @private internal utility of `AzureOpenAiExecutionTools`
|
|
45
|
+
*/
|
|
46
|
+
const loadAzureOpenAiModule = createLazyModuleLoader(() => import('@azure/openai'));
|
|
47
|
+
|
|
38
48
|
/**
|
|
39
49
|
* Execution Tools for calling Azure OpenAI API.
|
|
40
50
|
*
|
|
@@ -77,6 +87,8 @@ export class AzureOpenAiExecutionTools implements LlmExecutionTools /* <- TODO:
|
|
|
77
87
|
|
|
78
88
|
public async getClient(): Promise<OpenAIClient> {
|
|
79
89
|
if (this.client === null) {
|
|
90
|
+
const { AzureKeyCredential, OpenAIClient } = await loadAzureOpenAiModule();
|
|
91
|
+
|
|
80
92
|
this.client = new OpenAIClient(
|
|
81
93
|
`https://${this.options.resourceName}.openai.azure.com/`,
|
|
82
94
|
new AzureKeyCredential(this.options.apiKey),
|