@promptbook/cli 0.86.0-13 → 0.86.0-14

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 CHANGED
@@ -43,7 +43,7 @@ var BOOK_LANGUAGE_VERSION = '1.0.0';
43
43
  * @generated
44
44
  * @see https://github.com/webgptorg/promptbook
45
45
  */
46
- var PROMPTBOOK_ENGINE_VERSION = '0.86.0-13';
46
+ var PROMPTBOOK_ENGINE_VERSION = '0.86.0-14';
47
47
  /**
48
48
  * TODO: string_promptbook_version should be constrained to the all versions of Promptbook engine
49
49
  * Note: [💞] Ignore a discrepancy between file name and entity name
@@ -3798,7 +3798,7 @@ function capitalize(word) {
3798
3798
  * Converts promptbook in JSON format to string format
3799
3799
  *
3800
3800
  * @deprecated TODO: [🥍][🧠] Backup original files in `PipelineJson` same as in Promptbook.studio
3801
- * @param pipelineJson Promptbook in JSON format (.book.json)
3801
+ * @param pipelineJson Promptbook in JSON format (.bookc)
3802
3802
  * @returns Promptbook in string format (.book.md)
3803
3803
  * @public exported from `@promptbook/core`
3804
3804
  */
@@ -10744,7 +10744,7 @@ function flattenMarkdown(markdown) {
10744
10744
  * Note: This function acts as compilation process
10745
10745
  *
10746
10746
  * @param pipelineString {Promptbook} in string markdown format (.book.md)
10747
- * @returns {Promptbook} compiled in JSON format (.book.json)
10747
+ * @returns {Promptbook} compiled in JSON format (.bookc)
10748
10748
  * @throws {ParseError} if the promptbook string is not valid
10749
10749
  * @public exported from `@promptbook/core`
10750
10750
  */
@@ -11212,7 +11212,7 @@ function parsePipeline(pipelineString) {
11212
11212
  * @param pipelineString {Promptbook} in string markdown format (.book.md)
11213
11213
  * @param tools - Tools for the preparation and scraping - if not provided together with `llm`, the preparation will be skipped
11214
11214
  * @param options - Options and tools for the compilation
11215
- * @returns {Promptbook} compiled in JSON format (.book.json)
11215
+ * @returns {Promptbook} compiled in JSON format (.bookc)
11216
11216
  * @throws {ParseError} if the promptbook string is not valid
11217
11217
  * @public exported from `@promptbook/core`
11218
11218
  */
@@ -12006,7 +12006,7 @@ function createCollectionFromDirectory(rootPath, tools, options) {
12006
12006
  }
12007
12007
  madeLibraryFilePath = join(rootPath, "".concat(DEFAULT_PIPELINE_COLLECTION_BASE_FILENAME
12008
12008
  // <- TODO: [🦒] Allow to override (pass different value into the function)
12009
- , ".json"));
12009
+ , ".bookc"));
12010
12010
  return [4 /*yield*/, isFileExisting(madeLibraryFilePath, tools.fs)];
12011
12011
  case 3:
12012
12012
  if (!(_f.sent())) ;
@@ -12028,13 +12028,13 @@ function createCollectionFromDirectory(rootPath, tools, options) {
12028
12028
  return [4 /*yield*/, listAllFiles(rootPath, isRecursive, tools.fs)];
12029
12029
  case 1:
12030
12030
  fileNames = _b.sent();
12031
- // Note: First load all `.book.json` and then `.book` / `.book` files
12032
- // `.book.json` can be prepared so it is faster to load
12031
+ // Note: First load compiled `.bookc` files and then source `.book` files
12032
+ // `.bookc` are already compiled and can be used faster
12033
12033
  fileNames.sort(function (a, b) {
12034
- if (a.endsWith('.json') && (b.endsWith('.book') || b.endsWith('.book'))) {
12034
+ if ((a.endsWith('.bookc') || a.endsWith('.book.json')) && (b.endsWith('.book') || b.endsWith('.book.md'))) {
12035
12035
  return -1;
12036
12036
  }
12037
- if ((a.endsWith('.book') || a.endsWith('.book')) && b.endsWith('.json')) {
12037
+ if ((a.endsWith('.book') || a.endsWith('.book.md')) && (b.endsWith('.bookc') || b.endsWith('.book.json'))) {
12038
12038
  return 1;
12039
12039
  }
12040
12040
  return 0;
@@ -12051,7 +12051,7 @@ function createCollectionFromDirectory(rootPath, tools, options) {
12051
12051
  case 1:
12052
12052
  _f.trys.push([1, 8, , 9]);
12053
12053
  pipeline = null;
12054
- if (!(fileName.endsWith('.book') || fileName.endsWith('.book'))) return [3 /*break*/, 4];
12054
+ if (!(fileName.endsWith('.book') || fileName.endsWith('.book.md'))) return [3 /*break*/, 4];
12055
12055
  _c = validatePipelineString;
12056
12056
  return [4 /*yield*/, readFile(fileName, 'utf-8')];
12057
12057
  case 2:
@@ -12064,7 +12064,7 @@ function createCollectionFromDirectory(rootPath, tools, options) {
12064
12064
  pipeline = __assign(__assign({}, pipeline), { sourceFile: sourceFile });
12065
12065
  return [3 /*break*/, 7];
12066
12066
  case 4:
12067
- if (!fileName.endsWith('.book.json')) return [3 /*break*/, 6];
12067
+ if (!(fileName.endsWith('.bookc') || fileName.endsWith('.book.json'))) return [3 /*break*/, 6];
12068
12068
  _e = (_d = JSON).parse;
12069
12069
  return [4 /*yield*/, readFile(fileName, 'utf-8')];
12070
12070
  case 5:
@@ -12275,7 +12275,7 @@ function $initializeMakeCommand(program) {
12275
12275
  'Path to promptbook collection directory', DEFAULT_BOOKS_DIRNAME);
12276
12276
  makeCommand.option('--project-name', "Name of the project for whom collection is", 'Untitled Promptbook project');
12277
12277
  makeCommand.option('--root-url <url>', "Root URL of all pipelines to make", undefined);
12278
- makeCommand.option('-f, --format <format>', spaceTrim("\n Output format of builded collection \"javascript\", \"typescript\" or \"json\"\n\n Note: You can use multiple formats separated by comma\n "), 'javascript' /* <- Note: [🏳‍🌈] */);
12278
+ makeCommand.option('-f, --format <format>', spaceTrim("\n Output format of builded collection \"bookc\", \"javascript\", \"typescript\" or \"json\"\n\n Note: You can use multiple formats separated by comma\n "), 'bookc' /* <- Note: [🏳‍🌈] */);
12279
12279
  makeCommand.option('--no-validation', "Do not validate logic of pipelines in collection", true);
12280
12280
  makeCommand.option('--validation', "Types of validations separated by comma (options \"logic\",\"imports\")", 'logic,imports');
12281
12281
  makeCommand.option('-r, --reload', "Call LLM models even if same prompt with result is in the cache", false);
@@ -12443,27 +12443,34 @@ function $initializeMakeCommand(program) {
12443
12443
  }
12444
12444
  });
12445
12445
  }); };
12446
- if (!formats.includes('json')) return [3 /*break*/, 22];
12447
- formats = formats.filter(function (format) { return format !== 'json'; });
12448
- return [4 /*yield*/, saveFile('json', collectionJsonString)];
12446
+ if (!formats.includes('bookc')) return [3 /*break*/, 22];
12447
+ formats = formats.filter(function (format) { return format !== 'bookc'; });
12448
+ return [4 /*yield*/, saveFile('bookc', collectionJsonString + '\n\n\n\n\n\n\n\n' /* <- TODO: !!!!!! Remove new lines */)];
12449
12449
  case 21:
12450
12450
  _e.sent();
12451
12451
  _e.label = 22;
12452
12452
  case 22:
12453
- if (!(formats.includes('javascript') || formats.includes('js'))) return [3 /*break*/, 24];
12454
- formats = formats.filter(function (format) { return format !== 'javascript' && format !== 'js'; });
12455
- return [4 /*yield*/, saveFile('js', spaceTrim(function (block) { return "\n // ".concat(block(GENERATOR_WARNING_BY_PROMPTBOOK_CLI), "\n\n import { createCollectionFromJson } from '@promptbook/core';\n\n /**\n * Pipeline collection for ").concat(projectName, "\n *\n * ").concat(block(GENERATOR_WARNING_BY_PROMPTBOOK_CLI), "\n *\n * @generated\n * @private internal cache for `").concat(functionName, "`\n */\n let pipelineCollection = null;\n\n\n /**\n * Get pipeline collection for ").concat(projectName, "\n *\n * ").concat(block(GENERATOR_WARNING_BY_PROMPTBOOK_CLI), "\n *\n * @generated\n * @returns {PipelineCollection} Library of promptbooks for ").concat(projectName, "\n */\n export function ").concat(functionName, "(){\n if(pipelineCollection===null){\n pipelineCollection = createCollectionFromJson(\n ").concat(block(collectionJsonItems), "\n );\n }\n\n return pipelineCollection;\n }\n "); }))];
12453
+ if (!formats.includes('json')) return [3 /*break*/, 24];
12454
+ formats = formats.filter(function (format) { return format !== 'json'; });
12455
+ return [4 /*yield*/, saveFile('json', collectionJsonString)];
12456
12456
  case 23:
12457
- (_e.sent()) + '\n';
12457
+ _e.sent();
12458
12458
  _e.label = 24;
12459
12459
  case 24:
12460
- if (!(formats.includes('typescript') || formats.includes('ts'))) return [3 /*break*/, 26];
12461
- formats = formats.filter(function (format) { return format !== 'typescript' && format !== 'ts'; });
12462
- return [4 /*yield*/, saveFile('ts', spaceTrim(function (block) { return "\n // ".concat(block(GENERATOR_WARNING_BY_PROMPTBOOK_CLI), "\n\n import { createCollectionFromJson } from '@promptbook/core';\n import type { PipelineCollection } from '@promptbook/types';\n\n /**\n * Pipeline collection for ").concat(projectName, "\n *\n * ").concat(block(GENERATOR_WARNING_BY_PROMPTBOOK_CLI), "\n *\n * @private internal cache for `").concat(functionName, "`\n * @generated\n */\n let pipelineCollection: null | PipelineCollection = null;\n\n\n /**\n * Get pipeline collection for ").concat(projectName, "\n *\n * ").concat(block(GENERATOR_WARNING_BY_PROMPTBOOK_CLI), "\n *\n * @generated\n * @returns {PipelineCollection} Library of promptbooks for ").concat(projectName, "\n */\n export function ").concat(functionName, "(): PipelineCollection{\n if(pipelineCollection===null){\n\n // TODO: !!6 Use book string literal notation\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n pipelineCollection = (createCollectionFromJson as (..._: any) => PipelineCollection)(\n ").concat(block(collectionJsonItems), "\n );\n }\n\n return pipelineCollection;\n }\n "); }) + '\n')];
12460
+ if (!(formats.includes('javascript') || formats.includes('js'))) return [3 /*break*/, 26];
12461
+ formats = formats.filter(function (format) { return format !== 'javascript' && format !== 'js'; });
12462
+ return [4 /*yield*/, saveFile('js', spaceTrim(function (block) { return "\n // ".concat(block(GENERATOR_WARNING_BY_PROMPTBOOK_CLI), "\n\n import { createCollectionFromJson } from '@promptbook/core';\n\n /**\n * Pipeline collection for ").concat(projectName, "\n *\n * ").concat(block(GENERATOR_WARNING_BY_PROMPTBOOK_CLI), "\n *\n * @generated\n * @private internal cache for `").concat(functionName, "`\n */\n let pipelineCollection = null;\n\n\n /**\n * Get pipeline collection for ").concat(projectName, "\n *\n * ").concat(block(GENERATOR_WARNING_BY_PROMPTBOOK_CLI), "\n *\n * @generated\n * @returns {PipelineCollection} Library of promptbooks for ").concat(projectName, "\n */\n export function ").concat(functionName, "(){\n if(pipelineCollection===null){\n pipelineCollection = createCollectionFromJson(\n ").concat(block(collectionJsonItems), "\n );\n }\n\n return pipelineCollection;\n }\n "); }))];
12463
12463
  case 25:
12464
- _e.sent();
12464
+ (_e.sent()) + '\n';
12465
12465
  _e.label = 26;
12466
12466
  case 26:
12467
+ if (!(formats.includes('typescript') || formats.includes('ts'))) return [3 /*break*/, 28];
12468
+ formats = formats.filter(function (format) { return format !== 'typescript' && format !== 'ts'; });
12469
+ return [4 /*yield*/, saveFile('ts', spaceTrim(function (block) { return "\n // ".concat(block(GENERATOR_WARNING_BY_PROMPTBOOK_CLI), "\n\n import { createCollectionFromJson } from '@promptbook/core';\n import type { PipelineCollection } from '@promptbook/types';\n\n /**\n * Pipeline collection for ").concat(projectName, "\n *\n * ").concat(block(GENERATOR_WARNING_BY_PROMPTBOOK_CLI), "\n *\n * @private internal cache for `").concat(functionName, "`\n * @generated\n */\n let pipelineCollection: null | PipelineCollection = null;\n\n\n /**\n * Get pipeline collection for ").concat(projectName, "\n *\n * ").concat(block(GENERATOR_WARNING_BY_PROMPTBOOK_CLI), "\n *\n * @generated\n * @returns {PipelineCollection} Library of promptbooks for ").concat(projectName, "\n */\n export function ").concat(functionName, "(): PipelineCollection{\n if(pipelineCollection===null){\n\n // TODO: !!6 Use book string literal notation\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n pipelineCollection = (createCollectionFromJson as (..._: any) => PipelineCollection)(\n ").concat(block(collectionJsonItems), "\n );\n }\n\n return pipelineCollection;\n }\n "); }) + '\n')];
12470
+ case 27:
12471
+ _e.sent();
12472
+ _e.label = 28;
12473
+ case 28:
12467
12474
  if (formats.length > 0) {
12468
12475
  console.warn(colors.yellow("Format ".concat(formats.join(' and '), " is not supported")));
12469
12476
  }
@@ -14169,7 +14176,7 @@ function $initializeStartServerCommand(program) {
14169
14176
  function $initializeTestCommand(program) {
14170
14177
  var _this = this;
14171
14178
  var testCommand = program.command('test');
14172
- testCommand.description(spaceTrim("\n Iterates over `.book.md` and `.book.json` and checks if they are parsable and logically valid\n "));
14179
+ testCommand.description(spaceTrim("\n Iterates over `.book.md` and `.bookc` and checks if they are parsable and logically valid\n "));
14173
14180
  testCommand.argument('<filesGlob>',
14174
14181
  // <- TODO: [🧟‍♂️] Unite path to promptbook collection argument
14175
14182
  'Pipelines to test as glob pattern');
@@ -14234,7 +14241,7 @@ function $initializeTestCommand(program) {
14234
14241
  }
14235
14242
  _g.label = 10;
14236
14243
  case 10:
14237
- if (!filename.endsWith('.book.json')) return [3 /*break*/, 12];
14244
+ if (!filename.endsWith('.bookc')) return [3 /*break*/, 12];
14238
14245
  _d = (_c = JSON).parse;
14239
14246
  return [4 /*yield*/, readFile(filename, 'utf-8')];
14240
14247
  case 11: