@promptbook/cli 0.112.0-123 → 0.112.0-124
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 +14 -14
- package/agents/default/developer.book +23 -0
- package/apps/agents-server/src/app/api/scrape/route.ts +18 -0
- package/apps/agents-server/src/tools/createAgentProgressTools.ts +6 -4
- package/apps/agents-server/src/utils/assertSafeUrl.ts +136 -0
- package/apps/agents-server/src/utils/authenticateUser.ts +2 -1
- package/apps/agents-server/src/utils/getCurrentUser.ts +2 -1
- package/apps/agents-server/src/utils/isAdminPasswordEqual.ts +28 -0
- package/apps/agents-server/src/utils/isUserGlobalAdmin.ts +3 -1
- package/apps/agents-server/src/utils/userChat/createRunUserChatJobPersistenceController.ts +21 -0
- package/apps/agents-server/src/utils/userChat/retryUserChatJob.ts +4 -0
- package/apps/agents-server/src/utils/userChat/userChatMessageLifecycle.ts +2 -0
- package/apps/agents-server/src/utils/userChat/userChatProgressCard.ts +288 -0
- package/esm/index.es.js +78 -7
- package/esm/index.es.js.map +1 -1
- package/esm/src/cli/cli-commands/coder/ensureCoderDeveloperAgentFile.d.ts +25 -0
- package/esm/src/cli/cli-commands/coder/initializeCoderProjectConfiguration.d.ts +2 -0
- package/esm/src/version.d.ts +1 -1
- package/package.json +1 -1
- package/src/cli/cli-commands/coder/ensureCoderDeveloperAgentFile.ts +79 -0
- package/src/cli/cli-commands/coder/getDefaultCoderPackageJsonScripts.ts +1 -1
- package/src/cli/cli-commands/coder/init.ts +2 -0
- package/src/cli/cli-commands/coder/initializeCoderProjectConfiguration.ts +10 -0
- package/src/cli/cli-commands/coder/printInitializationSummary.ts +3 -0
- package/src/other/templates/getTemplatesPipelineCollection.ts +707 -876
- package/src/version.ts +2 -2
- package/src/versions.txt +1 -0
- package/umd/index.umd.js +77 -6
- package/umd/index.umd.js.map +1 -1
- package/umd/src/cli/cli-commands/coder/ensureCoderDeveloperAgentFile.d.ts +25 -0
- package/umd/src/cli/cli-commands/coder/initializeCoderProjectConfiguration.d.ts +2 -0
- package/umd/src/version.d.ts +1 -1
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import type { InitializationStatus } from './boilerplateTemplates';
|
|
2
|
+
/**
|
|
3
|
+
* Relative directory path for agents initialized by `ptbk coder init`.
|
|
4
|
+
*
|
|
5
|
+
* @private internal utility of `coder init` command
|
|
6
|
+
*/
|
|
7
|
+
export declare const CODER_AGENTS_DIRECTORY_PATH = "agents";
|
|
8
|
+
/**
|
|
9
|
+
* Relative file path to the default developer agent initialized by `ptbk coder init`.
|
|
10
|
+
*
|
|
11
|
+
* @private internal utility of `coder init` command
|
|
12
|
+
*/
|
|
13
|
+
export declare const CODER_DEVELOPER_AGENT_FILE_PATH = "agents/developer.book";
|
|
14
|
+
/**
|
|
15
|
+
* Source file path of the bundled developer agent inside the Promptbook repository.
|
|
16
|
+
*
|
|
17
|
+
* @private internal utility of `coder init` command
|
|
18
|
+
*/
|
|
19
|
+
export declare const DEFAULT_CODER_DEVELOPER_AGENT_SOURCE_FILE_PATH = "agents/default/developer.book";
|
|
20
|
+
/**
|
|
21
|
+
* Ensures the default developer agent exists in the initialized project.
|
|
22
|
+
*
|
|
23
|
+
* @private function of `initializeCoderProjectConfiguration`
|
|
24
|
+
*/
|
|
25
|
+
export declare function ensureCoderDeveloperAgentFile(projectPath: string): Promise<InitializationStatus>;
|
|
@@ -9,6 +9,8 @@ export type CoderInitializationSummary = {
|
|
|
9
9
|
readonly promptsDoneDirectoryStatus: InitializationStatus;
|
|
10
10
|
readonly promptsTemplatesDirectoryStatus: InitializationStatus;
|
|
11
11
|
readonly promptTemplateFileStatuses: ReadonlyArray<EnsuredCoderPromptTemplateFile>;
|
|
12
|
+
readonly agentsDirectoryStatus: InitializationStatus;
|
|
13
|
+
readonly developerAgentFileStatus: InitializationStatus;
|
|
12
14
|
readonly agentsFileStatus: InitializationStatus;
|
|
13
15
|
readonly agentCodingFileStatus: InitializationStatus;
|
|
14
16
|
readonly envFileStatus: InitializationStatus;
|
package/esm/src/version.d.ts
CHANGED
|
@@ -15,7 +15,7 @@ export declare const BOOK_LANGUAGE_VERSION: string_semantic_version;
|
|
|
15
15
|
export declare const PROMPTBOOK_ENGINE_VERSION: string_promptbook_version;
|
|
16
16
|
/**
|
|
17
17
|
* Represents the version string of the Promptbook engine.
|
|
18
|
-
* It follows semantic versioning (e.g., `0.112.0-
|
|
18
|
+
* It follows semantic versioning (e.g., `0.112.0-123`).
|
|
19
19
|
*
|
|
20
20
|
* @generated
|
|
21
21
|
*/
|
package/package.json
CHANGED
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import { copyFile, stat } from 'fs/promises';
|
|
2
|
+
import { join } from 'path';
|
|
3
|
+
import { spaceTrim } from 'spacetrim';
|
|
4
|
+
import { NotAllowed } from '../../../errors/NotAllowed';
|
|
5
|
+
import type { InitializationStatus } from './boilerplateTemplates';
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Relative directory path for agents initialized by `ptbk coder init`.
|
|
9
|
+
*
|
|
10
|
+
* @private internal utility of `coder init` command
|
|
11
|
+
*/
|
|
12
|
+
export const CODER_AGENTS_DIRECTORY_PATH = 'agents';
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Relative file path to the default developer agent initialized by `ptbk coder init`.
|
|
16
|
+
*
|
|
17
|
+
* @private internal utility of `coder init` command
|
|
18
|
+
*/
|
|
19
|
+
export const CODER_DEVELOPER_AGENT_FILE_PATH = 'agents/developer.book';
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Source file path of the bundled developer agent inside the Promptbook repository.
|
|
23
|
+
*
|
|
24
|
+
* @private internal utility of `coder init` command
|
|
25
|
+
*/
|
|
26
|
+
export const DEFAULT_CODER_DEVELOPER_AGENT_SOURCE_FILE_PATH = 'agents/default/developer.book';
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Ensures the default developer agent exists in the initialized project.
|
|
30
|
+
*
|
|
31
|
+
* @private function of `initializeCoderProjectConfiguration`
|
|
32
|
+
*/
|
|
33
|
+
export async function ensureCoderDeveloperAgentFile(projectPath: string): Promise<InitializationStatus> {
|
|
34
|
+
const absoluteFilePath = join(projectPath, CODER_DEVELOPER_AGENT_FILE_PATH);
|
|
35
|
+
if (await isExistingFile(absoluteFilePath)) {
|
|
36
|
+
return 'unchanged';
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
await copyFile(await resolveDefaultCoderDeveloperAgentFilePath(), absoluteFilePath);
|
|
40
|
+
return 'created';
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* Resolves the bundled developer agent from a source checkout or generated CLI package.
|
|
45
|
+
*/
|
|
46
|
+
async function resolveDefaultCoderDeveloperAgentFilePath(): Promise<string> {
|
|
47
|
+
const candidates = [
|
|
48
|
+
join(__dirname, '..', DEFAULT_CODER_DEVELOPER_AGENT_SOURCE_FILE_PATH),
|
|
49
|
+
join(__dirname, '..', '..', '..', '..', DEFAULT_CODER_DEVELOPER_AGENT_SOURCE_FILE_PATH),
|
|
50
|
+
];
|
|
51
|
+
|
|
52
|
+
for (const candidate of candidates) {
|
|
53
|
+
if (await isExistingFile(candidate)) {
|
|
54
|
+
return candidate;
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
throw new NotAllowed(
|
|
59
|
+
spaceTrim(`
|
|
60
|
+
Cannot find the bundled Promptbook developer agent.
|
|
61
|
+
|
|
62
|
+
Checked:
|
|
63
|
+
${candidates.map((candidate) => `- \`${candidate}\``).join('\n')}
|
|
64
|
+
`),
|
|
65
|
+
);
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
/**
|
|
69
|
+
* Checks whether a path exists and is a file.
|
|
70
|
+
*/
|
|
71
|
+
async function isExistingFile(path: string): Promise<boolean> {
|
|
72
|
+
try {
|
|
73
|
+
return (await stat(path)).isFile();
|
|
74
|
+
} catch {
|
|
75
|
+
return false;
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
// Note: [🟡] Code for coder init developer agent bootstrapping [ensureCoderDeveloperAgentFile](src/cli/cli-commands/coder/ensureCoderDeveloperAgentFile.ts) should never be published outside of `@promptbook/cli`
|
|
@@ -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 --harness openai-codex --model gpt-5.4 --thinking-level xhigh --context AGENTS.md --no-wait',
|
|
7
|
+
'ptbk coder run --harness openai-codex --model gpt-5.4 --thinking-level xhigh --agent agents/developer.book --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>>;
|
|
@@ -7,6 +7,7 @@ import { handleActionErrors } from '../common/handleActionErrors';
|
|
|
7
7
|
import { AGENT_CODING_FILE_PATH } from './agentCodingFile';
|
|
8
8
|
import { AGENTS_FILE_PATH } from './agentsFile';
|
|
9
9
|
import { getDefaultCoderProjectPromptTemplateDefinitions } from './boilerplateTemplates';
|
|
10
|
+
import { CODER_DEVELOPER_AGENT_FILE_PATH } from './ensureCoderDeveloperAgentFile';
|
|
10
11
|
import { formatDisplayPath } from './formatDisplayPath';
|
|
11
12
|
import { generatePromptBoilerplate } from './generate-boilerplates';
|
|
12
13
|
import { initializeCoderProjectConfiguration } from './initializeCoderProjectConfiguration';
|
|
@@ -34,6 +35,7 @@ export function $initializeCoderInitCommand(program: Program): $side_effect {
|
|
|
34
35
|
- prompts/
|
|
35
36
|
- prompts/done/
|
|
36
37
|
${listDefaultCoderProjectPromptTemplateDisplayPaths()}
|
|
38
|
+
- ${CODER_DEVELOPER_AGENT_FILE_PATH}
|
|
37
39
|
- ${AGENTS_FILE_PATH}
|
|
38
40
|
- ${AGENT_CODING_FILE_PATH}
|
|
39
41
|
- .gitignore
|
|
@@ -8,6 +8,10 @@ import {
|
|
|
8
8
|
PROMPTS_TEMPLATES_DIRECTORY_PATH,
|
|
9
9
|
} from './boilerplateTemplates';
|
|
10
10
|
import { ensureCoderEnvFile } from './ensureCoderEnvFile';
|
|
11
|
+
import {
|
|
12
|
+
CODER_AGENTS_DIRECTORY_PATH,
|
|
13
|
+
ensureCoderDeveloperAgentFile,
|
|
14
|
+
} from './ensureCoderDeveloperAgentFile';
|
|
11
15
|
import { ensureCoderGitignoreFile } from './ensureCoderGitignoreFile';
|
|
12
16
|
import { ensureCoderMarkdownFile } from './ensureCoderMarkdownFile';
|
|
13
17
|
import { ensureCoderPackageJsonFile } from './ensureCoderPackageJsonFile';
|
|
@@ -25,6 +29,8 @@ export type CoderInitializationSummary = {
|
|
|
25
29
|
readonly promptsDoneDirectoryStatus: InitializationStatus;
|
|
26
30
|
readonly promptsTemplatesDirectoryStatus: InitializationStatus;
|
|
27
31
|
readonly promptTemplateFileStatuses: ReadonlyArray<EnsuredCoderPromptTemplateFile>;
|
|
32
|
+
readonly agentsDirectoryStatus: InitializationStatus;
|
|
33
|
+
readonly developerAgentFileStatus: InitializationStatus;
|
|
28
34
|
readonly agentsFileStatus: InitializationStatus;
|
|
29
35
|
readonly agentCodingFileStatus: InitializationStatus;
|
|
30
36
|
readonly envFileStatus: InitializationStatus;
|
|
@@ -44,6 +50,8 @@ export async function initializeCoderProjectConfiguration(projectPath: string):
|
|
|
44
50
|
const promptsDoneDirectoryStatus = await ensureDirectory(projectPath, PROMPTS_DONE_DIRECTORY_PATH);
|
|
45
51
|
const promptsTemplatesDirectoryStatus = await ensureDirectory(projectPath, PROMPTS_TEMPLATES_DIRECTORY_PATH);
|
|
46
52
|
const promptTemplateFileStatuses = await ensureDefaultCoderPromptTemplateFiles(projectPath);
|
|
53
|
+
const agentsDirectoryStatus = await ensureDirectory(projectPath, CODER_AGENTS_DIRECTORY_PATH);
|
|
54
|
+
const developerAgentFileStatus = await ensureCoderDeveloperAgentFile(projectPath);
|
|
47
55
|
const agentsFileStatus = await ensureCoderMarkdownFile(
|
|
48
56
|
projectPath,
|
|
49
57
|
AGENTS_FILE_PATH,
|
|
@@ -66,6 +74,8 @@ export async function initializeCoderProjectConfiguration(projectPath: string):
|
|
|
66
74
|
promptsDoneDirectoryStatus,
|
|
67
75
|
promptsTemplatesDirectoryStatus,
|
|
68
76
|
promptTemplateFileStatuses,
|
|
77
|
+
agentsDirectoryStatus,
|
|
78
|
+
developerAgentFileStatus,
|
|
69
79
|
agentsFileStatus,
|
|
70
80
|
agentCodingFileStatus,
|
|
71
81
|
envFileStatus,
|
|
@@ -2,6 +2,7 @@ import colors from 'colors';
|
|
|
2
2
|
import { AGENT_CODING_FILE_PATH } from './agentCodingFile';
|
|
3
3
|
import { AGENTS_FILE_PATH } from './agentsFile';
|
|
4
4
|
import type { InitializationStatus } from './boilerplateTemplates';
|
|
5
|
+
import { CODER_DEVELOPER_AGENT_FILE_PATH } from './ensureCoderDeveloperAgentFile';
|
|
5
6
|
import { formatDisplayPath } from './formatDisplayPath';
|
|
6
7
|
import type { CoderInitializationSummary } from './initializeCoderProjectConfiguration';
|
|
7
8
|
|
|
@@ -23,6 +24,8 @@ export function printInitializationSummary(summary: CoderInitializationSummary):
|
|
|
23
24
|
);
|
|
24
25
|
}
|
|
25
26
|
|
|
27
|
+
printInitializationStatusLine('agents/', summary.agentsDirectoryStatus);
|
|
28
|
+
printInitializationStatusLine(CODER_DEVELOPER_AGENT_FILE_PATH, summary.developerAgentFileStatus);
|
|
26
29
|
printInitializationStatusLine(AGENTS_FILE_PATH, summary.agentsFileStatus);
|
|
27
30
|
printInitializationStatusLine(AGENT_CODING_FILE_PATH, summary.agentCodingFileStatus);
|
|
28
31
|
printInitializationStatusLine('.env', summary.envFileStatus);
|