@promptbook/cli 0.112.0-21 → 0.112.0-23
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/esm/index.es.js +268 -3
- package/esm/index.es.js.map +1 -1
- package/esm/src/_packages/components.index.d.ts +4 -0
- package/esm/src/_packages/types.index.d.ts +4 -0
- package/esm/src/book-components/Chat/types/ChatMessage.d.ts +54 -0
- package/esm/src/cli/$runPromptbookCli.d.ts +9 -0
- package/esm/src/cli/cli-commands/coder/init.d.ts +14 -0
- package/esm/src/cli/cli-commands/coder.d.ts +1 -0
- package/esm/src/cli/main.d.ts +2 -2
- package/esm/src/cli/test/ptbk.d.ts +1 -1
- package/esm/src/commitments/_common/toolRuntimeContext.d.ts +4 -0
- package/esm/src/version.d.ts +1 -1
- package/package.json +1 -1
- package/umd/index.umd.js +271 -6
- package/umd/index.umd.js.map +1 -1
- package/umd/src/_packages/components.index.d.ts +4 -0
- package/umd/src/_packages/types.index.d.ts +4 -0
- package/umd/src/book-components/Chat/types/ChatMessage.d.ts +54 -0
- package/umd/src/cli/$runPromptbookCli.d.ts +9 -0
- package/umd/src/cli/cli-commands/coder/init.d.ts +14 -0
- package/umd/src/cli/cli-commands/coder.d.ts +1 -0
- package/umd/src/cli/main.d.ts +2 -2
- package/umd/src/cli/test/ptbk.d.ts +1 -1
- package/umd/src/commitments/_common/toolRuntimeContext.d.ts +4 -0
- package/umd/src/version.d.ts +1 -1
|
@@ -54,6 +54,8 @@ import { mdSaveFormatDefinition } from '../book-components/Chat/save/markdown/md
|
|
|
54
54
|
import { pdfSaveFormatDefinition } from '../book-components/Chat/save/pdf/pdfSaveFormatDefinition';
|
|
55
55
|
import { reactSaveFormatDefinition } from '../book-components/Chat/save/react/reactSaveFormatDefinition';
|
|
56
56
|
import { txtSaveFormatDefinition } from '../book-components/Chat/save/text/txtSaveFormatDefinition';
|
|
57
|
+
import type { ChatProgressItem } from '../book-components/Chat/types/ChatMessage';
|
|
58
|
+
import type { ChatProgressCard } from '../book-components/Chat/types/ChatMessage';
|
|
57
59
|
import type { ChatMessage } from '../book-components/Chat/types/ChatMessage';
|
|
58
60
|
import type { ChatParticipant } from '../book-components/Chat/types/ChatParticipant';
|
|
59
61
|
import type { MessageButton } from '../book-components/Chat/utils/parseMessageButtons';
|
|
@@ -128,6 +130,8 @@ export { mdSaveFormatDefinition };
|
|
|
128
130
|
export { pdfSaveFormatDefinition };
|
|
129
131
|
export { reactSaveFormatDefinition };
|
|
130
132
|
export { txtSaveFormatDefinition };
|
|
133
|
+
export type { ChatProgressItem };
|
|
134
|
+
export type { ChatProgressCard };
|
|
131
135
|
export type { ChatMessage };
|
|
132
136
|
export type { ChatParticipant };
|
|
133
137
|
export type { MessageButton };
|
|
@@ -37,6 +37,8 @@ import type { ChatSaveFormatDefinition } from '../book-components/Chat/save/_com
|
|
|
37
37
|
import type { string_chat_format_name } from '../book-components/Chat/save/_common/string_chat_format_name';
|
|
38
38
|
import type { SourceChipProps } from '../book-components/Chat/SourceChip/SourceChip';
|
|
39
39
|
import type { ChatToolCall } from '../book-components/Chat/types/ChatMessage';
|
|
40
|
+
import type { ChatProgressItem } from '../book-components/Chat/types/ChatMessage';
|
|
41
|
+
import type { ChatProgressCard } from '../book-components/Chat/types/ChatMessage';
|
|
40
42
|
import type { ChatMessage } from '../book-components/Chat/types/ChatMessage';
|
|
41
43
|
import type { ChatParticipant } from '../book-components/Chat/types/ChatParticipant';
|
|
42
44
|
import type { ParsedCitation } from '../book-components/Chat/utils/parseCitationsFromContent';
|
|
@@ -458,6 +460,8 @@ export type { ChatSaveFormatDefinition };
|
|
|
458
460
|
export type { string_chat_format_name };
|
|
459
461
|
export type { SourceChipProps };
|
|
460
462
|
export type { ChatToolCall };
|
|
463
|
+
export type { ChatProgressItem };
|
|
464
|
+
export type { ChatProgressCard };
|
|
461
465
|
export type { ChatMessage };
|
|
462
466
|
export type { ChatParticipant };
|
|
463
467
|
export type { ParsedCitation };
|
|
@@ -2,6 +2,56 @@ import { Message } from '../../../types/Message';
|
|
|
2
2
|
import type { ToolCall } from '../../../types/ToolCall';
|
|
3
3
|
import type { id, string_date_iso8601, string_markdown } from '../../../types/typeAliases';
|
|
4
4
|
export type ChatToolCall = ToolCall;
|
|
5
|
+
/**
|
|
6
|
+
* One item in a user-facing progress card shown while assistant response is still running.
|
|
7
|
+
*
|
|
8
|
+
* @public exported from `@promptbook/components`
|
|
9
|
+
*/
|
|
10
|
+
export type ChatProgressItem = {
|
|
11
|
+
/**
|
|
12
|
+
* Stable item id used for incremental updates.
|
|
13
|
+
*/
|
|
14
|
+
readonly id: string;
|
|
15
|
+
/**
|
|
16
|
+
* Item text in markdown.
|
|
17
|
+
*/
|
|
18
|
+
readonly text: string_markdown;
|
|
19
|
+
/**
|
|
20
|
+
* Item status shown by the UI.
|
|
21
|
+
*/
|
|
22
|
+
readonly status: 'pending' | 'completed';
|
|
23
|
+
};
|
|
24
|
+
/**
|
|
25
|
+
* Structured progress card rendered in place of generic thinking placeholders.
|
|
26
|
+
*
|
|
27
|
+
* @public exported from `@promptbook/components`
|
|
28
|
+
*/
|
|
29
|
+
export type ChatProgressCard = {
|
|
30
|
+
/**
|
|
31
|
+
* Optional title shown at the top of the panel.
|
|
32
|
+
*/
|
|
33
|
+
readonly title?: string_markdown;
|
|
34
|
+
/**
|
|
35
|
+
* Optional markdown section describing current work.
|
|
36
|
+
*/
|
|
37
|
+
readonly now?: string_markdown;
|
|
38
|
+
/**
|
|
39
|
+
* Optional markdown section describing upcoming work.
|
|
40
|
+
*/
|
|
41
|
+
readonly next?: string_markdown;
|
|
42
|
+
/**
|
|
43
|
+
* Ordered bullet items representing in-progress or completed tasks.
|
|
44
|
+
*/
|
|
45
|
+
readonly items: ReadonlyArray<ChatProgressItem>;
|
|
46
|
+
/**
|
|
47
|
+
* Optional timestamp when this card was last updated.
|
|
48
|
+
*/
|
|
49
|
+
readonly updatedAt?: string_date_iso8601;
|
|
50
|
+
/**
|
|
51
|
+
* Optional visibility flag allowing explicit panel hide before final answer.
|
|
52
|
+
*/
|
|
53
|
+
readonly isVisible?: boolean;
|
|
54
|
+
};
|
|
5
55
|
/**
|
|
6
56
|
* Represents a single message within a chat interface.
|
|
7
57
|
*
|
|
@@ -111,6 +161,10 @@ export type ChatMessage = Omit<Message<id>, 'direction' | 'recipients' | 'thread
|
|
|
111
161
|
*/
|
|
112
162
|
excerpt?: string;
|
|
113
163
|
}>;
|
|
164
|
+
/**
|
|
165
|
+
* Optional structured progress-card payload shown while a response is still in progress.
|
|
166
|
+
*/
|
|
167
|
+
readonly progressCard?: ChatProgressCard;
|
|
114
168
|
};
|
|
115
169
|
/**
|
|
116
170
|
* TODO: Make all fields readonly
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared bootstrap for Promptbook CLI used by both local `ts-node` and packaged `npx` entrypoints.
|
|
3
|
+
*
|
|
4
|
+
* @private internal utility of Promptbook CLI bootstrap
|
|
5
|
+
*/
|
|
6
|
+
export declare function $runPromptbookCli(): Promise<void>;
|
|
7
|
+
/**
|
|
8
|
+
* Note: [🟡] Code in this file should never be published outside of `@promptbook/cli`
|
|
9
|
+
*/
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { Command as Program } from 'commander';
|
|
2
|
+
import type { $side_effect } from '../../../utils/organization/$side_effect';
|
|
3
|
+
/**
|
|
4
|
+
* Initializes `coder init` command for Promptbook CLI utilities.
|
|
5
|
+
*
|
|
6
|
+
* Note: `$` is used to indicate that this function is not a pure function - it registers a command in the CLI.
|
|
7
|
+
*
|
|
8
|
+
* @private internal function of `promptbookCli`
|
|
9
|
+
*/
|
|
10
|
+
export declare function $initializeCoderInitCommand(program: Program): $side_effect;
|
|
11
|
+
/**
|
|
12
|
+
* Note: [💞] Ignore a discrepancy between file name and entity name
|
|
13
|
+
* Note: [🟡] Code in this file should never be published outside of `@promptbook/cli`
|
|
14
|
+
*/
|
|
@@ -4,6 +4,7 @@ import type { $side_effect } from '../../utils/organization/$side_effect';
|
|
|
4
4
|
* Initializes `coder` command with subcommands for Promptbook CLI utilities
|
|
5
5
|
*
|
|
6
6
|
* The coder command provides utilities for automated coding:
|
|
7
|
+
* - init: Initialize coder configuration in current project
|
|
7
8
|
* - generate-boilerplates: Generate prompt boilerplate files
|
|
8
9
|
* - find-refactor-candidates: Find files that need refactoring
|
|
9
10
|
* - run: Run coding prompts with AI agents
|
package/esm/src/cli/main.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { $runPromptbookCli } from './$runPromptbookCli';
|
|
2
2
|
/**
|
|
3
3
|
* Note: [🔺] Purpose of this file is to export CLI for production environment
|
|
4
4
|
*/
|
|
@@ -8,7 +8,7 @@ import { promptbookCli } from './promptbookCli';
|
|
|
8
8
|
* @public exported from `@promptbook/cli`
|
|
9
9
|
*/
|
|
10
10
|
export declare const _CLI: {
|
|
11
|
-
_initialize_promptbookCli: typeof
|
|
11
|
+
_initialize_promptbookCli: typeof $runPromptbookCli;
|
|
12
12
|
};
|
|
13
13
|
/**
|
|
14
14
|
* Note: [💞] Ignore a discrepancy between file name and entity name
|
|
@@ -104,6 +104,10 @@ export type ToolRuntimeContext = {
|
|
|
104
104
|
userId?: number;
|
|
105
105
|
agentId?: string;
|
|
106
106
|
agentName?: string;
|
|
107
|
+
/**
|
|
108
|
+
* Optional assistant message id currently being generated in durable web chat.
|
|
109
|
+
*/
|
|
110
|
+
assistantMessageId?: string;
|
|
107
111
|
parameters?: Record<string, string>;
|
|
108
112
|
attachments?: ReadonlyArray<ChatAttachment>;
|
|
109
113
|
};
|
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-22`).
|
|
19
19
|
*
|
|
20
20
|
* @generated
|
|
21
21
|
*/
|
package/package.json
CHANGED
package/umd/index.umd.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
(function (global, factory) {
|
|
2
|
-
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('colors'), require('commander'), require('spacetrim'), require('fs'), require('path'), require('
|
|
3
|
-
typeof define === 'function' && define.amd ? define(['exports', 'colors', 'commander', 'spacetrim', 'fs', 'path', '
|
|
4
|
-
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global["promptbook-cli"] = {}, global.colors, global.commander, global._spaceTrim, global.fs, global.path, global.
|
|
5
|
-
})(this, (function (exports, colors, commander, _spaceTrim, fs, path, waitasecond, prompts,
|
|
2
|
+
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('colors'), require('commander'), require('spacetrim'), require('fs'), require('path'), require('fs/promises'), require('waitasecond'), require('prompts'), require('dotenv'), require('crypto-js/enc-hex'), require('crypto-js/sha256'), require('socket.io-client'), require('crypto-js'), require('jszip'), require('crypto'), require('@mozilla/readability'), require('jsdom'), require('showdown'), require('glob-promise'), require('moment'), require('express'), require('express-openapi-validator'), require('http'), require('socket.io'), require('swagger-ui-express'), require('react'), require('react-dom/server'), require('@anthropic-ai/sdk'), require('bottleneck'), require('@azure/openai'), require('typescript'), require('readline'), require('child_process'), require('pg'), require('@supabase/supabase-js'), require('path/posix'), require('rxjs'), require('mime-types'), require('papaparse'), require('@openai/agents'), require('openai')) :
|
|
3
|
+
typeof define === 'function' && define.amd ? define(['exports', 'colors', 'commander', 'spacetrim', 'fs', 'path', 'fs/promises', 'waitasecond', 'prompts', 'dotenv', 'crypto-js/enc-hex', 'crypto-js/sha256', 'socket.io-client', 'crypto-js', 'jszip', 'crypto', '@mozilla/readability', 'jsdom', 'showdown', 'glob-promise', 'moment', 'express', 'express-openapi-validator', 'http', 'socket.io', 'swagger-ui-express', 'react', 'react-dom/server', '@anthropic-ai/sdk', 'bottleneck', '@azure/openai', 'typescript', 'readline', 'child_process', 'pg', '@supabase/supabase-js', 'path/posix', 'rxjs', 'mime-types', 'papaparse', '@openai/agents', 'openai'], factory) :
|
|
4
|
+
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global["promptbook-cli"] = {}, global.colors, global.commander, global._spaceTrim, global.fs, global.path, global.promises, global.waitasecond, global.prompts, global.dotenv, global.hexEncoder, global.sha256, global.socket_ioClient, global.cryptoJs, global.JSZip, global.crypto, global.readability, global.jsdom, global.showdown, global.glob, global.moment, global.express, global.OpenApiValidator, global.http, global.socket_io, global.swaggerUi, global.react, global.server, global.Anthropic, global.Bottleneck, global.openai, global.ts, global.readline, global.child_process, global.pg, null, global.posix, global.rxjs, global.mimeTypes, global.papaparse, global.agents, global.OpenAI));
|
|
5
|
+
})(this, (function (exports, colors, commander, _spaceTrim, fs, path, promises, waitasecond, prompts, dotenv, hexEncoder, sha256, socket_ioClient, cryptoJs, JSZip, crypto, readability, jsdom, showdown, glob, moment, express, OpenApiValidator, http, socket_io, swaggerUi, react, server, Anthropic, Bottleneck, openai, ts, readline, child_process, pg, supabaseJs, posix, rxjs, mimeTypes, papaparse, agents, OpenAI) { 'use strict';
|
|
6
6
|
|
|
7
7
|
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
8
8
|
|
|
@@ -60,7 +60,7 @@
|
|
|
60
60
|
* @generated
|
|
61
61
|
* @see https://github.com/webgptorg/promptbook
|
|
62
62
|
*/
|
|
63
|
-
const PROMPTBOOK_ENGINE_VERSION = '0.112.0-
|
|
63
|
+
const PROMPTBOOK_ENGINE_VERSION = '0.112.0-23';
|
|
64
64
|
/**
|
|
65
65
|
* TODO: string_promptbook_version should be constrained to the all versions of Promptbook engine
|
|
66
66
|
* Note: [💞] Ignore a discrepancy between file name and entity name
|
|
@@ -1830,6 +1830,205 @@
|
|
|
1830
1830
|
* Note: [🟡] Code in this file should never be published outside of `@promptbook/cli`
|
|
1831
1831
|
*/
|
|
1832
1832
|
|
|
1833
|
+
/**
|
|
1834
|
+
* Relative path to the root prompts directory used by Promptbook coder utilities.
|
|
1835
|
+
*/
|
|
1836
|
+
const PROMPTS_DIRECTORY_PATH = 'prompts';
|
|
1837
|
+
/**
|
|
1838
|
+
* Relative path to the archive directory used by `coder verify`.
|
|
1839
|
+
*/
|
|
1840
|
+
const PROMPTS_DONE_DIRECTORY_PATH = path.join(PROMPTS_DIRECTORY_PATH, 'done');
|
|
1841
|
+
/**
|
|
1842
|
+
* Required environment variables for coding-agent git identity.
|
|
1843
|
+
*/
|
|
1844
|
+
const REQUIRED_CODER_ENV_VARIABLES = [
|
|
1845
|
+
{
|
|
1846
|
+
name: 'CODING_AGENT_GIT_NAME',
|
|
1847
|
+
value: 'Promptbook Coding Agent',
|
|
1848
|
+
},
|
|
1849
|
+
{
|
|
1850
|
+
name: 'CODING_AGENT_GIT_EMAIL',
|
|
1851
|
+
value: 'coding-agent@promptbook.studio',
|
|
1852
|
+
},
|
|
1853
|
+
{
|
|
1854
|
+
name: 'CODING_AGENT_GIT_SIGNING_KEY',
|
|
1855
|
+
value: '13406525ED912F938FEA85AB4046C687298B2382',
|
|
1856
|
+
},
|
|
1857
|
+
];
|
|
1858
|
+
/**
|
|
1859
|
+
* Initializes `coder init` command for Promptbook CLI utilities.
|
|
1860
|
+
*
|
|
1861
|
+
* Note: `$` is used to indicate that this function is not a pure function - it registers a command in the CLI.
|
|
1862
|
+
*
|
|
1863
|
+
* @private internal function of `promptbookCli`
|
|
1864
|
+
*/
|
|
1865
|
+
function $initializeCoderInitCommand(program) {
|
|
1866
|
+
const command = program.command('init');
|
|
1867
|
+
command.alias('initialize');
|
|
1868
|
+
command.description(_spaceTrim.spaceTrim(`
|
|
1869
|
+
Initialize Promptbook coder configuration for current project
|
|
1870
|
+
|
|
1871
|
+
Creates:
|
|
1872
|
+
- prompts/
|
|
1873
|
+
- prompts/done/
|
|
1874
|
+
|
|
1875
|
+
Ensures required coding-agent environment variables in .env:
|
|
1876
|
+
- CODING_AGENT_GIT_NAME
|
|
1877
|
+
- CODING_AGENT_GIT_EMAIL
|
|
1878
|
+
- CODING_AGENT_GIT_SIGNING_KEY
|
|
1879
|
+
`));
|
|
1880
|
+
command.action(handleActionErrors(async () => {
|
|
1881
|
+
const summary = await initializeCoderProjectConfiguration(process.cwd());
|
|
1882
|
+
printInitializationSummary(summary);
|
|
1883
|
+
}));
|
|
1884
|
+
}
|
|
1885
|
+
/**
|
|
1886
|
+
* Creates or updates all coder configuration artifacts required in the current project.
|
|
1887
|
+
*/
|
|
1888
|
+
async function initializeCoderProjectConfiguration(projectPath) {
|
|
1889
|
+
const promptsDirectoryStatus = await ensureDirectory(projectPath, PROMPTS_DIRECTORY_PATH);
|
|
1890
|
+
const promptsDoneDirectoryStatus = await ensureDirectory(projectPath, PROMPTS_DONE_DIRECTORY_PATH);
|
|
1891
|
+
const { envFileStatus, initializedEnvVariableNames } = await ensureCoderEnvFile(projectPath);
|
|
1892
|
+
return {
|
|
1893
|
+
promptsDirectoryStatus,
|
|
1894
|
+
promptsDoneDirectoryStatus,
|
|
1895
|
+
envFileStatus,
|
|
1896
|
+
initializedEnvVariableNames,
|
|
1897
|
+
};
|
|
1898
|
+
}
|
|
1899
|
+
/**
|
|
1900
|
+
* Ensures a relative directory exists in the project root.
|
|
1901
|
+
*/
|
|
1902
|
+
async function ensureDirectory(projectPath, relativeDirectoryPath) {
|
|
1903
|
+
const directoryPath = path.join(projectPath, relativeDirectoryPath);
|
|
1904
|
+
const existedBefore = await isExistingDirectory(directoryPath);
|
|
1905
|
+
if (!existedBefore) {
|
|
1906
|
+
await promises.mkdir(directoryPath, { recursive: true });
|
|
1907
|
+
return 'created';
|
|
1908
|
+
}
|
|
1909
|
+
return 'unchanged';
|
|
1910
|
+
}
|
|
1911
|
+
/**
|
|
1912
|
+
* Ensures `.env` exists and contains all required coder environment variables.
|
|
1913
|
+
*/
|
|
1914
|
+
async function ensureCoderEnvFile(projectPath) {
|
|
1915
|
+
const envFilePath = path.join(projectPath, '.env');
|
|
1916
|
+
const envFileExistedBefore = await isExistingFile(envFilePath);
|
|
1917
|
+
const currentEnvContent = envFileExistedBefore ? await promises.readFile(envFilePath, 'utf-8') : '';
|
|
1918
|
+
const existingEnvVariables = parseEnvVariableNames(currentEnvContent);
|
|
1919
|
+
const missingEnvVariables = REQUIRED_CODER_ENV_VARIABLES.filter(({ name }) => !existingEnvVariables.has(name));
|
|
1920
|
+
if (missingEnvVariables.length === 0) {
|
|
1921
|
+
if (!envFileExistedBefore) {
|
|
1922
|
+
await promises.writeFile(envFilePath, '# Environment variables for Promptbook coder\n', 'utf-8');
|
|
1923
|
+
return {
|
|
1924
|
+
envFileStatus: 'created',
|
|
1925
|
+
initializedEnvVariableNames: [],
|
|
1926
|
+
};
|
|
1927
|
+
}
|
|
1928
|
+
return {
|
|
1929
|
+
envFileStatus: 'unchanged',
|
|
1930
|
+
initializedEnvVariableNames: [],
|
|
1931
|
+
};
|
|
1932
|
+
}
|
|
1933
|
+
const envBlockToAppend = buildMissingEnvVariablesBlock(missingEnvVariables);
|
|
1934
|
+
const nextEnvContent = appendBlock(currentEnvContent, envBlockToAppend);
|
|
1935
|
+
await promises.writeFile(envFilePath, nextEnvContent, 'utf-8');
|
|
1936
|
+
return {
|
|
1937
|
+
envFileStatus: envFileExistedBefore ? 'updated' : 'created',
|
|
1938
|
+
initializedEnvVariableNames: missingEnvVariables.map(({ name }) => name),
|
|
1939
|
+
};
|
|
1940
|
+
}
|
|
1941
|
+
/**
|
|
1942
|
+
* Parses variable names currently defined in `.env` style content.
|
|
1943
|
+
*/
|
|
1944
|
+
function parseEnvVariableNames(envContent) {
|
|
1945
|
+
const variableNames = new Set();
|
|
1946
|
+
for (const line of envContent.split(/\r?\n/)) {
|
|
1947
|
+
const trimmedLine = line.trim();
|
|
1948
|
+
if (trimmedLine === '' || trimmedLine.startsWith('#')) {
|
|
1949
|
+
continue;
|
|
1950
|
+
}
|
|
1951
|
+
const match = trimmedLine.match(/^([A-Za-z_][A-Za-z0-9_]*)\s*=/);
|
|
1952
|
+
if (!match || !match[1]) {
|
|
1953
|
+
continue;
|
|
1954
|
+
}
|
|
1955
|
+
variableNames.add(match[1]);
|
|
1956
|
+
}
|
|
1957
|
+
return variableNames;
|
|
1958
|
+
}
|
|
1959
|
+
/**
|
|
1960
|
+
* Builds a `.env` block containing missing coder environment variables.
|
|
1961
|
+
*/
|
|
1962
|
+
function buildMissingEnvVariablesBlock(variables) {
|
|
1963
|
+
return _spaceTrim.spaceTrim(`
|
|
1964
|
+
# Promptbook coder identity (initialized by \`ptbk coder init\`)
|
|
1965
|
+
${variables.map(({ name, value }) => `${name}=${JSON.stringify(value)}`).join('\n')}
|
|
1966
|
+
`);
|
|
1967
|
+
}
|
|
1968
|
+
/**
|
|
1969
|
+
* Appends one text block to existing file content while preserving readable newlines.
|
|
1970
|
+
*/
|
|
1971
|
+
function appendBlock(currentContent, blockToAppend) {
|
|
1972
|
+
if (currentContent.trim() === '') {
|
|
1973
|
+
return `${blockToAppend}\n`;
|
|
1974
|
+
}
|
|
1975
|
+
const normalizedCurrentContent = currentContent.endsWith('\n') ? currentContent : `${currentContent}\n`;
|
|
1976
|
+
return `${normalizedCurrentContent}\n${blockToAppend}\n`;
|
|
1977
|
+
}
|
|
1978
|
+
/**
|
|
1979
|
+
* Prints a readable summary of what was initialized for the user.
|
|
1980
|
+
*/
|
|
1981
|
+
function printInitializationSummary(summary) {
|
|
1982
|
+
console.info(colors__default["default"].green('Promptbook coder configuration initialized.'));
|
|
1983
|
+
console.info(colors__default["default"].gray(`- prompts/: ${formatInitializationStatus(summary.promptsDirectoryStatus)}`));
|
|
1984
|
+
console.info(colors__default["default"].gray(`- prompts/done/: ${formatInitializationStatus(summary.promptsDoneDirectoryStatus)}`));
|
|
1985
|
+
console.info(colors__default["default"].gray(`- .env: ${formatInitializationStatus(summary.envFileStatus)}`));
|
|
1986
|
+
if (summary.initializedEnvVariableNames.length > 0) {
|
|
1987
|
+
console.info(colors__default["default"].cyan(`- Added env variables: ${summary.initializedEnvVariableNames.join(', ')}`));
|
|
1988
|
+
}
|
|
1989
|
+
else {
|
|
1990
|
+
console.info(colors__default["default"].gray('- Required coder env variables are already present.'));
|
|
1991
|
+
}
|
|
1992
|
+
}
|
|
1993
|
+
/**
|
|
1994
|
+
* Formats one initialization status into a human-readable label.
|
|
1995
|
+
*/
|
|
1996
|
+
function formatInitializationStatus(status) {
|
|
1997
|
+
if (status === 'created') {
|
|
1998
|
+
return 'created';
|
|
1999
|
+
}
|
|
2000
|
+
if (status === 'updated') {
|
|
2001
|
+
return 'updated';
|
|
2002
|
+
}
|
|
2003
|
+
return 'unchanged';
|
|
2004
|
+
}
|
|
2005
|
+
/**
|
|
2006
|
+
* Checks whether a path exists and is a file.
|
|
2007
|
+
*/
|
|
2008
|
+
async function isExistingFile(path) {
|
|
2009
|
+
try {
|
|
2010
|
+
return (await promises.stat(path)).isFile();
|
|
2011
|
+
}
|
|
2012
|
+
catch (_a) {
|
|
2013
|
+
return false;
|
|
2014
|
+
}
|
|
2015
|
+
}
|
|
2016
|
+
/**
|
|
2017
|
+
* Checks whether a path exists and is a directory.
|
|
2018
|
+
*/
|
|
2019
|
+
async function isExistingDirectory(path) {
|
|
2020
|
+
try {
|
|
2021
|
+
return (await promises.stat(path)).isDirectory();
|
|
2022
|
+
}
|
|
2023
|
+
catch (_a) {
|
|
2024
|
+
return false;
|
|
2025
|
+
}
|
|
2026
|
+
}
|
|
2027
|
+
/**
|
|
2028
|
+
* Note: [💞] Ignore a discrepancy between file name and entity name
|
|
2029
|
+
* Note: [🟡] Code in this file should never be published outside of `@promptbook/cli`
|
|
2030
|
+
*/
|
|
2031
|
+
|
|
1833
2032
|
/**
|
|
1834
2033
|
* Initializes `coder run` command for Promptbook CLI utilities
|
|
1835
2034
|
*
|
|
@@ -1979,6 +2178,7 @@
|
|
|
1979
2178
|
* Initializes `coder` command with subcommands for Promptbook CLI utilities
|
|
1980
2179
|
*
|
|
1981
2180
|
* The coder command provides utilities for automated coding:
|
|
2181
|
+
* - init: Initialize coder configuration in current project
|
|
1982
2182
|
* - generate-boilerplates: Generate prompt boilerplate files
|
|
1983
2183
|
* - find-refactor-candidates: Find files that need refactoring
|
|
1984
2184
|
* - run: Run coding prompts with AI agents
|
|
@@ -1995,6 +2195,7 @@
|
|
|
1995
2195
|
Coding utilities for automated development workflows
|
|
1996
2196
|
|
|
1997
2197
|
Subcommands:
|
|
2198
|
+
- init: Initialize coder configuration in current project
|
|
1998
2199
|
- generate-boilerplates: Generate prompt boilerplate files
|
|
1999
2200
|
- find-refactor-candidates: Find files that need refactoring
|
|
2000
2201
|
- run: Run coding prompts with AI agents
|
|
@@ -2002,6 +2203,7 @@
|
|
|
2002
2203
|
- find-fresh-emoji-tags: Find unused emoji tags
|
|
2003
2204
|
`));
|
|
2004
2205
|
// Register all subcommands
|
|
2206
|
+
$initializeCoderInitCommand(coderCommand);
|
|
2005
2207
|
$initializeCoderGenerateBoilerplatesCommand(coderCommand);
|
|
2006
2208
|
$initializeCoderFindRefactorCandidatesCommand(coderCommand);
|
|
2007
2209
|
$initializeCoderRunCommand(coderCommand);
|
|
@@ -31211,6 +31413,28 @@
|
|
|
31211
31413
|
* Note: [🟡] Code in this file should never be published outside of `@promptbook/cli`
|
|
31212
31414
|
*/
|
|
31213
31415
|
|
|
31416
|
+
/**
|
|
31417
|
+
* Tracks whether CLI runtime registrations were already initialized in this process.
|
|
31418
|
+
*
|
|
31419
|
+
* @private internal utility of Promptbook CLI bootstrap
|
|
31420
|
+
*/
|
|
31421
|
+
let isCliRuntimeRegistered = false;
|
|
31422
|
+
/**
|
|
31423
|
+
* Shared bootstrap for Promptbook CLI used by both local `ts-node` and packaged `npx` entrypoints.
|
|
31424
|
+
*
|
|
31425
|
+
* @private internal utility of Promptbook CLI bootstrap
|
|
31426
|
+
*/
|
|
31427
|
+
async function $runPromptbookCli() {
|
|
31428
|
+
if (!isCliRuntimeRegistered) {
|
|
31429
|
+
await Promise.resolve().then(function () { return cli_index; });
|
|
31430
|
+
isCliRuntimeRegistered = true;
|
|
31431
|
+
}
|
|
31432
|
+
await promptbookCli();
|
|
31433
|
+
}
|
|
31434
|
+
/**
|
|
31435
|
+
* Note: [🟡] Code in this file should never be published outside of `@promptbook/cli`
|
|
31436
|
+
*/
|
|
31437
|
+
|
|
31214
31438
|
/**
|
|
31215
31439
|
* Note: [🔺] Purpose of this file is to export CLI for production environment
|
|
31216
31440
|
*/
|
|
@@ -31221,7 +31445,7 @@
|
|
|
31221
31445
|
*/
|
|
31222
31446
|
const _CLI = {
|
|
31223
31447
|
// Note: [🥠]
|
|
31224
|
-
_initialize_promptbookCli:
|
|
31448
|
+
_initialize_promptbookCli: $runPromptbookCli,
|
|
31225
31449
|
};
|
|
31226
31450
|
/**
|
|
31227
31451
|
* Note: [💞] Ignore a discrepancy between file name and entity name
|
|
@@ -39911,6 +40135,47 @@
|
|
|
39911
40135
|
* Note: [💞] Ignore a discrepancy between file name and entity name
|
|
39912
40136
|
*/
|
|
39913
40137
|
|
|
40138
|
+
// ⚠️ WARNING: This code has been generated so that any manual changes will be overwritten
|
|
40139
|
+
|
|
40140
|
+
var cli_index = /*#__PURE__*/Object.freeze({
|
|
40141
|
+
__proto__: null,
|
|
40142
|
+
BOOK_LANGUAGE_VERSION: BOOK_LANGUAGE_VERSION,
|
|
40143
|
+
PROMPTBOOK_ENGINE_VERSION: PROMPTBOOK_ENGINE_VERSION,
|
|
40144
|
+
_CLI: _CLI,
|
|
40145
|
+
_AnthropicClaudeMetadataRegistration: _AnthropicClaudeMetadataRegistration,
|
|
40146
|
+
_AnthropicClaudeRegistration: _AnthropicClaudeRegistration,
|
|
40147
|
+
_AzureOpenAiMetadataRegistration: _AzureOpenAiMetadataRegistration,
|
|
40148
|
+
_AzureOpenAiRegistration: _AzureOpenAiRegistration,
|
|
40149
|
+
_DeepseekMetadataRegistration: _DeepseekMetadataRegistration,
|
|
40150
|
+
_DeepseekRegistration: _DeepseekRegistration,
|
|
40151
|
+
_GoogleMetadataRegistration: _GoogleMetadataRegistration,
|
|
40152
|
+
_GoogleRegistration: _GoogleRegistration,
|
|
40153
|
+
_OllamaMetadataRegistration: _OllamaMetadataRegistration,
|
|
40154
|
+
_OllamaRegistration: _OllamaRegistration,
|
|
40155
|
+
_OpenAiMetadataRegistration: _OpenAiMetadataRegistration,
|
|
40156
|
+
_OpenAiAssistantMetadataRegistration: _OpenAiAssistantMetadataRegistration,
|
|
40157
|
+
_OpenAiCompatibleMetadataRegistration: _OpenAiCompatibleMetadataRegistration,
|
|
40158
|
+
_OpenAiRegistration: _OpenAiRegistration,
|
|
40159
|
+
_OpenAiAssistantRegistration: _OpenAiAssistantRegistration,
|
|
40160
|
+
_OpenAiCompatibleRegistration: _OpenAiCompatibleRegistration,
|
|
40161
|
+
_BoilerplateScraperRegistration: _BoilerplateScraperRegistration,
|
|
40162
|
+
_BoilerplateScraperMetadataRegistration: _BoilerplateScraperMetadataRegistration,
|
|
40163
|
+
_LegacyDocumentScraperRegistration: _LegacyDocumentScraperRegistration,
|
|
40164
|
+
_LegacyDocumentScraperMetadataRegistration: _LegacyDocumentScraperMetadataRegistration,
|
|
40165
|
+
_DocumentScraperRegistration: _DocumentScraperRegistration,
|
|
40166
|
+
_DocumentScraperMetadataRegistration: _DocumentScraperMetadataRegistration,
|
|
40167
|
+
_MarkdownScraperRegistration: _MarkdownScraperRegistration,
|
|
40168
|
+
_MarkdownScraperMetadataRegistration: _MarkdownScraperMetadataRegistration,
|
|
40169
|
+
_MarkitdownScraperRegistration: _MarkitdownScraperRegistration,
|
|
40170
|
+
_MarkitdownScraperMetadataRegistration: _MarkitdownScraperMetadataRegistration,
|
|
40171
|
+
_PdfScraperRegistration: _PdfScraperRegistration,
|
|
40172
|
+
_PdfScraperMetadataRegistration: _PdfScraperMetadataRegistration,
|
|
40173
|
+
_WebsiteScraperRegistration: _WebsiteScraperRegistration,
|
|
40174
|
+
_WebsiteScraperMetadataRegistration: _WebsiteScraperMetadataRegistration,
|
|
40175
|
+
_FormattedBookInMarkdownTranspilerRegistration: _FormattedBookInMarkdownTranspilerRegistration,
|
|
40176
|
+
_OpenAiSdkTranspilerRegistration: _OpenAiSdkTranspilerRegistration
|
|
40177
|
+
});
|
|
40178
|
+
|
|
39914
40179
|
/**
|
|
39915
40180
|
* Shuffles an array of items randomly and returns a new array
|
|
39916
40181
|
*
|