@promptbook/cli 0.44.0-2 → 0.44.0-21

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 (28) hide show
  1. package/README.md +724 -2
  2. package/esm/index.es.js +78 -60
  3. package/esm/index.es.js.map +1 -1
  4. package/esm/typings/_packages/utils.index.d.ts +5 -3
  5. package/esm/typings/config.d.ts +4 -0
  6. package/esm/typings/execution/plugins/natural-execution-tools/mocked/fakeTextToExpectations.d.ts +9 -1
  7. package/esm/typings/execution/plugins/natural-execution-tools/mocked/fakeTextToExpectations.test.d.ts +1 -0
  8. package/esm/typings/execution/plugins/natural-execution-tools/mocked/faked-completion.test.d.ts +1 -0
  9. package/esm/typings/execution/plugins/script-execution-tools/javascript/JavascriptExecutionToolsOptions.d.ts +5 -1
  10. package/esm/typings/execution/plugins/script-execution-tools/javascript/utils/unknownToString.d.ts +7 -0
  11. package/esm/typings/execution/utils/checkExpectations.d.ts +25 -0
  12. package/esm/typings/execution/utils/checkExpectations.test.d.ts +1 -0
  13. package/esm/typings/types/Prompt.d.ts +5 -0
  14. package/esm/typings/types/PromptbookJson/PromptTemplateJson.d.ts +2 -0
  15. package/package.json +3 -3
  16. package/umd/index.umd.js +110 -93
  17. package/umd/index.umd.js.map +1 -1
  18. package/umd/typings/_packages/utils.index.d.ts +5 -3
  19. package/umd/typings/config.d.ts +4 -0
  20. package/umd/typings/execution/plugins/natural-execution-tools/mocked/fakeTextToExpectations.d.ts +9 -1
  21. package/umd/typings/execution/plugins/natural-execution-tools/mocked/fakeTextToExpectations.test.d.ts +1 -0
  22. package/umd/typings/execution/plugins/natural-execution-tools/mocked/faked-completion.test.d.ts +1 -0
  23. package/umd/typings/execution/plugins/script-execution-tools/javascript/JavascriptExecutionToolsOptions.d.ts +5 -1
  24. package/umd/typings/execution/plugins/script-execution-tools/javascript/utils/unknownToString.d.ts +7 -0
  25. package/umd/typings/execution/utils/checkExpectations.d.ts +25 -0
  26. package/umd/typings/execution/utils/checkExpectations.test.d.ts +1 -0
  27. package/umd/typings/types/Prompt.d.ts +5 -0
  28. package/umd/typings/types/PromptbookJson/PromptTemplateJson.d.ts +2 -0
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@promptbook/cli",
3
- "version": "0.44.0-2",
3
+ "version": "0.44.0-21",
4
4
  "description": "Library to supercharge your use of large language models",
5
5
  "private": false,
6
6
  "sideEffects": false,
@@ -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-2"
45
+ "@promptbook/core": "0.44.0-21"
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-1';
149
+ var PROMPTBOOK_VERSION = '0.44.0-20';
151
150
 
152
151
  /**
153
152
  * This error indicates that the promptbook in a markdown format cannot be parsed into a valid promptbook object
@@ -245,72 +244,22 @@
245
244
  })(Error));
246
245
 
247
246
  /**
248
- * The maximum number of iterations for a loops
249
- */
250
- var LOOP_LIMIT = 1000;
251
-
252
- /**
253
- * This error occurs during the parameter replacement in the template
247
+ * This error occurs when some expectation is not met in the execution of the pipeline
254
248
  *
255
- * Note: This is a kindof subtype of PromptbookExecutionError because it occurs during the execution of the pipeline
249
+ * @private Always catched and rethrown as `PromptbookExecutionError`
250
+ * Note: This is a kindof subtype of PromptbookExecutionError
256
251
  */
257
252
  /** @class */ ((function (_super) {
258
- __extends(TemplateError, _super);
259
- function TemplateError(message) {
253
+ __extends(ExpectError, _super);
254
+ function ExpectError(message) {
260
255
  var _this = _super.call(this, message) || this;
261
- _this.name = 'TemplateError';
262
- Object.setPrototypeOf(_this, TemplateError.prototype);
256
+ _this.name = 'ExpectError';
257
+ Object.setPrototypeOf(_this, ExpectError.prototype);
263
258
  return _this;
264
259
  }
265
- return TemplateError;
260
+ return ExpectError;
266
261
  })(Error));
267
262
 
268
- /**
269
- * This error type indicates that the error should not happen and its last check before crashing with some other error
270
- */
271
- var UnexpectedError = /** @class */ (function (_super) {
272
- __extends(UnexpectedError, _super);
273
- function UnexpectedError(message) {
274
- 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;
275
- _this.name = 'UnexpectedError';
276
- Object.setPrototypeOf(_this, UnexpectedError.prototype);
277
- return _this;
278
- }
279
- return UnexpectedError;
280
- }(Error));
281
-
282
- /**
283
- * Prettify the html code
284
- *
285
- * @param html raw html code
286
- * @returns formatted html code
287
- */
288
- function prettifyMarkdown(html) {
289
- try {
290
- return prettier.format(html, {
291
- parser: 'markdown',
292
- plugins: [parserHtml__default["default"]],
293
- // TODO: DRY - make some import or auto-copy of .prettierrc
294
- endOfLine: 'lf',
295
- tabWidth: 4,
296
- singleQuote: true,
297
- trailingComma: 'all',
298
- arrowParens: 'always',
299
- printWidth: 120,
300
- htmlWhitespaceSensitivity: 'ignore',
301
- jsxBracketSameLine: false,
302
- bracketSpacing: true,
303
- });
304
- }
305
- catch (error) {
306
- console.error('There was an error with prettifying the markdown, using the original as the fallback', {
307
- error: error,
308
- html: html,
309
- });
310
- return html;
311
- }
312
- }
313
-
314
263
  var defaultDiacriticsRemovalMap = [
315
264
  {
316
265
  base: 'A',
@@ -554,6 +503,73 @@
554
503
  limitations under the License.
555
504
  */
556
505
 
506
+ /**
507
+ * The maximum number of iterations for a loops
508
+ */
509
+ var LOOP_LIMIT = 1000;
510
+
511
+ /**
512
+ * This error occurs during the parameter replacement in the template
513
+ *
514
+ * Note: This is a kindof subtype of PromptbookExecutionError because it occurs during the execution of the pipeline
515
+ */
516
+ /** @class */ ((function (_super) {
517
+ __extends(TemplateError, _super);
518
+ function TemplateError(message) {
519
+ var _this = _super.call(this, message) || this;
520
+ _this.name = 'TemplateError';
521
+ Object.setPrototypeOf(_this, TemplateError.prototype);
522
+ return _this;
523
+ }
524
+ return TemplateError;
525
+ })(Error));
526
+
527
+ /**
528
+ * This error type indicates that the error should not happen and its last check before crashing with some other error
529
+ */
530
+ var UnexpectedError = /** @class */ (function (_super) {
531
+ __extends(UnexpectedError, _super);
532
+ function UnexpectedError(message) {
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;
534
+ _this.name = 'UnexpectedError';
535
+ Object.setPrototypeOf(_this, UnexpectedError.prototype);
536
+ return _this;
537
+ }
538
+ return UnexpectedError;
539
+ }(Error));
540
+
541
+ /**
542
+ * Prettify the html code
543
+ *
544
+ * @param html raw html code
545
+ * @returns formatted html code
546
+ */
547
+ function prettifyMarkdown(html) {
548
+ try {
549
+ return prettier.format(html, {
550
+ parser: 'markdown',
551
+ plugins: [parserHtml__default["default"]],
552
+ // TODO: DRY - make some import or auto-copy of .prettierrc
553
+ endOfLine: 'lf',
554
+ tabWidth: 4,
555
+ singleQuote: true,
556
+ trailingComma: 'all',
557
+ arrowParens: 'always',
558
+ printWidth: 120,
559
+ htmlWhitespaceSensitivity: 'ignore',
560
+ jsxBracketSameLine: false,
561
+ bracketSpacing: true,
562
+ });
563
+ }
564
+ catch (error) {
565
+ console.error('There was an error with prettifying the markdown, using the original as the fallback', {
566
+ error: error,
567
+ html: html,
568
+ });
569
+ return html;
570
+ }
571
+ }
572
+
557
573
  /**
558
574
  * Makes first letter of a string uppercase
559
575
  *
@@ -689,7 +705,7 @@
689
705
  * @returns {string} The input string with all comments removed.
690
706
  */
691
707
  function removeContentComments(content) {
692
- return spaceTrim__default["default"](content.replace(/<!--(.*?)-->/gs, ''));
708
+ return spacetrim.spaceTrim(content.replace(/<!--(.*?)-->/gs, ''));
693
709
  }
694
710
 
695
711
  /**
@@ -936,7 +952,7 @@
936
952
  }
937
953
  if (parent_1.parent === null /* <- Note: We are in root */) {
938
954
  // [🌻]
939
- 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 "));
940
956
  }
941
957
  parent_1 = parent_1.parent;
942
958
  }
@@ -970,7 +986,7 @@
970
986
  return {
971
987
  level: level,
972
988
  title: title,
973
- content: spaceTrim__default["default"](contentLines.join('\n')),
989
+ content: spacetrim.spaceTrim(contentLines.join('\n')),
974
990
  sections: sections.map(parsingMarkdownStructureToMarkdownStructure),
975
991
  };
976
992
  }
@@ -1018,7 +1034,7 @@
1018
1034
  if (!(error instanceof Error)) {
1019
1035
  throw error;
1020
1036
  }
1021
- 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 "); }));
1022
1038
  }
1023
1039
  return variables;
1024
1040
  }
@@ -1041,6 +1057,7 @@
1041
1057
  */
1042
1058
  var EXPECTATION_UNITS = ['CHARACTERS', 'WORDS', 'SENTENCES', 'PARAGRAPHS', 'LINES', 'PAGES'];
1043
1059
  /**
1060
+ * TODO: [💝] Unite object for expecting amount and format - remove expectFormat
1044
1061
  * TODO: use one helper type> (string_prompt | string_javascript | string_markdown) & string_template
1045
1062
  */
1046
1063
 
@@ -1082,15 +1099,15 @@
1082
1099
  type.startsWith('PROMPTBOOKURL') ||
1083
1100
  type.startsWith('HTTPS')) {
1084
1101
  if (!(listItemParts.length === 2 || (listItemParts.length === 1 && type.startsWith('HTTPS')))) {
1085
- 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 ")));
1086
1103
  }
1087
1104
  var promptbookUrlString = listItemParts.pop();
1088
1105
  var promptbookUrl = new URL(promptbookUrlString);
1089
1106
  if (promptbookUrl.protocol !== 'https:') {
1090
- 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 ")));
1091
1108
  }
1092
1109
  if (promptbookUrl.hash !== '') {
1093
- 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 ")));
1094
1111
  }
1095
1112
  return {
1096
1113
  type: 'PROMPTBOOK_URL',
@@ -1099,7 +1116,7 @@
1099
1116
  }
1100
1117
  else if (type.startsWith('PROMPTBOOK_VERSION') || type.startsWith('PTBK_VERSION')) {
1101
1118
  if (listItemParts.length !== 2) {
1102
- 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 ")));
1103
1120
  }
1104
1121
  var promptbookVersion = listItemParts.pop();
1105
1122
  // TODO: Validate version
@@ -1114,7 +1131,7 @@
1114
1131
  type.startsWith('SIMPLE_TEMPLATE')) {
1115
1132
  var executionTypes = ExecutionTypes.filter(function (executionType) { return type.includes(executionType); });
1116
1133
  if (executionTypes.length !== 1) {
1117
- 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 "); }));
1118
1135
  }
1119
1136
  return {
1120
1137
  type: 'EXECUTE',
@@ -1139,7 +1156,7 @@
1139
1156
  };
1140
1157
  }
1141
1158
  else {
1142
- 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 "); }));
1143
1160
  }
1144
1161
  }
1145
1162
  if (type.startsWith('MODEL_NAME')) {
@@ -1150,7 +1167,7 @@
1150
1167
  };
1151
1168
  }
1152
1169
  else {
1153
- 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 "); }));
1154
1171
  }
1155
1172
  }
1156
1173
  else if (type.startsWith('PARAM') ||
@@ -1160,12 +1177,12 @@
1160
1177
  listItem.startsWith('> {') /* <- Note: This is a bit hack to parse return parameters defined at the end of each section */) {
1161
1178
  var parametersMatch = listItem.match(/\{(?<parameterName>[a-z0-9_]+)\}[^\S\r\n]*(?<parameterDescription>.*)$/im);
1162
1179
  if (!parametersMatch || !parametersMatch.groups || !parametersMatch.groups.parameterName) {
1163
- 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 ")));
1164
1181
  }
1165
1182
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
1166
1183
  var _b = parametersMatch.groups, parameterName = _b.parameterName, parameterDescription = _b.parameterDescription;
1167
1184
  if (parameterDescription && parameterDescription.match(/\{(?<parameterName>[a-z0-9_]+)\}/im)) {
1168
- 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 ")));
1169
1186
  }
1170
1187
  var isInput = type.startsWith('INPUT');
1171
1188
  var isOutput = type.startsWith('OUTPUT');
@@ -1183,11 +1200,11 @@
1183
1200
  }
1184
1201
  else if (type.startsWith('JOKER')) {
1185
1202
  if (listItemParts.length !== 2) {
1186
- 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 ")));
1187
1204
  }
1188
1205
  var parametersMatch = (listItemParts.pop() || '').match(/^\{(?<parameterName>[a-z0-9_]+)\}$/im);
1189
1206
  if (!parametersMatch || !parametersMatch.groups || !parametersMatch.groups.parameterName) {
1190
- 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 ")));
1191
1208
  }
1192
1209
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
1193
1210
  var parameterName = parametersMatch.groups.parameterName;
@@ -1198,7 +1215,7 @@
1198
1215
  }
1199
1216
  else if (type.startsWith('POSTPROCESS') || type.startsWith('POST_PROCESS')) {
1200
1217
  if (listItemParts.length !== 2) {
1201
- 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 ")));
1202
1219
  }
1203
1220
  var functionName = listItemParts.pop();
1204
1221
  return {
@@ -1278,7 +1295,7 @@
1278
1295
  if (!(error instanceof Error)) {
1279
1296
  throw error;
1280
1297
  }
1281
- 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 ")));
1282
1299
  }
1283
1300
  /*
1284
1301
  } else if (type.startsWith('__________________')) {
@@ -1286,7 +1303,7 @@
1286
1303
  */
1287
1304
  }
1288
1305
  else {
1289
- 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 ")));
1290
1307
  }
1291
1308
  }
1292
1309
 
@@ -1322,7 +1339,7 @@
1322
1339
  existingParameter.description &&
1323
1340
  existingParameter.description !== parameterDescription &&
1324
1341
  parameterDescription) {
1325
- 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 "); }));
1326
1343
  }
1327
1344
  if (existingParameter) {
1328
1345
  if (parameterDescription) {
@@ -1343,7 +1360,7 @@
1343
1360
  var markdownStructure = markdownToMarkdownStructure(promptbookString);
1344
1361
  var markdownStructureDeepness = countMarkdownStructureDeepness(markdownStructure);
1345
1362
  if (markdownStructureDeepness !== 2) {
1346
- 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 ")));
1347
1364
  }
1348
1365
  promptbookJson.title = markdownStructure.title;
1349
1366
  // TODO: [1] DRY description
@@ -1352,7 +1369,7 @@
1352
1369
  description = description.split(/^```.*^```/gms).join('');
1353
1370
  //Note: Remove lists and return statement
1354
1371
  description = description.split(/^(?:(?:-)|(?:\d\))|(?:`?->))\s+.*$/gm).join('');
1355
- description = spaceTrim__default["default"](description);
1372
+ description = spacetrim.spaceTrim(description);
1356
1373
  if (description === '') {
1357
1374
  description = undefined;
1358
1375
  }
@@ -1467,13 +1484,13 @@
1467
1484
  throw new PromptbookSyntaxError('You must specify the language of the script in the prompt template');
1468
1485
  }
1469
1486
  else if (!SUPPORTED_SCRIPT_LANGUAGES.includes(language)) {
1470
- 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 "); }));
1471
1488
  }
1472
1489
  }
1473
1490
  var lastLine = section.content.split('\n').pop();
1474
1491
  var match = /^->\s*\{(?<resultingParamName>[a-z0-9_]+)\}/im.exec(lastLine);
1475
1492
  if (!match || match.groups === undefined || match.groups.resultingParamName === undefined) {
1476
- 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(
1477
1494
  // TODO: Show code of invalid sections each time + DRY
1478
1495
  section.content
1479
1496
  .split('\n')
@@ -1487,7 +1504,7 @@
1487
1504
  description_1 = description_1.split(/^```.*^```/gms).join('');
1488
1505
  //Note: Remove lists and return statement
1489
1506
  description_1 = description_1.split(/^(?:(?:-)|(?:\d\))|(?:`?->))\s+.*$/gm).join('');
1490
- description_1 = spaceTrim__default["default"](description_1);
1507
+ description_1 = spacetrim.spaceTrim(description_1);
1491
1508
  if (description_1 === '') {
1492
1509
  description_1 = undefined;
1493
1510
  }
@@ -1578,7 +1595,7 @@
1578
1595
  var sectionRegex = new RegExp("<!--".concat(sectionName, "-->([\\s\\S]*?)<!--/").concat(sectionName, "-->"), 'g');
1579
1596
  var sectionMatch = content.match(sectionRegex);
1580
1597
  if (sectionMatch) {
1581
- 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 "); }));
1582
1599
  }
1583
1600
  var placeForSection = removeContentComments(content).match(/^##.*$/im);
1584
1601
  if (!placeForSection) {
@@ -1609,7 +1626,7 @@
1609
1626
  }
1610
1627
  return 'template' + normalizeTo_PascalCase(template.title);
1611
1628
  };
1612
- 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
1613
1630
  .flatMap(function (_a) {
1614
1631
  var title = _a.title, dependentParameterNames = _a.dependentParameterNames, resultingParameterName = _a.resultingParameterName;
1615
1632
  return __spreadArray([
@@ -1628,7 +1645,7 @@
1628
1645
  return "".concat(parameterNameToTemplateName_1(name), "--\"{").concat(name, "}\"-->output");
1629
1646
  })
1630
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 "); });
1631
- 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 "); });
1632
1649
  promptbookString = addAutoGeneratedSection(promptbookString, {
1633
1650
  sectionName: 'Graph',
1634
1651
  sectionContent: promptbookMermaidBlock,
@@ -1653,14 +1670,14 @@
1653
1670
  var _this = this;
1654
1671
  return __generator(this, function (_a) {
1655
1672
  if (!isRunningInNode()) {
1656
- 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 "));
1657
1674
  }
1658
1675
  program = new commander__default["default"].Command();
1659
1676
  program.name('promptbook');
1660
1677
  program.version(PROMPTBOOK_VERSION);
1661
- program.description(spaceTrim__default["default"]("\n Promptbook utilities\n "));
1678
+ program.description(spacetrim.spaceTrim("\n Promptbook utilities\n "));
1662
1679
  prettifyCommand = program.command('prettify');
1663
- 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 "));
1664
1681
  prettifyCommand.argument('<filesGlob>', 'Promptbooks to prettify as glob pattern');
1665
1682
  prettifyCommand.option('-i, --ignore <glob>', "Ignore as glob pattern");
1666
1683
  prettifyCommand.action(function (filesGlob, _a) {
@@ -1733,7 +1750,7 @@
1733
1750
  });
1734
1751
  });
1735
1752
  helloCommand = program.command('hello');
1736
- helloCommand.description(spaceTrim__default["default"]("\n Just command for testing\n "));
1753
+ helloCommand.description(spacetrim.spaceTrim("\n Just command for testing\n "));
1737
1754
  helloCommand.argument('<name>', 'Your name');
1738
1755
  helloCommand.option('-g, --greeting <greeting>', "Greeting", 'Hello');
1739
1756
  helloCommand.action(function (name, _a) {