@promptbook/cli 0.83.0 → 0.84.0-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.
package/README.md CHANGED
@@ -23,6 +23,10 @@
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
+
26
30
  ## 📦 Package `@promptbook/cli`
27
31
 
28
32
  - 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';
42
+ var PROMPTBOOK_ENGINE_VERSION = '0.83.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
@@ -9618,6 +9618,55 @@ var HIGH_LEVEL_ABSTRACTIONS = [
9618
9618
  var SUPPORTED_SCRIPT_LANGUAGES = ['javascript', 'typescript', 'python'];
9619
9619
  // <- TODO: [🏥] DRY
9620
9620
 
9621
+ /**
9622
+ * Removes Markdown (or HTML) comments
9623
+ *
9624
+ * @param {string} content - The string to remove comments from.
9625
+ * @returns {string} The input string with all comments removed.
9626
+ * @public exported from `@promptbook/markdown-utils`
9627
+ */
9628
+ function removeMarkdownComments(content) {
9629
+ return spaceTrim$1(content.replace(/<!--(.*?)-->/gs, ''));
9630
+ }
9631
+
9632
+ /**
9633
+ * @@@
9634
+ *
9635
+ * @public exported from `@promptbook/editable`
9636
+ */
9637
+ function isFlatPipeline(pipelineString) {
9638
+ pipelineString = removeMarkdownComments(pipelineString);
9639
+ pipelineString = spaceTrim(pipelineString);
9640
+ var isMarkdownBeginningWithHeadline = pipelineString.startsWith('# ');
9641
+ var isLastLineReturnStatement = pipelineString.split('\n').pop().split('`').join('').startsWith('->');
9642
+ // TODO: Also (double)check
9643
+ // > const usedCommands
9644
+ // > const isBlocksUsed
9645
+ // > const returnStatementCount
9646
+ var isFlat = !isMarkdownBeginningWithHeadline && isLastLineReturnStatement;
9647
+ return isFlat;
9648
+ }
9649
+
9650
+ /**
9651
+ * @@@
9652
+ *
9653
+ * @public exported from `@promptbook/editable`
9654
+ */
9655
+ function deflatePipeline(pipelineString) {
9656
+ if (!isFlatPipeline(pipelineString)) {
9657
+ return pipelineString;
9658
+ }
9659
+ var pipelineStringLines = pipelineString.split('\n');
9660
+ var returnStatement = pipelineStringLines.pop();
9661
+ var prompt = spaceTrim(pipelineStringLines.join('\n'));
9662
+ pipelineString = validatePipelineString(spaceTrim(function (block) { return "\n # ".concat(DEFAULT_BOOK_TITLE, "\n\n ## Prompt\n\n ```\n ").concat(block(prompt), "\n ```\n\n ").concat(returnStatement, "\n "); }));
9663
+ // <- TODO: Maybe use book` notation
9664
+ return pipelineString;
9665
+ }
9666
+ /**
9667
+ * TODO: Unit test
9668
+ */
9669
+
9621
9670
  /**
9622
9671
  * Utility function to extract all list items from markdown
9623
9672
  *
@@ -9833,17 +9882,6 @@ function flattenMarkdown(markdown) {
9833
9882
  * NOW we are working just with markdown string and its good enough
9834
9883
  */
9835
9884
 
9836
- /**
9837
- * Removes Markdown (or HTML) comments
9838
- *
9839
- * @param {string} content - The string to remove comments from.
9840
- * @returns {string} The input string with all comments removed.
9841
- * @public exported from `@promptbook/markdown-utils`
9842
- */
9843
- function removeMarkdownComments(content) {
9844
- return spaceTrim$1(content.replace(/<!--(.*?)-->/gs, ''));
9845
- }
9846
-
9847
9885
  /**
9848
9886
  * Compile pipeline from string (markdown) format to JSON format synchronously
9849
9887
  *
@@ -9904,26 +9942,9 @@ function parsePipeline(pipelineString) {
9904
9942
  pipelineString = removeMarkdownComments(pipelineString);
9905
9943
  pipelineString = spaceTrim$1(pipelineString);
9906
9944
  // <- TODO: [😧] `spaceTrim` should preserve discriminated type *(or at lease `PipelineString`)*
9945
+ pipelineString = deflatePipeline(pipelineString);
9907
9946
  // ==============
9908
- // Note: 1️⃣◽2️⃣ Process flat pipeline
9909
- var isMarkdownBeginningWithHeadline = pipelineString.startsWith('# ');
9910
- var isLastLineReturnStatement = pipelineString.split('\n').pop().split('`').join('').startsWith('->');
9911
- // TODO: Also (double)check
9912
- // > const usedCommands
9913
- // > const isBlocksUsed
9914
- // > const returnStatementCount
9915
- var isFlatPipeline = !isMarkdownBeginningWithHeadline && isLastLineReturnStatement;
9916
- // console.log({ isMarkdownBeginningWithHeadline, isLastLineReturnStatement, isFlatPipeline });
9917
- if (isFlatPipeline) {
9918
- var pipelineStringLines = pipelineString.split('\n');
9919
- var returnStatement_1 = pipelineStringLines.pop();
9920
- var prompt_1 = spaceTrim$1(pipelineStringLines.join('\n'));
9921
- pipelineString = validatePipelineString(spaceTrim$1(function (block) { return "\n # ".concat(DEFAULT_BOOK_TITLE, "\n\n ## Prompt\n\n ```\n ").concat(block(prompt_1), "\n ```\n\n ").concat(returnStatement_1, "\n "); }));
9922
- // <- TODO: Maybe use book` notation
9923
- // console.log(pipelineString);
9924
- }
9925
- // ==============
9926
- // Note: 1️⃣◽3️⃣ Parse the markdown
9947
+ // Note: 1️⃣◽2️⃣ Parse the markdown
9927
9948
  pipelineString = flattenMarkdown(pipelineString) /* <- Note: [🥞] */;
9928
9949
  pipelineString = pipelineString.replaceAll(/`\{(?<parameterName>[a-z0-9_]+)\}`/gi, '{$<parameterName>}');
9929
9950
  pipelineString = pipelineString.replaceAll(/`->\s+\{(?<parameterName>[a-z0-9_]+)\}`/gi, '-> {$<parameterName>}');