@promptbook/cli 0.82.0 → 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 (44) hide show
  1. package/esm/index.es.js +47 -44
  2. package/esm/index.es.js.map +1 -1
  3. package/esm/typings/src/_packages/editable.index.d.ts +74 -0
  4. package/esm/typings/src/_packages/types.index.d.ts +26 -0
  5. package/esm/typings/src/commands/BOOK_VERSION/BookVersionCommand.d.ts +1 -1
  6. package/esm/typings/src/commands/BOOK_VERSION/bookVersionCommandParser.d.ts +1 -1
  7. package/esm/typings/src/commands/EXPECT/expectCommandParser.d.ts +1 -1
  8. package/esm/typings/src/commands/FOREACH/ForeachCommand.d.ts +1 -1
  9. package/esm/typings/src/commands/FOREACH/foreachCommandParser.d.ts +1 -1
  10. package/esm/typings/src/commands/FORMAT/formatCommandParser.d.ts +1 -1
  11. package/esm/typings/src/commands/FORMFACTOR/FormfactorCommand.d.ts +1 -1
  12. package/esm/typings/src/commands/FORMFACTOR/formfactorCommandParser.d.ts +1 -1
  13. package/esm/typings/src/commands/JOKER/JokerCommand.d.ts +1 -1
  14. package/esm/typings/src/commands/JOKER/jokerCommandParser.d.ts +1 -1
  15. package/esm/typings/src/commands/KNOWLEDGE/KnowledgeCommand.d.ts +2 -2
  16. package/esm/typings/src/commands/KNOWLEDGE/knowledgeCommandParser.d.ts +1 -1
  17. package/esm/typings/src/commands/KNOWLEDGE/utils/{sourceContentToName.d.ts → knowledgeSourceContentToName.d.ts} +2 -2
  18. package/esm/typings/src/commands/MODEL/ModelCommand.d.ts +2 -1
  19. package/esm/typings/src/commands/MODEL/modelCommandParser.d.ts +2 -1
  20. package/esm/typings/src/commands/PARAMETER/ParameterCommand.d.ts +1 -1
  21. package/esm/typings/src/commands/PARAMETER/parameterCommandParser.d.ts +1 -1
  22. package/esm/typings/src/commands/PERSONA/PersonaCommand.d.ts +1 -1
  23. package/esm/typings/src/commands/PERSONA/personaCommandParser.d.ts +1 -1
  24. package/esm/typings/src/commands/POSTPROCESS/PostprocessCommand.d.ts +1 -1
  25. package/esm/typings/src/commands/POSTPROCESS/postprocessCommandParser.d.ts +1 -1
  26. package/esm/typings/src/commands/SECTION/SectionCommand.d.ts +1 -1
  27. package/esm/typings/src/commands/SECTION/sectionCommandParser.d.ts +1 -1
  28. package/esm/typings/src/commands/URL/UrlCommand.d.ts +1 -1
  29. package/esm/typings/src/commands/URL/urlCommandParser.d.ts +1 -1
  30. package/esm/typings/src/commands/X_ACTION/ActionCommand.d.ts +1 -1
  31. package/esm/typings/src/commands/X_ACTION/actionCommandParser.d.ts +1 -1
  32. package/esm/typings/src/commands/X_INSTRUMENT/InstrumentCommand.d.ts +1 -1
  33. package/esm/typings/src/commands/X_INSTRUMENT/instrumentCommandParser.d.ts +1 -1
  34. package/esm/typings/src/commands/_common/getParserForCommand.d.ts +1 -1
  35. package/esm/typings/src/commands/_common/parseCommand.d.ts +1 -1
  36. package/esm/typings/src/commands/_common/stringifyCommand.d.ts +1 -0
  37. package/esm/typings/src/commands/_common/types/CommandParser.d.ts +8 -0
  38. package/esm/typings/src/commands/_common/types/CommandUsagePlaces.d.ts +2 -0
  39. package/esm/typings/src/commands/index.d.ts +1 -1
  40. package/esm/typings/src/pipeline/PipelineJson/KnowledgeSourceJson.d.ts +1 -1
  41. package/package.json +1 -1
  42. package/umd/index.umd.js +47 -44
  43. package/umd/index.umd.js.map +1 -1
  44. /package/esm/typings/src/commands/KNOWLEDGE/utils/{sourceContentToName.test.d.ts → knowledgeSourceContentToName.test.d.ts} +0 -0
package/umd/index.umd.js CHANGED
@@ -51,7 +51,7 @@
51
51
  * @generated
52
52
  * @see https://github.com/webgptorg/promptbook
53
53
  */
54
- var PROMPTBOOK_ENGINE_VERSION = '0.82.0-3';
54
+ var PROMPTBOOK_ENGINE_VERSION = '0.82.0';
55
55
  /**
56
56
  * TODO: string_promptbook_version should be constrained to the all versions of Promptbook engine
57
57
  * Note: [💞] Ignore a discrepancy between file name and entity name
@@ -6402,15 +6402,15 @@
6402
6402
  /**
6403
6403
  * Creates unique name for the source
6404
6404
  *
6405
- * @private within the repository
6405
+ * @public exported from `@promptbook/editable`
6406
6406
  */
6407
- function sourceContentToName(sourceContent) {
6408
- var hash = cryptoJs.SHA256(hexEncoder__default["default"].parse(JSON.stringify(sourceContent)))
6407
+ function knowledgeSourceContentToName(knowledgeSourceContent) {
6408
+ var hash = cryptoJs.SHA256(hexEncoder__default["default"].parse(JSON.stringify(knowledgeSourceContent)))
6409
6409
  // <- TODO: [🥬] Encapsulate sha256 to some private utility function
6410
6410
  .toString( /* hex */)
6411
6411
  .substring(0, 20);
6412
6412
  // <- TODO: [🥬] Make some system for hashes and ids of promptbook
6413
- var semanticName = normalizeToKebabCase(sourceContent.substring(0, 20));
6413
+ var semanticName = normalizeToKebabCase(knowledgeSourceContent.substring(0, 20));
6414
6414
  var pieces = ['source', semanticName, hash].filter(function (piece) { return piece !== ''; });
6415
6415
  var name = pieces.join('-').split('--').join('-');
6416
6416
  // <- TODO: Use MAX_FILENAME_LENGTH
@@ -6474,19 +6474,19 @@
6474
6474
  function makeKnowledgeSourceHandler(knowledgeSource, tools, options) {
6475
6475
  var _a;
6476
6476
  return __awaiter(this, void 0, void 0, function () {
6477
- var _b, fetch, sourceContent, name, _c, _d, rootDirname, url, response_1, mimeType, filename_1, fileExtension, mimeType;
6477
+ var _b, fetch, knowledgeSourceContent, name, _c, _d, rootDirname, url, response_1, mimeType, filename_1, fileExtension, mimeType;
6478
6478
  return __generator(this, function (_f) {
6479
6479
  switch (_f.label) {
6480
6480
  case 0:
6481
6481
  _b = tools.fetch, fetch = _b === void 0 ? scraperFetch : _b;
6482
- sourceContent = knowledgeSource.sourceContent;
6482
+ knowledgeSourceContent = knowledgeSource.knowledgeSourceContent;
6483
6483
  name = knowledgeSource.name;
6484
6484
  _c = options || {}, _d = _c.rootDirname, rootDirname = _d === void 0 ? null : _d, _c.isVerbose;
6485
6485
  if (!name) {
6486
- name = sourceContentToName(sourceContent);
6486
+ name = knowledgeSourceContentToName(knowledgeSourceContent);
6487
6487
  }
6488
- if (!isValidUrl(sourceContent)) return [3 /*break*/, 2];
6489
- url = sourceContent;
6488
+ if (!isValidUrl(knowledgeSourceContent)) return [3 /*break*/, 2];
6489
+ url = knowledgeSourceContent;
6490
6490
  return [4 /*yield*/, fetch(url)];
6491
6491
  case 1:
6492
6492
  response_1 = _f.sent();
@@ -6532,7 +6532,7 @@
6532
6532
  },
6533
6533
  }];
6534
6534
  case 2:
6535
- if (!isValidFilePath(sourceContent)) return [3 /*break*/, 4];
6535
+ if (!isValidFilePath(knowledgeSourceContent)) return [3 /*break*/, 4];
6536
6536
  if (tools.fs === undefined) {
6537
6537
  throw new EnvironmentMismatchError('Can not import file knowledge without filesystem tools');
6538
6538
  // <- TODO: [🧠] What is the best error type here`
@@ -6541,13 +6541,13 @@
6541
6541
  throw new EnvironmentMismatchError('Can not import file knowledge in non-file pipeline');
6542
6542
  // <- TODO: [🧠] What is the best error type here`
6543
6543
  }
6544
- filename_1 = path.join(rootDirname, sourceContent).split('\\').join('/');
6544
+ filename_1 = path.join(rootDirname, knowledgeSourceContent).split('\\').join('/');
6545
6545
  fileExtension = getFileExtension(filename_1);
6546
6546
  mimeType = extensionToMimeType(fileExtension || '');
6547
6547
  return [4 /*yield*/, isFileExisting(filename_1, tools.fs)];
6548
6548
  case 3:
6549
6549
  if (!(_f.sent())) {
6550
- throw new NotFoundError(spaceTrim__default["default"](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 "); }));
6550
+ throw new NotFoundError(spaceTrim__default["default"](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 "); }));
6551
6551
  }
6552
6552
  // TODO: [🧠][😿] Test security file - file is scoped to the project (BUT maybe do this in `filesystemTools`)
6553
6553
  return [2 /*return*/, {
@@ -6598,7 +6598,7 @@
6598
6598
  url: null,
6599
6599
  mimeType: 'text/markdown',
6600
6600
  asText: function () {
6601
- return knowledgeSource.sourceContent;
6601
+ return knowledgeSource.knowledgeSourceContent;
6602
6602
  },
6603
6603
  asJson: function () {
6604
6604
  throw new UnexpectedError('Did not expect that `markdownScraper` would need to get the content `asJson`');
@@ -6660,7 +6660,7 @@
6660
6660
  partialPieces = __spreadArray([], __read(partialPiecesUnchecked), false);
6661
6661
  return [2 /*return*/, "break"];
6662
6662
  }
6663
- console.warn(spaceTrim__default["default"](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
6663
+ console.warn(spaceTrim__default["default"](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
6664
6664
  .split('\n')
6665
6665
  .map(function (line) { return "> ".concat(line); })
6666
6666
  .join('\n')), "\n\n ").concat(block($registeredScrapersMessage(scrapers)), "\n\n\n "); }));
@@ -6698,7 +6698,7 @@
6698
6698
  return [7 /*endfinally*/];
6699
6699
  case 9:
6700
6700
  if (partialPieces === null) {
6701
- throw new KnowledgeScrapeError(spaceTrim__default["default"](function (block) { return "\n Cannot scrape knowledge\n\n The source:\n > ".concat(block(knowledgeSource.sourceContent
6701
+ throw new KnowledgeScrapeError(spaceTrim__default["default"](function (block) { return "\n Cannot scrape knowledge\n\n The source:\n > ".concat(block(knowledgeSource.knowledgeSourceContent
6702
6702
  .split('\n')
6703
6703
  .map(function (line) { return "> ".concat(line); })
6704
6704
  .join('\n')), "\n\n No scraper found for the mime type \"").concat(sourceHandler.mimeType, "\"\n\n ").concat(block($registeredScrapersMessage(scrapers)), "\n\n\n "); }));
@@ -6969,7 +6969,7 @@
6969
6969
  * Parses the knowledge command
6970
6970
  *
6971
6971
  * @see `documentationUrl` for more details
6972
- * @private within the commands folder
6972
+ * @public exported from `@promptbook/editable`
6973
6973
  */
6974
6974
  var knowledgeCommandParser = {
6975
6975
  /**
@@ -7005,23 +7005,25 @@
7005
7005
  */
7006
7006
  parse: function (input) {
7007
7007
  var args = input.args;
7008
- var sourceContent = spaceTrim__default["default"](args[0] || '');
7009
- if (sourceContent === '') {
7008
+ var knowledgeSourceContent = spaceTrim__default["default"](args[0] || '');
7009
+ if (knowledgeSourceContent === '') {
7010
7010
  throw new ParseError("Source is not defined");
7011
7011
  }
7012
7012
  // TODO: [main] !!4 Following checks should be applied every link in the `sourceContent`
7013
- if (sourceContent.startsWith('http://')) {
7013
+ if (knowledgeSourceContent.startsWith('http://')) {
7014
7014
  throw new ParseError("Source is not secure");
7015
7015
  }
7016
- if (!(isValidFilePath(sourceContent) || isValidUrl(sourceContent))) {
7016
+ if (!(isValidFilePath(knowledgeSourceContent) || isValidUrl(knowledgeSourceContent))) {
7017
7017
  throw new ParseError("Source not valid");
7018
7018
  }
7019
- if (sourceContent.startsWith('../') || sourceContent.startsWith('/') || /^[A-Z]:[\\/]+/i.test(sourceContent)) {
7019
+ if (knowledgeSourceContent.startsWith('../') ||
7020
+ knowledgeSourceContent.startsWith('/') ||
7021
+ /^[A-Z]:[\\/]+/i.test(knowledgeSourceContent)) {
7020
7022
  throw new ParseError("Source cannot be outside of the .book.md folder");
7021
7023
  }
7022
7024
  return {
7023
7025
  type: 'KNOWLEDGE',
7024
- sourceContent: sourceContent,
7026
+ knowledgeSourceContent: knowledgeSourceContent,
7025
7027
  };
7026
7028
  },
7027
7029
  /**
@@ -7030,10 +7032,10 @@
7030
7032
  * Note: `$` is used to indicate that this function mutates given `pipelineJson`
7031
7033
  */
7032
7034
  $applyToPipelineJson: function (command, $pipelineJson) {
7033
- var sourceContent = command.sourceContent;
7035
+ var knowledgeSourceContent = command.knowledgeSourceContent;
7034
7036
  $pipelineJson.knowledgeSources.push({
7035
- name: sourceContentToName(sourceContent),
7036
- sourceContent: sourceContent,
7037
+ name: knowledgeSourceContentToName(knowledgeSourceContent),
7038
+ knowledgeSourceContent: knowledgeSourceContent,
7037
7039
  });
7038
7040
  },
7039
7041
  /**
@@ -7061,7 +7063,7 @@
7061
7063
  * Parses the section command
7062
7064
  *
7063
7065
  * @see `documentationUrl` for more details
7064
- * @private within the commands folder
7066
+ * @public exported from `@promptbook/editable`
7065
7067
  */
7066
7068
  var sectionCommandParser = {
7067
7069
  /**
@@ -7192,7 +7194,7 @@
7192
7194
  if (command.taskType === 'KNOWLEDGE') {
7193
7195
  knowledgeCommandParser.$applyToPipelineJson({
7194
7196
  type: 'KNOWLEDGE',
7195
- sourceContent: $taskJson.content, // <- TODO: [🐝][main] !!3 Work with KNOWLEDGE which not referring to the source file or website, but its content itself
7197
+ knowledgeSourceContent: $taskJson.content, // <- TODO: [🐝][main] !!3 Work with KNOWLEDGE which not referring to the source file or website, but its content itself
7196
7198
  }, $pipelineJson);
7197
7199
  $taskJson.isTask = false;
7198
7200
  return;
@@ -7337,7 +7339,7 @@
7337
7339
  * Parses the BOOK_VERSION command
7338
7340
  *
7339
7341
  * @see `documentationUrl` for more details
7340
- * @private within the commands folder
7342
+ * @public exported from `@promptbook/editable`
7341
7343
  */
7342
7344
  var bookVersionCommandParser = {
7343
7345
  /**
@@ -7492,7 +7494,7 @@
7492
7494
  * Parses the expect command
7493
7495
  *
7494
7496
  * @see `documentationUrl` for more details
7495
- * @private within the commands folder
7497
+ * @public exported from `@promptbook/editable`
7496
7498
  */
7497
7499
  var expectCommandParser = {
7498
7500
  /**
@@ -7808,7 +7810,7 @@
7808
7810
  * Note: @@@ This command is used as foreach for new commands - it should NOT be used in any `.book.md` file
7809
7811
  *
7810
7812
  * @see `documentationUrl` for more details
7811
- * @private within the commands folder
7813
+ * @public exported from `@promptbook/editable`
7812
7814
  */
7813
7815
  var foreachCommandParser = {
7814
7816
  /**
@@ -7962,7 +7964,7 @@
7962
7964
  * Parses the format command
7963
7965
  *
7964
7966
  * @see `documentationUrl` for more details
7965
- * @private within the commands folder
7967
+ * @public exported from `@promptbook/editable`
7966
7968
  */
7967
7969
  var formatCommandParser = {
7968
7970
  /**
@@ -8259,7 +8261,7 @@
8259
8261
  * Note: @@@ This command is used as formfactor for new commands - it should NOT be used in any `.book.md` file
8260
8262
  *
8261
8263
  * @see `documentationUrl` for more details
8262
- * @private within the commands folder
8264
+ * @public exported from `@promptbook/editable`
8263
8265
  */
8264
8266
  var formfactorCommandParser = {
8265
8267
  /**
@@ -8348,7 +8350,7 @@
8348
8350
  * Parses the joker command
8349
8351
  *
8350
8352
  * @see `documentationUrl` for more details
8351
- * @private within the commands folder
8353
+ * @public exported from `@promptbook/editable`
8352
8354
  */
8353
8355
  var jokerCommandParser = {
8354
8356
  /**
@@ -8425,7 +8427,8 @@
8425
8427
  * Parses the model command
8426
8428
  *
8427
8429
  * @see `documentationUrl` for more details
8428
- * @private within the commands folder
8430
+ * @deprecated Option to manually set the model requirements is not recommended to use, use `PERSONA` instead
8431
+ * @public exported from `@promptbook/editable`
8429
8432
  */
8430
8433
  var modelCommandParser = {
8431
8434
  /**
@@ -8569,7 +8572,7 @@
8569
8572
  * Parses the parameter command
8570
8573
  *
8571
8574
  * @see `documentationUrl` for more details
8572
- * @private within the commands folder
8575
+ * @public exported from `@promptbook/editable`
8573
8576
  */
8574
8577
  var parameterCommandParser = {
8575
8578
  /**
@@ -8674,7 +8677,7 @@
8674
8677
  * Parses the persona command
8675
8678
  *
8676
8679
  * @see `documentationUrl` for more details
8677
- * @private within the commands folder
8680
+ * @public exported from `@promptbook/editable`
8678
8681
  */
8679
8682
  var personaCommandParser = {
8680
8683
  /**
@@ -8809,7 +8812,7 @@
8809
8812
  * Parses the postprocess command
8810
8813
  *
8811
8814
  * @see `documentationUrl` for more details
8812
- * @private within the commands folder
8815
+ * @public exported from `@promptbook/editable`
8813
8816
  */
8814
8817
  var postprocessCommandParser = {
8815
8818
  /**
@@ -8887,7 +8890,7 @@
8887
8890
  * Parses the url command
8888
8891
  *
8889
8892
  * @see `documentationUrl` for more details
8890
- * @private within the commands folder
8893
+ * @public exported from `@promptbook/editable`
8891
8894
  */
8892
8895
  var urlCommandParser = {
8893
8896
  /**
@@ -8988,7 +8991,7 @@
8988
8991
  * Parses the action command
8989
8992
  *
8990
8993
  * @see `documentationUrl` for more details
8991
- * @private within the commands folder
8994
+ * @public exported from `@promptbook/editable`
8992
8995
  */
8993
8996
  var actionCommandParser = {
8994
8997
  /**
@@ -9054,7 +9057,7 @@
9054
9057
  * Parses the instrument command
9055
9058
  *
9056
9059
  * @see `documentationUrl` for more details
9057
- * @private within the commands folder
9060
+ * @public exported from `@promptbook/editable`
9058
9061
  */
9059
9062
  var instrumentCommandParser = {
9060
9063
  /**
@@ -9119,7 +9122,7 @@
9119
9122
  /**
9120
9123
  * All available command parsers
9121
9124
  *
9122
- * @private internal index of `parseCommand`
9125
+ * @public exported from `@promptbook/editable`
9123
9126
  */
9124
9127
  var COMMANDS = [
9125
9128
  sectionCommandParser,
@@ -9150,7 +9153,7 @@
9150
9153
  * @returns the parser for the command
9151
9154
  * @throws {UnexpectedError} if the parser is not found
9152
9155
  *
9153
- * @private within the compilePipeline
9156
+ * @public exported from `@promptbook/editable`
9154
9157
  */
9155
9158
  function getParserForCommand(command) {
9156
9159
  var commandParser = COMMANDS.find(function (commandParser) { return commandParser.name === command.type; });
@@ -9186,7 +9189,7 @@
9186
9189
  * @returns parsed command object
9187
9190
  * @throws {ParseError} if the command is invalid
9188
9191
  *
9189
- * @private within the compilePipeline
9192
+ * @public exported from `@promptbook/editable`
9190
9193
  */
9191
9194
  function parseCommand(raw, usagePlace) {
9192
9195
  if (raw.includes('\n') || raw.includes('\r')) {