@promptbook/cli 0.44.0-9 → 0.45.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 (58) hide show
  1. package/README.md +751 -2
  2. package/esm/index.es.js +2 -2
  3. package/esm/index.es.js.map +1 -1
  4. package/esm/typings/_packages/utils.index.d.ts +4 -2
  5. package/esm/typings/conversion/promptbookStringToJson.d.ts +2 -2
  6. package/esm/typings/execution/ExecutionTools.d.ts +3 -3
  7. package/esm/typings/execution/NaturalExecutionTools.d.ts +2 -2
  8. package/esm/typings/execution/ScriptExecutionTools.d.ts +2 -2
  9. package/esm/typings/execution/UserInterfaceTools.d.ts +1 -1
  10. package/esm/typings/execution/plugins/natural-execution-tools/langtail/LangtailExecutionTools.d.ts +10 -0
  11. package/esm/typings/execution/plugins/natural-execution-tools/mocked/fakeTextToExpectations.d.ts +6 -2
  12. package/esm/typings/execution/plugins/natural-execution-tools/openai/OpenAiExecutionTools.d.ts +5 -0
  13. package/esm/typings/execution/plugins/natural-execution-tools/openai/OpenAiExecutionToolsOptions.d.ts +7 -7
  14. package/esm/typings/execution/plugins/natural-execution-tools/remote/RemoteNaturalExecutionToolsOptions.d.ts +1 -1
  15. package/esm/typings/execution/plugins/script-execution-tools/javascript/JavascriptExecutionToolsOptions.d.ts +5 -1
  16. package/esm/typings/execution/plugins/script-execution-tools/javascript/utils/unknownToString.d.ts +7 -0
  17. package/esm/typings/execution/plugins/user-interface-execution-tools/callback/CallbackInterfaceToolsOptions.d.ts +3 -3
  18. package/esm/typings/execution/translation/automatic-translate/automatic-translators/AutomaticTranslator.d.ts +1 -1
  19. package/esm/typings/library/PromptbookLibrary.d.ts +1 -1
  20. package/esm/typings/types/ExecutionTypes.d.ts +1 -1
  21. package/esm/typings/types/ModelRequirements.d.ts +1 -1
  22. package/esm/typings/types/Prompt.d.ts +5 -0
  23. package/esm/typings/types/PromptbookJson/PromptTemplateJson.d.ts +6 -5
  24. package/esm/typings/types/PromptbookJson/PromptTemplateParameterJson.d.ts +1 -1
  25. package/esm/typings/types/PromptbookJson/PromptbookJson.d.ts +3 -3
  26. package/esm/typings/types/ScriptLanguage.d.ts +1 -1
  27. package/esm/typings/types/TaskProgress.d.ts +2 -2
  28. package/esm/typings/types/execution-report/ExecutionReportStringOptions.d.ts +1 -1
  29. package/esm/typings/utils/markdown/extractAllBlocksFromMarkdown.d.ts +1 -1
  30. package/package.json +4 -4
  31. package/umd/index.umd.js +35 -36
  32. package/umd/index.umd.js.map +1 -1
  33. package/umd/typings/_packages/utils.index.d.ts +4 -2
  34. package/umd/typings/conversion/promptbookStringToJson.d.ts +2 -2
  35. package/umd/typings/execution/ExecutionTools.d.ts +3 -3
  36. package/umd/typings/execution/NaturalExecutionTools.d.ts +2 -2
  37. package/umd/typings/execution/ScriptExecutionTools.d.ts +2 -2
  38. package/umd/typings/execution/UserInterfaceTools.d.ts +1 -1
  39. package/umd/typings/execution/plugins/natural-execution-tools/langtail/LangtailExecutionTools.d.ts +10 -0
  40. package/umd/typings/execution/plugins/natural-execution-tools/mocked/fakeTextToExpectations.d.ts +6 -2
  41. package/umd/typings/execution/plugins/natural-execution-tools/openai/OpenAiExecutionTools.d.ts +5 -0
  42. package/umd/typings/execution/plugins/natural-execution-tools/openai/OpenAiExecutionToolsOptions.d.ts +7 -7
  43. package/umd/typings/execution/plugins/natural-execution-tools/remote/RemoteNaturalExecutionToolsOptions.d.ts +1 -1
  44. package/umd/typings/execution/plugins/script-execution-tools/javascript/JavascriptExecutionToolsOptions.d.ts +5 -1
  45. package/umd/typings/execution/plugins/script-execution-tools/javascript/utils/unknownToString.d.ts +7 -0
  46. package/umd/typings/execution/plugins/user-interface-execution-tools/callback/CallbackInterfaceToolsOptions.d.ts +3 -3
  47. package/umd/typings/execution/translation/automatic-translate/automatic-translators/AutomaticTranslator.d.ts +1 -1
  48. package/umd/typings/library/PromptbookLibrary.d.ts +1 -1
  49. package/umd/typings/types/ExecutionTypes.d.ts +1 -1
  50. package/umd/typings/types/ModelRequirements.d.ts +1 -1
  51. package/umd/typings/types/Prompt.d.ts +5 -0
  52. package/umd/typings/types/PromptbookJson/PromptTemplateJson.d.ts +6 -5
  53. package/umd/typings/types/PromptbookJson/PromptTemplateParameterJson.d.ts +1 -1
  54. package/umd/typings/types/PromptbookJson/PromptbookJson.d.ts +3 -3
  55. package/umd/typings/types/ScriptLanguage.d.ts +1 -1
  56. package/umd/typings/types/TaskProgress.d.ts +2 -2
  57. package/umd/typings/types/execution-report/ExecutionReportStringOptions.d.ts +1 -1
  58. package/umd/typings/utils/markdown/extractAllBlocksFromMarkdown.d.ts +1 -1
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@promptbook/cli",
3
- "version": "0.44.0-9",
3
+ "version": "0.45.0",
4
4
  "description": "Library to supercharge your use of large language models",
5
5
  "private": false,
6
6
  "sideEffects": false,
@@ -28,7 +28,7 @@
28
28
  "text-generation",
29
29
  "language-model"
30
30
  ],
31
- "license": "SEE LICENSE IN LICENSE",
31
+ "license": "CC-BY-4.0",
32
32
  "bugs": {
33
33
  "url": "https://github.com/webgptorg/promptbook/issues"
34
34
  },
@@ -38,11 +38,11 @@
38
38
  "commander": "12.0.0",
39
39
  "glob-promise": "6.0.5",
40
40
  "prettier": "2.8.1",
41
- "spacetrim": "0.11.2",
41
+ "spacetrim": "0.11.20",
42
42
  "waitasecond": "1.11.33"
43
43
  },
44
44
  "peerDependencies": {
45
- "@promptbook/core": "0.44.0-9"
45
+ "@promptbook/core": "0.45.0"
46
46
  },
47
47
  "main": "./umd/index.umd.js",
48
48
  "module": "./esm/index.es.js",
package/umd/index.umd.js CHANGED
@@ -1,15 +1,14 @@
1
1
  (function (global, factory) {
2
2
  typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('colors'), require('commander'), require('fs/promises'), require('glob-promise'), require('spacetrim'), require('waitasecond'), require('prettier'), require('prettier/parser-html'), require('moment')) :
3
3
  typeof define === 'function' && define.amd ? define(['exports', 'colors', 'commander', 'fs/promises', 'glob-promise', 'spacetrim', 'waitasecond', 'prettier', 'prettier/parser-html', 'moment'], factory) :
4
- (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global["promptbook-cli"] = {}, global.colors, global.commander, global.promises, global.glob, global.spaceTrim, global.waitasecond, global.prettier, global.parserHtml));
5
- })(this, (function (exports, colors, commander, promises, glob, spaceTrim, waitasecond, prettier, parserHtml) { 'use strict';
4
+ (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global["promptbook-cli"] = {}, global.colors, global.commander, global.promises, global.glob, global.spacetrim, global.waitasecond, global.prettier, global.parserHtml));
5
+ })(this, (function (exports, colors, commander, promises, glob, spacetrim, waitasecond, prettier, parserHtml) { 'use strict';
6
6
 
7
7
  function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
8
8
 
9
9
  var colors__default = /*#__PURE__*/_interopDefaultLegacy(colors);
10
10
  var commander__default = /*#__PURE__*/_interopDefaultLegacy(commander);
11
11
  var glob__default = /*#__PURE__*/_interopDefaultLegacy(glob);
12
- var spaceTrim__default = /*#__PURE__*/_interopDefaultLegacy(spaceTrim);
13
12
  var parserHtml__default = /*#__PURE__*/_interopDefaultLegacy(parserHtml);
14
13
 
15
14
  /*! *****************************************************************************
@@ -147,7 +146,7 @@
147
146
  /**
148
147
  * The version of the Promptbook library
149
148
  */
150
- var PROMPTBOOK_VERSION = '0.44.0-8';
149
+ var PROMPTBOOK_VERSION = '0.44.0';
151
150
 
152
151
  /**
153
152
  * This error indicates that the promptbook in a markdown format cannot be parsed into a valid promptbook object
@@ -531,7 +530,7 @@
531
530
  var UnexpectedError = /** @class */ (function (_super) {
532
531
  __extends(UnexpectedError, _super);
533
532
  function UnexpectedError(message) {
534
- var _this = _super.call(this, spaceTrim__default["default"](function (block) { return "\n ".concat(block(message), "\n\n Note: This error should not happen.\n It's probbably a bug in the promptbook library\n\n Please report issue:\n https://github.com/webgptorg/promptbook/issues\n\n Or contact us on me@pavolhejny.com\n\n "); })) || this;
533
+ var _this = _super.call(this, spacetrim.spaceTrim(function (block) { return "\n ".concat(block(message), "\n\n Note: This error should not happen.\n It's probbably a bug in the promptbook library\n\n Please report issue:\n https://github.com/webgptorg/promptbook/issues\n\n Or contact us on me@pavolhejny.com\n\n "); })) || this;
535
534
  _this.name = 'UnexpectedError';
536
535
  Object.setPrototypeOf(_this, UnexpectedError.prototype);
537
536
  return _this;
@@ -706,7 +705,7 @@
706
705
  * @returns {string} The input string with all comments removed.
707
706
  */
708
707
  function removeContentComments(content) {
709
- return spaceTrim__default["default"](content.replace(/<!--(.*?)-->/gs, ''));
708
+ return spacetrim.spaceTrim(content.replace(/<!--(.*?)-->/gs, ''));
710
709
  }
711
710
 
712
711
  /**
@@ -953,7 +952,7 @@
953
952
  }
954
953
  if (parent_1.parent === null /* <- Note: We are in root */) {
955
954
  // [🌻]
956
- throw new Error(spaceTrim__default["default"]("\n The file has an invalid structure.\n The markdown file must have exactly one top-level section.\n "));
955
+ throw new Error(spacetrim.spaceTrim("\n The file has an invalid structure.\n The markdown file must have exactly one top-level section.\n "));
957
956
  }
958
957
  parent_1 = parent_1.parent;
959
958
  }
@@ -987,7 +986,7 @@
987
986
  return {
988
987
  level: level,
989
988
  title: title,
990
- content: spaceTrim__default["default"](contentLines.join('\n')),
989
+ content: spacetrim.spaceTrim(contentLines.join('\n')),
991
990
  sections: sections.map(parsingMarkdownStructureToMarkdownStructure),
992
991
  };
993
992
  }
@@ -1035,7 +1034,7 @@
1035
1034
  if (!(error instanceof Error)) {
1036
1035
  throw error;
1037
1036
  }
1038
- throw new PromptbookSyntaxError(spaceTrim__default["default"](function (block) { return "\n Can not extract variables from the script\n\n ".concat(block(error.name), ": ").concat(block(error.message), "\n "); }));
1037
+ throw new PromptbookSyntaxError(spacetrim.spaceTrim(function (block) { return "\n Can not extract variables from the script\n\n ".concat(block(error.name), ": ").concat(block(error.message), "\n "); }));
1039
1038
  }
1040
1039
  return variables;
1041
1040
  }
@@ -1100,15 +1099,15 @@
1100
1099
  type.startsWith('PROMPTBOOKURL') ||
1101
1100
  type.startsWith('HTTPS')) {
1102
1101
  if (!(listItemParts.length === 2 || (listItemParts.length === 1 && type.startsWith('HTTPS')))) {
1103
- throw new PromptbookSyntaxError(spaceTrim__default["default"]("\n Invalid PROMPTBOOK_URL command:\n\n - ".concat(listItem, "\n ")));
1102
+ throw new PromptbookSyntaxError(spacetrim.spaceTrim("\n Invalid PROMPTBOOK_URL command:\n\n - ".concat(listItem, "\n ")));
1104
1103
  }
1105
1104
  var promptbookUrlString = listItemParts.pop();
1106
1105
  var promptbookUrl = new URL(promptbookUrlString);
1107
1106
  if (promptbookUrl.protocol !== 'https:') {
1108
- throw new PromptbookSyntaxError(spaceTrim__default["default"]("\n Invalid PROMPTBOOK_URL command:\n\n - ".concat(listItem, "\n\n Protocol must be HTTPS\n ")));
1107
+ throw new PromptbookSyntaxError(spacetrim.spaceTrim("\n Invalid PROMPTBOOK_URL command:\n\n - ".concat(listItem, "\n\n Protocol must be HTTPS\n ")));
1109
1108
  }
1110
1109
  if (promptbookUrl.hash !== '') {
1111
- throw new PromptbookSyntaxError(spaceTrim__default["default"]("\n Invalid PROMPTBOOK_URL command:\n\n - ".concat(listItem, "\n\n URL must not contain hash\n Hash is used for identification of the prompt template in the pipeline\n ")));
1110
+ throw new PromptbookSyntaxError(spacetrim.spaceTrim("\n Invalid PROMPTBOOK_URL command:\n\n - ".concat(listItem, "\n\n URL must not contain hash\n Hash is used for identification of the prompt template in the pipeline\n ")));
1112
1111
  }
1113
1112
  return {
1114
1113
  type: 'PROMPTBOOK_URL',
@@ -1117,7 +1116,7 @@
1117
1116
  }
1118
1117
  else if (type.startsWith('PROMPTBOOK_VERSION') || type.startsWith('PTBK_VERSION')) {
1119
1118
  if (listItemParts.length !== 2) {
1120
- throw new PromptbookSyntaxError(spaceTrim__default["default"]("\n Invalid PROMPTBOOK_VERSION command:\n\n - ".concat(listItem, "\n ")));
1119
+ throw new PromptbookSyntaxError(spacetrim.spaceTrim("\n Invalid PROMPTBOOK_VERSION command:\n\n - ".concat(listItem, "\n ")));
1121
1120
  }
1122
1121
  var promptbookVersion = listItemParts.pop();
1123
1122
  // TODO: Validate version
@@ -1132,7 +1131,7 @@
1132
1131
  type.startsWith('SIMPLE_TEMPLATE')) {
1133
1132
  var executionTypes = ExecutionTypes.filter(function (executionType) { return type.includes(executionType); });
1134
1133
  if (executionTypes.length !== 1) {
1135
- throw new PromptbookSyntaxError(spaceTrim__default["default"](function (block) { return "\n Unknown execution type in command:\n\n - ".concat(listItem, "\n\n Supported execution types are:\n ").concat(block(ExecutionTypes.join(', ')), "\n "); }));
1134
+ throw new PromptbookSyntaxError(spacetrim.spaceTrim(function (block) { return "\n Unknown execution type in command:\n\n - ".concat(listItem, "\n\n Supported execution types are:\n ").concat(block(ExecutionTypes.join(', ')), "\n "); }));
1136
1135
  }
1137
1136
  return {
1138
1137
  type: 'EXECUTE',
@@ -1157,7 +1156,7 @@
1157
1156
  };
1158
1157
  }
1159
1158
  else {
1160
- throw new PromptbookSyntaxError(spaceTrim__default["default"](function (block) { return "\n Unknown model variant in command:\n\n - ".concat(listItem, "\n\n Supported variants are:\n ").concat(block(['CHAT', 'COMPLETION'].join(', ')), "\n "); }));
1159
+ throw new PromptbookSyntaxError(spacetrim.spaceTrim(function (block) { return "\n Unknown model variant in command:\n\n - ".concat(listItem, "\n\n Supported variants are:\n ").concat(block(['CHAT', 'COMPLETION'].join(', ')), "\n "); }));
1161
1160
  }
1162
1161
  }
1163
1162
  if (type.startsWith('MODEL_NAME')) {
@@ -1168,7 +1167,7 @@
1168
1167
  };
1169
1168
  }
1170
1169
  else {
1171
- throw new PromptbookSyntaxError(spaceTrim__default["default"](function (block) { return "\n Unknown model key in command:\n\n - ".concat(listItem, "\n\n Supported model keys are:\n ").concat(block(['variant', 'name'].join(', ')), "\n\n Example:\n\n - MODEL VARIANT Chat\n - MODEL NAME gpt-4\n "); }));
1170
+ throw new PromptbookSyntaxError(spacetrim.spaceTrim(function (block) { return "\n Unknown model key in command:\n\n - ".concat(listItem, "\n\n Supported model keys are:\n ").concat(block(['variant', 'name'].join(', ')), "\n\n Example:\n\n - MODEL VARIANT Chat\n - MODEL NAME gpt-4\n "); }));
1172
1171
  }
1173
1172
  }
1174
1173
  else if (type.startsWith('PARAM') ||
@@ -1178,12 +1177,12 @@
1178
1177
  listItem.startsWith('> {') /* <- Note: This is a bit hack to parse return parameters defined at the end of each section */) {
1179
1178
  var parametersMatch = listItem.match(/\{(?<parameterName>[a-z0-9_]+)\}[^\S\r\n]*(?<parameterDescription>.*)$/im);
1180
1179
  if (!parametersMatch || !parametersMatch.groups || !parametersMatch.groups.parameterName) {
1181
- throw new PromptbookSyntaxError(spaceTrim__default["default"]("\n Invalid parameter in command:\n\n - ".concat(listItem, "\n ")));
1180
+ throw new PromptbookSyntaxError(spacetrim.spaceTrim("\n Invalid parameter in command:\n\n - ".concat(listItem, "\n ")));
1182
1181
  }
1183
1182
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
1184
1183
  var _b = parametersMatch.groups, parameterName = _b.parameterName, parameterDescription = _b.parameterDescription;
1185
1184
  if (parameterDescription && parameterDescription.match(/\{(?<parameterName>[a-z0-9_]+)\}/im)) {
1186
- throw new PromptbookSyntaxError(spaceTrim__default["default"]("\n Parameter {".concat(parameterName, "} can not contain another parameter in description:\n\n - ").concat(listItem, "\n ")));
1185
+ throw new PromptbookSyntaxError(spacetrim.spaceTrim("\n Parameter {".concat(parameterName, "} can not contain another parameter in description:\n\n - ").concat(listItem, "\n ")));
1187
1186
  }
1188
1187
  var isInput = type.startsWith('INPUT');
1189
1188
  var isOutput = type.startsWith('OUTPUT');
@@ -1201,11 +1200,11 @@
1201
1200
  }
1202
1201
  else if (type.startsWith('JOKER')) {
1203
1202
  if (listItemParts.length !== 2) {
1204
- throw new PromptbookSyntaxError(spaceTrim__default["default"]("\n Invalid JOKER command:\n\n - ".concat(listItem, "\n ")));
1203
+ throw new PromptbookSyntaxError(spacetrim.spaceTrim("\n Invalid JOKER command:\n\n - ".concat(listItem, "\n ")));
1205
1204
  }
1206
1205
  var parametersMatch = (listItemParts.pop() || '').match(/^\{(?<parameterName>[a-z0-9_]+)\}$/im);
1207
1206
  if (!parametersMatch || !parametersMatch.groups || !parametersMatch.groups.parameterName) {
1208
- throw new PromptbookSyntaxError(spaceTrim__default["default"]("\n Invalid parameter in command:\n\n - ".concat(listItem, "\n ")));
1207
+ throw new PromptbookSyntaxError(spacetrim.spaceTrim("\n Invalid parameter in command:\n\n - ".concat(listItem, "\n ")));
1209
1208
  }
1210
1209
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
1211
1210
  var parameterName = parametersMatch.groups.parameterName;
@@ -1216,7 +1215,7 @@
1216
1215
  }
1217
1216
  else if (type.startsWith('POSTPROCESS') || type.startsWith('POST_PROCESS')) {
1218
1217
  if (listItemParts.length !== 2) {
1219
- throw new PromptbookSyntaxError(spaceTrim__default["default"]("\n Invalid POSTPROCESSING command:\n\n - ".concat(listItem, "\n ")));
1218
+ throw new PromptbookSyntaxError(spacetrim.spaceTrim("\n Invalid POSTPROCESSING command:\n\n - ".concat(listItem, "\n ")));
1220
1219
  }
1221
1220
  var functionName = listItemParts.pop();
1222
1221
  return {
@@ -1296,7 +1295,7 @@
1296
1295
  if (!(error instanceof Error)) {
1297
1296
  throw error;
1298
1297
  }
1299
- throw new PromptbookSyntaxError(spaceTrim__default["default"]("\n Invalid EXPECT command; ".concat(error.message, ":\n\n - ").concat(listItem, "\n ")));
1298
+ throw new PromptbookSyntaxError(spacetrim.spaceTrim("\n Invalid EXPECT command; ".concat(error.message, ":\n\n - ").concat(listItem, "\n ")));
1300
1299
  }
1301
1300
  /*
1302
1301
  } else if (type.startsWith('__________________')) {
@@ -1304,7 +1303,7 @@
1304
1303
  */
1305
1304
  }
1306
1305
  else {
1307
- throw new PromptbookSyntaxError(spaceTrim__default["default"]("\n Unknown command:\n\n - ".concat(listItem, "\n\n Supported commands are:\n - PROMPTBOOK_URL <url>\n - PROMPTBOOK_VERSION <version>\n - EXECUTE PROMPT TEMPLATE\n - EXECUTE SIMPLE TEMPLATE\n - SIMPLE TEMPLATE\n - EXECUTE SCRIPT\n - EXECUTE PROMPT_DIALOG'\n - PROMPT_DIALOG'\n - MODEL NAME <name>\n - MODEL VARIANT <\"Chat\"|\"Completion\">\n - INPUT PARAM {<name>} <description>\n - OUTPUT PARAM {<name>} <description>\n - POSTPROCESS `{functionName}`\n - JOKER {<name>}\n - EXPECT JSON\n - EXPECT <\"Exactly\"|\"Min\"|\"Max\"> <number> <\"Chars\"|\"Words\"|\"Sentences\"|\"Paragraphs\"|\"Pages\">\n\n ")));
1306
+ throw new PromptbookSyntaxError(spacetrim.spaceTrim("\n Unknown command:\n\n - ".concat(listItem, "\n\n Supported commands are:\n - PROMPTBOOK_URL <url>\n - PROMPTBOOK_VERSION <version>\n - EXECUTE PROMPT TEMPLATE\n - EXECUTE SIMPLE TEMPLATE\n - SIMPLE TEMPLATE\n - EXECUTE SCRIPT\n - EXECUTE PROMPT_DIALOG'\n - PROMPT_DIALOG'\n - MODEL NAME <name>\n - MODEL VARIANT <\"Chat\"|\"Completion\">\n - INPUT PARAM {<name>} <description>\n - OUTPUT PARAM {<name>} <description>\n - POSTPROCESS `{functionName}`\n - JOKER {<name>}\n - EXPECT JSON\n - EXPECT <\"Exactly\"|\"Min\"|\"Max\"> <number> <\"Chars\"|\"Words\"|\"Sentences\"|\"Paragraphs\"|\"Pages\">\n\n ")));
1308
1307
  }
1309
1308
  }
1310
1309
 
@@ -1340,7 +1339,7 @@
1340
1339
  existingParameter.description &&
1341
1340
  existingParameter.description !== parameterDescription &&
1342
1341
  parameterDescription) {
1343
- throw new PromptbookSyntaxError(spaceTrim__default["default"](function (block) { return "\n Parameter {".concat(parameterName, "} is defined multiple times with different description.\n\n First definition:\n ").concat(block(existingParameter.description || '[undefined]'), "\n\n Second definition:\n ").concat(block(parameterDescription || '[undefined]'), "\n "); }));
1342
+ throw new PromptbookSyntaxError(spacetrim.spaceTrim(function (block) { return "\n Parameter {".concat(parameterName, "} is defined multiple times with different description.\n\n First definition:\n ").concat(block(existingParameter.description || '[undefined]'), "\n\n Second definition:\n ").concat(block(parameterDescription || '[undefined]'), "\n "); }));
1344
1343
  }
1345
1344
  if (existingParameter) {
1346
1345
  if (parameterDescription) {
@@ -1361,7 +1360,7 @@
1361
1360
  var markdownStructure = markdownToMarkdownStructure(promptbookString);
1362
1361
  var markdownStructureDeepness = countMarkdownStructureDeepness(markdownStructure);
1363
1362
  if (markdownStructureDeepness !== 2) {
1364
- throw new PromptbookSyntaxError(spaceTrim__default["default"]("\n Invalid markdown structure.\n The markdown must have exactly 2 levels of headings (one top-level section and one section for each template).\n Now it has ".concat(markdownStructureDeepness, " levels of headings.\n ")));
1363
+ throw new PromptbookSyntaxError(spacetrim.spaceTrim("\n Invalid markdown structure.\n The markdown must have exactly 2 levels of headings (one top-level section and one section for each template).\n Now it has ".concat(markdownStructureDeepness, " levels of headings.\n ")));
1365
1364
  }
1366
1365
  promptbookJson.title = markdownStructure.title;
1367
1366
  // TODO: [1] DRY description
@@ -1370,7 +1369,7 @@
1370
1369
  description = description.split(/^```.*^```/gms).join('');
1371
1370
  //Note: Remove lists and return statement
1372
1371
  description = description.split(/^(?:(?:-)|(?:\d\))|(?:`?->))\s+.*$/gm).join('');
1373
- description = spaceTrim__default["default"](description);
1372
+ description = spacetrim.spaceTrim(description);
1374
1373
  if (description === '') {
1375
1374
  description = undefined;
1376
1375
  }
@@ -1485,13 +1484,13 @@
1485
1484
  throw new PromptbookSyntaxError('You must specify the language of the script in the prompt template');
1486
1485
  }
1487
1486
  else if (!SUPPORTED_SCRIPT_LANGUAGES.includes(language)) {
1488
- throw new PromptbookSyntaxError(spaceTrim__default["default"](function (block) { return "\n Script language ".concat(language, " is not supported.\n\n Supported languages are:\n ").concat(block(SUPPORTED_SCRIPT_LANGUAGES.join(', ')), "\n\n "); }));
1487
+ throw new PromptbookSyntaxError(spacetrim.spaceTrim(function (block) { return "\n Script language ".concat(language, " is not supported.\n\n Supported languages are:\n ").concat(block(SUPPORTED_SCRIPT_LANGUAGES.join(', ')), "\n\n "); }));
1489
1488
  }
1490
1489
  }
1491
1490
  var lastLine = section.content.split('\n').pop();
1492
1491
  var match = /^->\s*\{(?<resultingParamName>[a-z0-9_]+)\}/im.exec(lastLine);
1493
1492
  if (!match || match.groups === undefined || match.groups.resultingParamName === undefined) {
1494
- throw new PromptbookSyntaxError(spaceTrim__default["default"](function (block) { return "\n Invalid template - each section must end with \"-> {...}\"\n\n Invalid section:\n ".concat(block(
1493
+ throw new PromptbookSyntaxError(spacetrim.spaceTrim(function (block) { return "\n Invalid template - each section must end with \"-> {...}\"\n\n Invalid section:\n ".concat(block(
1495
1494
  // TODO: Show code of invalid sections each time + DRY
1496
1495
  section.content
1497
1496
  .split('\n')
@@ -1505,7 +1504,7 @@
1505
1504
  description_1 = description_1.split(/^```.*^```/gms).join('');
1506
1505
  //Note: Remove lists and return statement
1507
1506
  description_1 = description_1.split(/^(?:(?:-)|(?:\d\))|(?:`?->))\s+.*$/gm).join('');
1508
- description_1 = spaceTrim__default["default"](description_1);
1507
+ description_1 = spacetrim.spaceTrim(description_1);
1509
1508
  if (description_1 === '') {
1510
1509
  description_1 = undefined;
1511
1510
  }
@@ -1596,7 +1595,7 @@
1596
1595
  var sectionRegex = new RegExp("<!--".concat(sectionName, "-->([\\s\\S]*?)<!--/").concat(sectionName, "-->"), 'g');
1597
1596
  var sectionMatch = content.match(sectionRegex);
1598
1597
  if (sectionMatch) {
1599
- return content.replace(sectionRegex, spaceTrim__default["default"](function (block) { return "\n <!--".concat(sectionName, "-->\n ").concat(block(warningLine), "\n ").concat(block(sectionContent), "\n <!--/").concat(sectionName, "-->\n "); }));
1598
+ return content.replace(sectionRegex, spacetrim.spaceTrim(function (block) { return "\n <!--".concat(sectionName, "-->\n ").concat(block(warningLine), "\n ").concat(block(sectionContent), "\n <!--/").concat(sectionName, "-->\n "); }));
1600
1599
  }
1601
1600
  var placeForSection = removeContentComments(content).match(/^##.*$/im);
1602
1601
  if (!placeForSection) {
@@ -1627,7 +1626,7 @@
1627
1626
  }
1628
1627
  return 'template' + normalizeTo_PascalCase(template.title);
1629
1628
  };
1630
- var promptbookMermaid_1 = spaceTrim__default["default"](function (block) { return "\n\n %% \uD83D\uDD2E Tip: Open this on GitHub or in the VSCode website to see the Mermaid graph visually\n\n flowchart LR\n subgraph \"".concat(promptbookJson_1.title, "\"\n\n direction TB\n\n input((Input)):::input\n ").concat(block(promptbookJson_1.promptTemplates
1629
+ var promptbookMermaid_1 = spacetrim.spaceTrim(function (block) { return "\n\n %% \uD83D\uDD2E Tip: Open this on GitHub or in the VSCode website to see the Mermaid graph visually\n\n flowchart LR\n subgraph \"".concat(promptbookJson_1.title, "\"\n\n direction TB\n\n input((Input)):::input\n ").concat(block(promptbookJson_1.promptTemplates
1631
1630
  .flatMap(function (_a) {
1632
1631
  var title = _a.title, dependentParameterNames = _a.dependentParameterNames, resultingParameterName = _a.resultingParameterName;
1633
1632
  return __spreadArray([
@@ -1646,7 +1645,7 @@
1646
1645
  return "".concat(parameterNameToTemplateName_1(name), "--\"{").concat(name, "}\"-->output");
1647
1646
  })
1648
1647
  .join('\n')), "\n output((Output)):::output\n\n classDef input color: grey;\n classDef output color: grey;\n\n end;\n\n\n\n "); });
1649
- var promptbookMermaidBlock = spaceTrim__default["default"](function (block) { return "\n ```mermaid\n ".concat(block(promptbookMermaid_1), "\n ```\n "); });
1648
+ var promptbookMermaidBlock = spacetrim.spaceTrim(function (block) { return "\n ```mermaid\n ".concat(block(promptbookMermaid_1), "\n ```\n "); });
1650
1649
  promptbookString = addAutoGeneratedSection(promptbookString, {
1651
1650
  sectionName: 'Graph',
1652
1651
  sectionContent: promptbookMermaidBlock,
@@ -1671,14 +1670,14 @@
1671
1670
  var _this = this;
1672
1671
  return __generator(this, function (_a) {
1673
1672
  if (!isRunningInNode()) {
1674
- throw new Error(spaceTrim__default["default"]("\n Function prettifyPromptbookStringCli is initiator of CLI script and should be run in Node.js environment.\n\n - In browser use prettifyPromptbookString.\n\n "));
1673
+ throw new Error(spacetrim.spaceTrim("\n Function prettifyPromptbookStringCli is initiator of CLI script and should be run in Node.js environment.\n\n - In browser use prettifyPromptbookString.\n\n "));
1675
1674
  }
1676
1675
  program = new commander__default["default"].Command();
1677
1676
  program.name('promptbook');
1678
1677
  program.version(PROMPTBOOK_VERSION);
1679
- program.description(spaceTrim__default["default"]("\n Promptbook utilities\n "));
1678
+ program.description(spacetrim.spaceTrim("\n Promptbook utilities\n "));
1680
1679
  prettifyCommand = program.command('prettify');
1681
- prettifyCommand.description(spaceTrim__default["default"]("\n Iterates over promptbooks and does multiple enhancing operations on them:\n 1) Adds Mermaid graph\n 2) Prettifies the markdown\n "));
1680
+ prettifyCommand.description(spacetrim.spaceTrim("\n Iterates over promptbooks and does multiple enhancing operations on them:\n 1) Adds Mermaid graph\n 2) Prettifies the markdown\n "));
1682
1681
  prettifyCommand.argument('<filesGlob>', 'Promptbooks to prettify as glob pattern');
1683
1682
  prettifyCommand.option('-i, --ignore <glob>', "Ignore as glob pattern");
1684
1683
  prettifyCommand.action(function (filesGlob, _a) {
@@ -1751,7 +1750,7 @@
1751
1750
  });
1752
1751
  });
1753
1752
  helloCommand = program.command('hello');
1754
- helloCommand.description(spaceTrim__default["default"]("\n Just command for testing\n "));
1753
+ helloCommand.description(spacetrim.spaceTrim("\n Just command for testing\n "));
1755
1754
  helloCommand.argument('<name>', 'Your name');
1756
1755
  helloCommand.option('-g, --greeting <greeting>', "Greeting", 'Hello');
1757
1756
  helloCommand.action(function (name, _a) {