@promptbook/cli 0.82.0-3 → 0.83.0

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.
Files changed (45) hide show
  1. package/README.md +0 -4
  2. package/esm/index.es.js +47 -44
  3. package/esm/index.es.js.map +1 -1
  4. package/esm/typings/src/_packages/editable.index.d.ts +74 -0
  5. package/esm/typings/src/_packages/types.index.d.ts +26 -0
  6. package/esm/typings/src/commands/BOOK_VERSION/BookVersionCommand.d.ts +1 -1
  7. package/esm/typings/src/commands/BOOK_VERSION/bookVersionCommandParser.d.ts +1 -1
  8. package/esm/typings/src/commands/EXPECT/expectCommandParser.d.ts +1 -1
  9. package/esm/typings/src/commands/FOREACH/ForeachCommand.d.ts +1 -1
  10. package/esm/typings/src/commands/FOREACH/foreachCommandParser.d.ts +1 -1
  11. package/esm/typings/src/commands/FORMAT/formatCommandParser.d.ts +1 -1
  12. package/esm/typings/src/commands/FORMFACTOR/FormfactorCommand.d.ts +1 -1
  13. package/esm/typings/src/commands/FORMFACTOR/formfactorCommandParser.d.ts +1 -1
  14. package/esm/typings/src/commands/JOKER/JokerCommand.d.ts +1 -1
  15. package/esm/typings/src/commands/JOKER/jokerCommandParser.d.ts +1 -1
  16. package/esm/typings/src/commands/KNOWLEDGE/KnowledgeCommand.d.ts +2 -2
  17. package/esm/typings/src/commands/KNOWLEDGE/knowledgeCommandParser.d.ts +1 -1
  18. package/esm/typings/src/commands/KNOWLEDGE/utils/{sourceContentToName.d.ts → knowledgeSourceContentToName.d.ts} +2 -2
  19. package/esm/typings/src/commands/MODEL/ModelCommand.d.ts +2 -1
  20. package/esm/typings/src/commands/MODEL/modelCommandParser.d.ts +2 -1
  21. package/esm/typings/src/commands/PARAMETER/ParameterCommand.d.ts +1 -1
  22. package/esm/typings/src/commands/PARAMETER/parameterCommandParser.d.ts +1 -1
  23. package/esm/typings/src/commands/PERSONA/PersonaCommand.d.ts +1 -1
  24. package/esm/typings/src/commands/PERSONA/personaCommandParser.d.ts +1 -1
  25. package/esm/typings/src/commands/POSTPROCESS/PostprocessCommand.d.ts +1 -1
  26. package/esm/typings/src/commands/POSTPROCESS/postprocessCommandParser.d.ts +1 -1
  27. package/esm/typings/src/commands/SECTION/SectionCommand.d.ts +1 -1
  28. package/esm/typings/src/commands/SECTION/sectionCommandParser.d.ts +1 -1
  29. package/esm/typings/src/commands/URL/UrlCommand.d.ts +1 -1
  30. package/esm/typings/src/commands/URL/urlCommandParser.d.ts +1 -1
  31. package/esm/typings/src/commands/X_ACTION/ActionCommand.d.ts +1 -1
  32. package/esm/typings/src/commands/X_ACTION/actionCommandParser.d.ts +1 -1
  33. package/esm/typings/src/commands/X_INSTRUMENT/InstrumentCommand.d.ts +1 -1
  34. package/esm/typings/src/commands/X_INSTRUMENT/instrumentCommandParser.d.ts +1 -1
  35. package/esm/typings/src/commands/_common/getParserForCommand.d.ts +1 -1
  36. package/esm/typings/src/commands/_common/parseCommand.d.ts +1 -1
  37. package/esm/typings/src/commands/_common/stringifyCommand.d.ts +1 -0
  38. package/esm/typings/src/commands/_common/types/CommandParser.d.ts +8 -0
  39. package/esm/typings/src/commands/_common/types/CommandUsagePlaces.d.ts +2 -0
  40. package/esm/typings/src/commands/index.d.ts +1 -1
  41. package/esm/typings/src/pipeline/PipelineJson/KnowledgeSourceJson.d.ts +1 -1
  42. package/package.json +1 -1
  43. package/umd/index.umd.js +47 -44
  44. package/umd/index.umd.js.map +1 -1
  45. /package/esm/typings/src/commands/KNOWLEDGE/utils/{sourceContentToName.test.d.ts → knowledgeSourceContentToName.test.d.ts} +0 -0
package/README.md CHANGED
@@ -23,10 +23,6 @@
23
23
 
24
24
 
25
25
 
26
- <blockquote style="color: #ff8811">
27
- <b>⚠ Warning:</b> This is a pre-release version of the library. It is not yet ready for production use. Please look at <a href="https://www.npmjs.com/package/@promptbook/core?activeTab=versions">latest stable release</a>.
28
- </blockquote>
29
-
30
26
  ## 📦 Package `@promptbook/cli`
31
27
 
32
28
  - Promptbooks are [divided into several](#-packages) packages, all are published from [single monorepo](https://github.com/webgptorg/promptbook).
package/esm/index.es.js CHANGED
@@ -39,7 +39,7 @@ var BOOK_LANGUAGE_VERSION = '1.0.0';
39
39
  * @generated
40
40
  * @see https://github.com/webgptorg/promptbook
41
41
  */
42
- var PROMPTBOOK_ENGINE_VERSION = '0.82.0-2';
42
+ var PROMPTBOOK_ENGINE_VERSION = '0.82.0';
43
43
  /**
44
44
  * TODO: string_promptbook_version should be constrained to the all versions of Promptbook engine
45
45
  * Note: [💞] Ignore a discrepancy between file name and entity name
@@ -6390,15 +6390,15 @@ function $registeredScrapersMessage(availableScrapers) {
6390
6390
  /**
6391
6391
  * Creates unique name for the source
6392
6392
  *
6393
- * @private within the repository
6393
+ * @public exported from `@promptbook/editable`
6394
6394
  */
6395
- function sourceContentToName(sourceContent) {
6396
- var hash = SHA256(hexEncoder.parse(JSON.stringify(sourceContent)))
6395
+ function knowledgeSourceContentToName(knowledgeSourceContent) {
6396
+ var hash = SHA256(hexEncoder.parse(JSON.stringify(knowledgeSourceContent)))
6397
6397
  // <- TODO: [🥬] Encapsulate sha256 to some private utility function
6398
6398
  .toString( /* hex */)
6399
6399
  .substring(0, 20);
6400
6400
  // <- TODO: [🥬] Make some system for hashes and ids of promptbook
6401
- var semanticName = normalizeToKebabCase(sourceContent.substring(0, 20));
6401
+ var semanticName = normalizeToKebabCase(knowledgeSourceContent.substring(0, 20));
6402
6402
  var pieces = ['source', semanticName, hash].filter(function (piece) { return piece !== ''; });
6403
6403
  var name = pieces.join('-').split('--').join('-');
6404
6404
  // <- TODO: Use MAX_FILENAME_LENGTH
@@ -6462,19 +6462,19 @@ var scraperFetch = function (url, init) { return __awaiter(void 0, void 0, void
6462
6462
  function makeKnowledgeSourceHandler(knowledgeSource, tools, options) {
6463
6463
  var _a;
6464
6464
  return __awaiter(this, void 0, void 0, function () {
6465
- var _b, fetch, sourceContent, name, _c, _d, rootDirname, url, response_1, mimeType, filename_1, fileExtension, mimeType;
6465
+ var _b, fetch, knowledgeSourceContent, name, _c, _d, rootDirname, url, response_1, mimeType, filename_1, fileExtension, mimeType;
6466
6466
  return __generator(this, function (_f) {
6467
6467
  switch (_f.label) {
6468
6468
  case 0:
6469
6469
  _b = tools.fetch, fetch = _b === void 0 ? scraperFetch : _b;
6470
- sourceContent = knowledgeSource.sourceContent;
6470
+ knowledgeSourceContent = knowledgeSource.knowledgeSourceContent;
6471
6471
  name = knowledgeSource.name;
6472
6472
  _c = options || {}, _d = _c.rootDirname, rootDirname = _d === void 0 ? null : _d, _c.isVerbose;
6473
6473
  if (!name) {
6474
- name = sourceContentToName(sourceContent);
6474
+ name = knowledgeSourceContentToName(knowledgeSourceContent);
6475
6475
  }
6476
- if (!isValidUrl(sourceContent)) return [3 /*break*/, 2];
6477
- url = sourceContent;
6476
+ if (!isValidUrl(knowledgeSourceContent)) return [3 /*break*/, 2];
6477
+ url = knowledgeSourceContent;
6478
6478
  return [4 /*yield*/, fetch(url)];
6479
6479
  case 1:
6480
6480
  response_1 = _f.sent();
@@ -6520,7 +6520,7 @@ function makeKnowledgeSourceHandler(knowledgeSource, tools, options) {
6520
6520
  },
6521
6521
  }];
6522
6522
  case 2:
6523
- if (!isValidFilePath(sourceContent)) return [3 /*break*/, 4];
6523
+ if (!isValidFilePath(knowledgeSourceContent)) return [3 /*break*/, 4];
6524
6524
  if (tools.fs === undefined) {
6525
6525
  throw new EnvironmentMismatchError('Can not import file knowledge without filesystem tools');
6526
6526
  // <- TODO: [🧠] What is the best error type here`
@@ -6529,13 +6529,13 @@ function makeKnowledgeSourceHandler(knowledgeSource, tools, options) {
6529
6529
  throw new EnvironmentMismatchError('Can not import file knowledge in non-file pipeline');
6530
6530
  // <- TODO: [🧠] What is the best error type here`
6531
6531
  }
6532
- filename_1 = join(rootDirname, sourceContent).split('\\').join('/');
6532
+ filename_1 = join(rootDirname, knowledgeSourceContent).split('\\').join('/');
6533
6533
  fileExtension = getFileExtension(filename_1);
6534
6534
  mimeType = extensionToMimeType(fileExtension || '');
6535
6535
  return [4 /*yield*/, isFileExisting(filename_1, tools.fs)];
6536
6536
  case 3:
6537
6537
  if (!(_f.sent())) {
6538
- throw new NotFoundError(spaceTrim(function (block) { return "\n Can not make source handler for file which does not exist:\n\n File:\n ".concat(block(sourceContent), "\n\n Full file path:\n ").concat(block(filename_1), "\n "); }));
6538
+ throw new NotFoundError(spaceTrim(function (block) { return "\n Can not make source handler for file which does not exist:\n\n File:\n ".concat(block(knowledgeSourceContent), "\n\n Full file path:\n ").concat(block(filename_1), "\n "); }));
6539
6539
  }
6540
6540
  // TODO: [🧠][😿] Test security file - file is scoped to the project (BUT maybe do this in `filesystemTools`)
6541
6541
  return [2 /*return*/, {
@@ -6586,7 +6586,7 @@ function makeKnowledgeSourceHandler(knowledgeSource, tools, options) {
6586
6586
  url: null,
6587
6587
  mimeType: 'text/markdown',
6588
6588
  asText: function () {
6589
- return knowledgeSource.sourceContent;
6589
+ return knowledgeSource.knowledgeSourceContent;
6590
6590
  },
6591
6591
  asJson: function () {
6592
6592
  throw new UnexpectedError('Did not expect that `markdownScraper` would need to get the content `asJson`');
@@ -6648,7 +6648,7 @@ function prepareKnowledgePieces(knowledgeSources, tools, options) {
6648
6648
  partialPieces = __spreadArray([], __read(partialPiecesUnchecked), false);
6649
6649
  return [2 /*return*/, "break"];
6650
6650
  }
6651
- console.warn(spaceTrim(function (block) { return "\n Cannot scrape knowledge from source despite the scraper `".concat(scraper.metadata.className, "` supports the mime type \"").concat(sourceHandler.mimeType, "\".\n\n The source:\n ").concat(block(knowledgeSource.sourceContent
6651
+ console.warn(spaceTrim(function (block) { return "\n Cannot scrape knowledge from source despite the scraper `".concat(scraper.metadata.className, "` supports the mime type \"").concat(sourceHandler.mimeType, "\".\n\n The source:\n ").concat(block(knowledgeSource.knowledgeSourceContent
6652
6652
  .split('\n')
6653
6653
  .map(function (line) { return "> ".concat(line); })
6654
6654
  .join('\n')), "\n\n ").concat(block($registeredScrapersMessage(scrapers)), "\n\n\n "); }));
@@ -6686,7 +6686,7 @@ function prepareKnowledgePieces(knowledgeSources, tools, options) {
6686
6686
  return [7 /*endfinally*/];
6687
6687
  case 9:
6688
6688
  if (partialPieces === null) {
6689
- throw new KnowledgeScrapeError(spaceTrim(function (block) { return "\n Cannot scrape knowledge\n\n The source:\n > ".concat(block(knowledgeSource.sourceContent
6689
+ throw new KnowledgeScrapeError(spaceTrim(function (block) { return "\n Cannot scrape knowledge\n\n The source:\n > ".concat(block(knowledgeSource.knowledgeSourceContent
6690
6690
  .split('\n')
6691
6691
  .map(function (line) { return "> ".concat(line); })
6692
6692
  .join('\n')), "\n\n No scraper found for the mime type \"").concat(sourceHandler.mimeType, "\"\n\n ").concat(block($registeredScrapersMessage(scrapers)), "\n\n\n "); }));
@@ -6957,7 +6957,7 @@ var SectionTypes = __spreadArray(__spreadArray([], __read(TaskTypes.map(function
6957
6957
  * Parses the knowledge command
6958
6958
  *
6959
6959
  * @see `documentationUrl` for more details
6960
- * @private within the commands folder
6960
+ * @public exported from `@promptbook/editable`
6961
6961
  */
6962
6962
  var knowledgeCommandParser = {
6963
6963
  /**
@@ -6993,23 +6993,25 @@ var knowledgeCommandParser = {
6993
6993
  */
6994
6994
  parse: function (input) {
6995
6995
  var args = input.args;
6996
- var sourceContent = spaceTrim(args[0] || '');
6997
- if (sourceContent === '') {
6996
+ var knowledgeSourceContent = spaceTrim(args[0] || '');
6997
+ if (knowledgeSourceContent === '') {
6998
6998
  throw new ParseError("Source is not defined");
6999
6999
  }
7000
7000
  // TODO: [main] !!4 Following checks should be applied every link in the `sourceContent`
7001
- if (sourceContent.startsWith('http://')) {
7001
+ if (knowledgeSourceContent.startsWith('http://')) {
7002
7002
  throw new ParseError("Source is not secure");
7003
7003
  }
7004
- if (!(isValidFilePath(sourceContent) || isValidUrl(sourceContent))) {
7004
+ if (!(isValidFilePath(knowledgeSourceContent) || isValidUrl(knowledgeSourceContent))) {
7005
7005
  throw new ParseError("Source not valid");
7006
7006
  }
7007
- if (sourceContent.startsWith('../') || sourceContent.startsWith('/') || /^[A-Z]:[\\/]+/i.test(sourceContent)) {
7007
+ if (knowledgeSourceContent.startsWith('../') ||
7008
+ knowledgeSourceContent.startsWith('/') ||
7009
+ /^[A-Z]:[\\/]+/i.test(knowledgeSourceContent)) {
7008
7010
  throw new ParseError("Source cannot be outside of the .book.md folder");
7009
7011
  }
7010
7012
  return {
7011
7013
  type: 'KNOWLEDGE',
7012
- sourceContent: sourceContent,
7014
+ knowledgeSourceContent: knowledgeSourceContent,
7013
7015
  };
7014
7016
  },
7015
7017
  /**
@@ -7018,10 +7020,10 @@ var knowledgeCommandParser = {
7018
7020
  * Note: `$` is used to indicate that this function mutates given `pipelineJson`
7019
7021
  */
7020
7022
  $applyToPipelineJson: function (command, $pipelineJson) {
7021
- var sourceContent = command.sourceContent;
7023
+ var knowledgeSourceContent = command.knowledgeSourceContent;
7022
7024
  $pipelineJson.knowledgeSources.push({
7023
- name: sourceContentToName(sourceContent),
7024
- sourceContent: sourceContent,
7025
+ name: knowledgeSourceContentToName(knowledgeSourceContent),
7026
+ knowledgeSourceContent: knowledgeSourceContent,
7025
7027
  });
7026
7028
  },
7027
7029
  /**
@@ -7049,7 +7051,7 @@ var knowledgeCommandParser = {
7049
7051
  * Parses the section command
7050
7052
  *
7051
7053
  * @see `documentationUrl` for more details
7052
- * @private within the commands folder
7054
+ * @public exported from `@promptbook/editable`
7053
7055
  */
7054
7056
  var sectionCommandParser = {
7055
7057
  /**
@@ -7180,7 +7182,7 @@ var sectionCommandParser = {
7180
7182
  if (command.taskType === 'KNOWLEDGE') {
7181
7183
  knowledgeCommandParser.$applyToPipelineJson({
7182
7184
  type: 'KNOWLEDGE',
7183
- sourceContent: $taskJson.content, // <- TODO: [🐝][main] !!3 Work with KNOWLEDGE which not referring to the source file or website, but its content itself
7185
+ knowledgeSourceContent: $taskJson.content, // <- TODO: [🐝][main] !!3 Work with KNOWLEDGE which not referring to the source file or website, but its content itself
7184
7186
  }, $pipelineJson);
7185
7187
  $taskJson.isTask = false;
7186
7188
  return;
@@ -7325,7 +7327,7 @@ var boilerplateCommandParser = {
7325
7327
  * Parses the BOOK_VERSION command
7326
7328
  *
7327
7329
  * @see `documentationUrl` for more details
7328
- * @private within the commands folder
7330
+ * @public exported from `@promptbook/editable`
7329
7331
  */
7330
7332
  var bookVersionCommandParser = {
7331
7333
  /**
@@ -7480,7 +7482,7 @@ function parseNumber(value) {
7480
7482
  * Parses the expect command
7481
7483
  *
7482
7484
  * @see `documentationUrl` for more details
7483
- * @private within the commands folder
7485
+ * @public exported from `@promptbook/editable`
7484
7486
  */
7485
7487
  var expectCommandParser = {
7486
7488
  /**
@@ -7796,7 +7798,7 @@ function validateParameterName(parameterName) {
7796
7798
  * Note: @@@ This command is used as foreach for new commands - it should NOT be used in any `.book.md` file
7797
7799
  *
7798
7800
  * @see `documentationUrl` for more details
7799
- * @private within the commands folder
7801
+ * @public exported from `@promptbook/editable`
7800
7802
  */
7801
7803
  var foreachCommandParser = {
7802
7804
  /**
@@ -7950,7 +7952,7 @@ var foreachCommandParser = {
7950
7952
  * Parses the format command
7951
7953
  *
7952
7954
  * @see `documentationUrl` for more details
7953
- * @private within the commands folder
7955
+ * @public exported from `@promptbook/editable`
7954
7956
  */
7955
7957
  var formatCommandParser = {
7956
7958
  /**
@@ -8247,7 +8249,7 @@ var FORMFACTOR_DEFINITIONS = [
8247
8249
  * Note: @@@ This command is used as formfactor for new commands - it should NOT be used in any `.book.md` file
8248
8250
  *
8249
8251
  * @see `documentationUrl` for more details
8250
- * @private within the commands folder
8252
+ * @public exported from `@promptbook/editable`
8251
8253
  */
8252
8254
  var formfactorCommandParser = {
8253
8255
  /**
@@ -8336,7 +8338,7 @@ var formfactorCommandParser = {
8336
8338
  * Parses the joker command
8337
8339
  *
8338
8340
  * @see `documentationUrl` for more details
8339
- * @private within the commands folder
8341
+ * @public exported from `@promptbook/editable`
8340
8342
  */
8341
8343
  var jokerCommandParser = {
8342
8344
  /**
@@ -8413,7 +8415,8 @@ var MODEL_VARIANTS = ['COMPLETION', 'CHAT', 'EMBEDDING' /* <- TODO [🏳] */ /*
8413
8415
  * Parses the model command
8414
8416
  *
8415
8417
  * @see `documentationUrl` for more details
8416
- * @private within the commands folder
8418
+ * @deprecated Option to manually set the model requirements is not recommended to use, use `PERSONA` instead
8419
+ * @public exported from `@promptbook/editable`
8417
8420
  */
8418
8421
  var modelCommandParser = {
8419
8422
  /**
@@ -8557,7 +8560,7 @@ var modelCommandParser = {
8557
8560
  * Parses the parameter command
8558
8561
  *
8559
8562
  * @see `documentationUrl` for more details
8560
- * @private within the commands folder
8563
+ * @public exported from `@promptbook/editable`
8561
8564
  */
8562
8565
  var parameterCommandParser = {
8563
8566
  /**
@@ -8662,7 +8665,7 @@ var parameterCommandParser = {
8662
8665
  * Parses the persona command
8663
8666
  *
8664
8667
  * @see `documentationUrl` for more details
8665
- * @private within the commands folder
8668
+ * @public exported from `@promptbook/editable`
8666
8669
  */
8667
8670
  var personaCommandParser = {
8668
8671
  /**
@@ -8797,7 +8800,7 @@ function isValidJavascriptName(javascriptName) {
8797
8800
  * Parses the postprocess command
8798
8801
  *
8799
8802
  * @see `documentationUrl` for more details
8800
- * @private within the commands folder
8803
+ * @public exported from `@promptbook/editable`
8801
8804
  */
8802
8805
  var postprocessCommandParser = {
8803
8806
  /**
@@ -8875,7 +8878,7 @@ var postprocessCommandParser = {
8875
8878
  * Parses the url command
8876
8879
  *
8877
8880
  * @see `documentationUrl` for more details
8878
- * @private within the commands folder
8881
+ * @public exported from `@promptbook/editable`
8879
8882
  */
8880
8883
  var urlCommandParser = {
8881
8884
  /**
@@ -8976,7 +8979,7 @@ var urlCommandParser = {
8976
8979
  * Parses the action command
8977
8980
  *
8978
8981
  * @see `documentationUrl` for more details
8979
- * @private within the commands folder
8982
+ * @public exported from `@promptbook/editable`
8980
8983
  */
8981
8984
  var actionCommandParser = {
8982
8985
  /**
@@ -9042,7 +9045,7 @@ var actionCommandParser = {
9042
9045
  * Parses the instrument command
9043
9046
  *
9044
9047
  * @see `documentationUrl` for more details
9045
- * @private within the commands folder
9048
+ * @public exported from `@promptbook/editable`
9046
9049
  */
9047
9050
  var instrumentCommandParser = {
9048
9051
  /**
@@ -9107,7 +9110,7 @@ var instrumentCommandParser = {
9107
9110
  /**
9108
9111
  * All available command parsers
9109
9112
  *
9110
- * @private internal index of `parseCommand`
9113
+ * @public exported from `@promptbook/editable`
9111
9114
  */
9112
9115
  var COMMANDS = [
9113
9116
  sectionCommandParser,
@@ -9138,7 +9141,7 @@ var COMMANDS = [
9138
9141
  * @returns the parser for the command
9139
9142
  * @throws {UnexpectedError} if the parser is not found
9140
9143
  *
9141
- * @private within the compilePipeline
9144
+ * @public exported from `@promptbook/editable`
9142
9145
  */
9143
9146
  function getParserForCommand(command) {
9144
9147
  var commandParser = COMMANDS.find(function (commandParser) { return commandParser.name === command.type; });
@@ -9174,7 +9177,7 @@ function removeMarkdownFormatting(str) {
9174
9177
  * @returns parsed command object
9175
9178
  * @throws {ParseError} if the command is invalid
9176
9179
  *
9177
- * @private within the compilePipeline
9180
+ * @public exported from `@promptbook/editable`
9178
9181
  */
9179
9182
  function parseCommand(raw, usagePlace) {
9180
9183
  if (raw.includes('\n') || raw.includes('\r')) {