@promptbook/core 0.74.0-6 → 0.74.0-7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/esm/index.es.js CHANGED
@@ -22,7 +22,7 @@ var BOOK_LANGUAGE_VERSION = '1.0.0';
22
22
  *
23
23
  * @see https://github.com/webgptorg/promptbook
24
24
  */
25
- var PROMPTBOOK_ENGINE_VERSION = '0.74.0-5';
25
+ var PROMPTBOOK_ENGINE_VERSION = '0.74.0-6';
26
26
  /**
27
27
  * TODO: string_promptbook_version should be constrained to the all versions of Promptbook engine
28
28
  */
@@ -8082,11 +8082,18 @@ function pipelineStringToJsonSync(pipelineString) {
8082
8082
  }
8083
8083
  // =============================================================
8084
8084
  // Note: 1️⃣ Parsing of the markdown into object
8085
+ if (pipelineString.startsWith('#!')) {
8086
+ var _c = __read(pipelineString.split('\n')), shebangLine_1 = _c[0], restLines = _c.slice(1);
8087
+ if (!(shebangLine_1 || '').includes('ptbk')) {
8088
+ throw new ParseError(spaceTrim$1(function (block) { return "\n It seems that you try to parse a book file which has non-standard shebang line for book files:\n Shebang line must contain 'ptbk'\n\n You have:\n ".concat(block(shebangLine_1 || '(empty line)'), "\n\n It should look like this:\n #!/usr/bin/env ptbk\n\n ").concat(block(getPipelineIdentification()), "\n "); }));
8089
+ }
8090
+ pipelineString = restLines.join('\n');
8091
+ }
8085
8092
  pipelineString = removeContentComments(pipelineString);
8086
8093
  pipelineString = flattenMarkdown(pipelineString) /* <- Note: [🥞] */;
8087
8094
  pipelineString = pipelineString.replaceAll(/`\{(?<parameterName>[a-z0-9_]+)\}`/gi, '{$<parameterName>}');
8088
8095
  pipelineString = pipelineString.replaceAll(/`->\s+\{(?<parameterName>[a-z0-9_]+)\}`/gi, '-> {$<parameterName>}');
8089
- var _c = __read(splitMarkdownIntoSections(pipelineString).map(parseMarkdownSection)), pipelineHead = _c[0], pipelineSections = _c.slice(1); /* <- Note: [🥞] */
8096
+ var _d = __read(splitMarkdownIntoSections(pipelineString).map(parseMarkdownSection)), pipelineHead = _d[0], pipelineSections = _d.slice(1); /* <- Note: [🥞] */
8090
8097
  if (pipelineHead === undefined) {
8091
8098
  throw new UnexpectedError(spaceTrim$1(function (block) { return "\n Pipeline head is not defined\n\n ".concat(block(getPipelineIdentification()), "\n\n This should never happen, because the pipeline already flattened\n "); }));
8092
8099
  }
@@ -8176,10 +8183,10 @@ function pipelineStringToJsonSync(pipelineString) {
8176
8183
  finally { if (e_1) throw e_1.error; }
8177
8184
  }
8178
8185
  var _loop_2 = function (section) {
8179
- var e_3, _d;
8186
+ var e_3, _e;
8180
8187
  // TODO: Parse template description (the content out of the codeblock and lists)
8181
8188
  var listItems_2 = extractAllListItemsFromMarkdown(section.content);
8182
- var _e = extractOneBlockFromMarkdown(section.content), language = _e.language, content = _e.content;
8189
+ var _f = extractOneBlockFromMarkdown(section.content), language = _f.language, content = _f.content;
8183
8190
  // TODO: [🎾][1] DRY description
8184
8191
  var description_1 = section.content;
8185
8192
  // Note: Remove codeblocks - TODO: [🎾]
@@ -8244,14 +8251,14 @@ function pipelineStringToJsonSync(pipelineString) {
8244
8251
  try {
8245
8252
  // TODO [♓️] List commands and before apply order them to achieve order-agnostic commands
8246
8253
  for (var commands_1 = (e_3 = void 0, __values(commands)), commands_1_1 = commands_1.next(); !commands_1_1.done; commands_1_1 = commands_1.next()) {
8247
- var _f = commands_1_1.value, listItem = _f.listItem, command = _f.command;
8254
+ var _g = commands_1_1.value, listItem = _g.listItem, command = _g.command;
8248
8255
  _loop_3(listItem, command);
8249
8256
  }
8250
8257
  }
8251
8258
  catch (e_3_1) { e_3 = { error: e_3_1 }; }
8252
8259
  finally {
8253
8260
  try {
8254
- if (commands_1_1 && !commands_1_1.done && (_d = commands_1.return)) _d.call(commands_1);
8261
+ if (commands_1_1 && !commands_1_1.done && (_e = commands_1.return)) _e.call(commands_1);
8255
8262
  }
8256
8263
  finally { if (e_3) throw e_3.error; }
8257
8264
  }