@promptbook/cli 0.74.0-8 → 0.74.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 (37) hide show
  1. package/README.md +5 -17
  2. package/bin/promptbook-cli.js +8 -4
  3. package/esm/index.es.js +173 -96
  4. package/esm/index.es.js.map +1 -1
  5. package/esm/typings/src/_packages/core.index.d.ts +5 -1
  6. package/esm/typings/src/_packages/utils.index.d.ts +4 -0
  7. package/esm/typings/src/cli/cli-commands/run.d.ts +1 -1
  8. package/esm/typings/src/cli/main.d.ts +4 -1
  9. package/esm/typings/src/cli/promptbookCli.d.ts +1 -1
  10. package/esm/typings/src/cli/test/ptbk.d.ts +1 -1
  11. package/esm/typings/src/collection/collectionToJson.test.d.ts +1 -1
  12. package/esm/typings/src/collection/constructors/createCollectionFromDirectory.d.ts +1 -1
  13. package/esm/typings/src/commands/BOOK_VERSION/BookVersionCommand.d.ts +1 -1
  14. package/esm/typings/src/commands/FOREACH/foreachCommandParser.d.ts +2 -2
  15. package/esm/typings/src/commands/_BOILERPLATE/boilerplateCommandParser.d.ts +1 -1
  16. package/esm/typings/src/config.d.ts +6 -0
  17. package/esm/typings/src/conversion/pipelineJsonToString.d.ts +3 -3
  18. package/esm/typings/src/conversion/pipelineStringToJson.d.ts +2 -2
  19. package/esm/typings/src/conversion/pipelineStringToJsonSync.d.ts +2 -2
  20. package/esm/typings/src/conversion/utils/stringifyPipelineJson.d.ts +1 -1
  21. package/esm/typings/src/conversion/validation/_importPipeline.d.ts +7 -7
  22. package/esm/typings/src/formats/_common/FormatDefinition.d.ts +1 -1
  23. package/esm/typings/src/formats/_common/FormatSubvalueDefinition.d.ts +1 -1
  24. package/esm/typings/src/storage/blackhole/BlackholeStorage.d.ts +33 -0
  25. package/esm/typings/src/storage/memory/MemoryStorage.d.ts +1 -1
  26. package/esm/typings/src/storage/{memory/utils → utils}/PrefixStorage.d.ts +1 -1
  27. package/esm/typings/src/types/PipelineJson/PipelineJson.d.ts +6 -4
  28. package/esm/typings/src/types/PipelineJson/PreparationJson.d.ts +1 -1
  29. package/esm/typings/src/types/Prompt.d.ts +1 -1
  30. package/esm/typings/src/types/typeAliases.d.ts +2 -2
  31. package/esm/typings/src/utils/expectation-counters/config.d.ts +12 -0
  32. package/esm/typings/src/utils/expectation-counters/countLines.d.ts +2 -0
  33. package/esm/typings/src/utils/expectation-counters/countPages.d.ts +2 -0
  34. package/package.json +1 -1
  35. package/umd/index.umd.js +173 -96
  36. package/umd/index.umd.js.map +1 -1
  37. /package/esm/typings/src/storage/{memory → local-storage}/utils/makePromptbookStorageFromWebStorage.d.ts +0 -0
package/esm/index.es.js CHANGED
@@ -37,7 +37,7 @@ var BOOK_LANGUAGE_VERSION = '1.0.0';
37
37
  *
38
38
  * @see https://github.com/webgptorg/promptbook
39
39
  */
40
- var PROMPTBOOK_ENGINE_VERSION = '0.74.0-7';
40
+ var PROMPTBOOK_ENGINE_VERSION = '0.74.0-13';
41
41
  /**
42
42
  * TODO: string_promptbook_version should be constrained to the all versions of Promptbook engine
43
43
  */
@@ -389,6 +389,12 @@ var GENERATOR_WARNING = "\u26A0\uFE0F WARNING: This code has been generated so t
389
389
  */
390
390
  var CLAIM = "Build responsible, controlled and transparent applications on top of LLM models!";
391
391
  // <- TODO: [🐊] Pick the best claim
392
+ /**
393
+ * When the title is not provided, the default title is used
394
+ *
395
+ * @public exported from `@promptbook/core`
396
+ */
397
+ var DEFAULT_TITLE = "Untitled";
392
398
  /**
393
399
  * Warning message for the generated sections and files files
394
400
  *
@@ -710,13 +716,13 @@ function capitalize(word) {
710
716
  /**
711
717
  * Converts promptbook in JSON format to string format
712
718
  *
713
- * @param pipelineJson Promptbook in JSON format (.ptbk.json)
714
- * @returns Promptbook in string format (.ptbk.md)
719
+ * @param pipelineJson Promptbook in JSON format (.book.json)
720
+ * @returns Promptbook in string format (.book.md)
715
721
  * @public exported from `@promptbook/core`
716
722
  */
717
723
  function pipelineJsonToString(pipelineJson) {
718
724
  var e_1, _a, e_2, _b, e_3, _c, e_4, _d, e_5, _e, e_6, _f;
719
- var title = pipelineJson.title, pipelineUrl = pipelineJson.pipelineUrl, promptbookVersion = pipelineJson.promptbookVersion, description = pipelineJson.description, parameters = pipelineJson.parameters, templates = pipelineJson.templates;
725
+ var title = pipelineJson.title, pipelineUrl = pipelineJson.pipelineUrl, bookVersion = pipelineJson.bookVersion, description = pipelineJson.description, parameters = pipelineJson.parameters, templates = pipelineJson.templates;
720
726
  var pipelineString = "# ".concat(title);
721
727
  if (description) {
722
728
  pipelineString += '\n\n';
@@ -726,8 +732,10 @@ function pipelineJsonToString(pipelineJson) {
726
732
  if (pipelineUrl) {
727
733
  commands.push("PIPELINE URL ".concat(pipelineUrl));
728
734
  }
729
- commands.push("PROMPTBOOK VERSION ".concat(promptbookVersion));
730
- // TODO: [main] !!! This increase size of the bundle and is probbably not necessary
735
+ if (bookVersion !== "undefined") {
736
+ commands.push("BOOK VERSION ".concat(bookVersion));
737
+ }
738
+ // TODO: [main] !!!!! This increases size of the bundle and is probbably not necessary
731
739
  pipelineString = prettifyMarkdown(pipelineString);
732
740
  try {
733
741
  for (var _g = __values(parameters.filter(function (_a) {
@@ -907,7 +915,7 @@ function templateParameterJsonToString(templateParameterJson) {
907
915
  * TODO: [🧠] Is there a way to auto-detect missing features in pipelineJsonToString
908
916
  * TODO: [🏛] Maybe make some markdown builder
909
917
  * TODO: [🏛] Escape all
910
- * TODO: [🧠] Should be in generated .ptbk.md file GENERATOR_WARNING
918
+ * TODO: [🧠] Should be in generated .book.md file GENERATOR_WARNING
911
919
  */
912
920
 
913
921
  /**
@@ -1545,7 +1553,7 @@ function joinLlmExecutionTools() {
1545
1553
  * TODO: [👷‍♂️] @@@ Manual about construction of llmTools
1546
1554
  */
1547
1555
 
1548
- var PipelineCollection = [{title:"Prepare Knowledge from Markdown",pipelineUrl:"https://promptbook.studio/promptbook/prepare-knowledge-from-markdown.ptbk.md",parameters:[{name:"knowledgeContent",description:"Markdown document content",isInput:true,isOutput:false},{name:"knowledgePieces",description:"The knowledge JSON object",isInput:false,isOutput:true}],templates:[{templateType:"PROMPT_TEMPLATE",name:"knowledge",title:"Knowledge",content:"You are experienced data researcher, extract the important knowledge from the document.\n\n# Rules\n\n- Make pieces of information concise, clear, and easy to understand\n- One piece of information should be approximately 1 paragraph\n- Divide the paragraphs by markdown horizontal lines ---\n- Omit irrelevant information\n- Group redundant information\n- Write just extracted information, nothing else\n\n# The document\n\nTake information from this document:\n\n> {knowledgeContent}",resultingParameterName:"knowledgePieces",dependentParameterNames:["knowledgeContent"]}],knowledgeSources:[],knowledgePieces:[],personas:[],preparations:[],sourceFile:"./promptbook-collection/prepare-knowledge-from-markdown.ptbk.md"},{title:"Prepare Keywords",pipelineUrl:"https://promptbook.studio/promptbook/prepare-knowledge-keywords.ptbk.md",parameters:[{name:"knowledgePieceContent",description:"The content",isInput:true,isOutput:false},{name:"keywords",description:"Keywords separated by comma",isInput:false,isOutput:true}],templates:[{templateType:"PROMPT_TEMPLATE",name:"knowledge",title:"Knowledge",content:"You are experienced data researcher, detect the important keywords in the document.\n\n# Rules\n\n- Write just keywords separated by comma\n\n# The document\n\nTake information from this document:\n\n> {knowledgePieceContent}",resultingParameterName:"keywords",dependentParameterNames:["knowledgePieceContent"]}],knowledgeSources:[],knowledgePieces:[],personas:[],preparations:[],sourceFile:"./promptbook-collection/prepare-knowledge-keywords.ptbk.md"},{title:"Prepare Title",pipelineUrl:"https://promptbook.studio/promptbook/prepare-knowledge-title.ptbk.md",parameters:[{name:"knowledgePieceContent",description:"The content",isInput:true,isOutput:false},{name:"title",description:"The title of the document",isInput:false,isOutput:true}],templates:[{templateType:"PROMPT_TEMPLATE",name:"knowledge",title:"Knowledge",content:"You are experienced content creator, write best title for the document.\n\n# Rules\n\n- Write just title, nothing else\n- Title should be concise and clear\n- Write maximum 5 words for the title\n\n# The document\n\n> {knowledgePieceContent}",resultingParameterName:"title",expectations:{words:{min:1,max:8}},dependentParameterNames:["knowledgePieceContent"]}],knowledgeSources:[],knowledgePieces:[],personas:[],preparations:[],sourceFile:"./promptbook-collection/prepare-knowledge-title.ptbk.md"},{title:"Prepare Keywords",pipelineUrl:"https://promptbook.studio/promptbook/prepare-persona.ptbk.md",parameters:[{name:"availableModelNames",description:"List of available model names separated by comma (,)",isInput:true,isOutput:false},{name:"personaDescription",description:"Description of the persona",isInput:true,isOutput:false},{name:"modelRequirements",description:"Specific requirements for the model",isInput:false,isOutput:true}],templates:[{templateType:"PROMPT_TEMPLATE",name:"make-model-requirements",title:"Make modelRequirements",content:"You are experienced AI engineer, you need to create virtual assistant.\nWrite\n\n## Example\n\n```json\n{\n\"modelName\": \"gpt-4o\",\n\"systemMessage\": \"You are experienced AI engineer and helpfull assistant.\",\n\"temperature\": 0.7\n}\n```\n\n## Instructions\n\n- Your output format is JSON object\n- Write just the JSON object, no other text should be present\n- It contains the following keys:\n - `modelName`: The name of the model to use\n - `systemMessage`: The system message to provide context to the model\n - `temperature`: The sampling temperature to use\n\n### Key `modelName`\n\nPick from the following models:\n\n- {availableModelNames}\n\n### Key `systemMessage`\n\nThe system message is used to communicate instructions or provide context to the model at the beginning of a conversation. It is displayed in a different format compared to user messages, helping the model understand its role in the conversation. The system message typically guides the model's behavior, sets the tone, or specifies desired output from the model. By utilizing the system message effectively, users can steer the model towards generating more accurate and relevant responses.\n\nFor example:\n\n> You are an experienced AI engineer and helpful assistant.\n\n> You are a friendly and knowledgeable chatbot.\n\n### Key `temperature`\n\nThe sampling temperature, between 0 and 1. Higher values like 0.8 will make the output more random, while lower values like 0.2 will make it more focused and deterministic. If set to 0, the model will use log probability to automatically increase the temperature until certain thresholds are hit.\n\nYou can pick a value between 0 and 2. For example:\n\n- `0.1`: Low temperature, extremely conservative and deterministic\n- `0.5`: Medium temperature, balanced between conservative and creative\n- `1.0`: High temperature, creative and bit random\n- `1.5`: Very high temperature, extremely creative and often chaotic and unpredictable\n- `2.0`: Maximum temperature, completely random and unpredictable, for some extreme creative use cases\n\n# The assistant\n\nTake this description of the persona:\n\n> {personaDescription}",resultingParameterName:"modelRequirements",format:"JSON",dependentParameterNames:["availableModelNames","personaDescription"]}],knowledgeSources:[],knowledgePieces:[],personas:[],preparations:[],sourceFile:"./promptbook-collection/prepare-persona.ptbk.md"}];
1556
+ var PipelineCollection = [{title:"Prepare Knowledge from Markdown",pipelineUrl:"https://promptbook.studio/promptbook/prepare-knowledge-from-markdown.book.md",parameters:[{name:"knowledgeContent",description:"Markdown document content",isInput:true,isOutput:false},{name:"knowledgePieces",description:"The knowledge JSON object",isInput:false,isOutput:true}],templates:[{templateType:"PROMPT_TEMPLATE",name:"knowledge",title:"Knowledge",content:"You are experienced data researcher, extract the important knowledge from the document.\n\n# Rules\n\n- Make pieces of information concise, clear, and easy to understand\n- One piece of information should be approximately 1 paragraph\n- Divide the paragraphs by markdown horizontal lines ---\n- Omit irrelevant information\n- Group redundant information\n- Write just extracted information, nothing else\n\n# The document\n\nTake information from this document:\n\n> {knowledgeContent}",resultingParameterName:"knowledgePieces",dependentParameterNames:["knowledgeContent"]}],knowledgeSources:[],knowledgePieces:[],personas:[],preparations:[],sourceFile:"./promptbook-collection/prepare-knowledge-from-markdown.book.md"},{title:"Prepare Keywords",pipelineUrl:"https://promptbook.studio/promptbook/prepare-knowledge-keywords.book.md",parameters:[{name:"knowledgePieceContent",description:"The content",isInput:true,isOutput:false},{name:"keywords",description:"Keywords separated by comma",isInput:false,isOutput:true}],templates:[{templateType:"PROMPT_TEMPLATE",name:"knowledge",title:"Knowledge",content:"You are experienced data researcher, detect the important keywords in the document.\n\n# Rules\n\n- Write just keywords separated by comma\n\n# The document\n\nTake information from this document:\n\n> {knowledgePieceContent}",resultingParameterName:"keywords",dependentParameterNames:["knowledgePieceContent"]}],knowledgeSources:[],knowledgePieces:[],personas:[],preparations:[],sourceFile:"./promptbook-collection/prepare-knowledge-keywords.book.md"},{title:"Prepare Title",pipelineUrl:"https://promptbook.studio/promptbook/prepare-knowledge-title.book.md",parameters:[{name:"knowledgePieceContent",description:"The content",isInput:true,isOutput:false},{name:"title",description:"The title of the document",isInput:false,isOutput:true}],templates:[{templateType:"PROMPT_TEMPLATE",name:"knowledge",title:"Knowledge",content:"You are experienced content creator, write best title for the document.\n\n# Rules\n\n- Write just title, nothing else\n- Title should be concise and clear\n- Write maximum 5 words for the title\n\n# The document\n\n> {knowledgePieceContent}",resultingParameterName:"title",expectations:{words:{min:1,max:8}},dependentParameterNames:["knowledgePieceContent"]}],knowledgeSources:[],knowledgePieces:[],personas:[],preparations:[],sourceFile:"./promptbook-collection/prepare-knowledge-title.book.md"},{title:"Prepare Keywords",pipelineUrl:"https://promptbook.studio/promptbook/prepare-persona.book.md",parameters:[{name:"availableModelNames",description:"List of available model names separated by comma (,)",isInput:true,isOutput:false},{name:"personaDescription",description:"Description of the persona",isInput:true,isOutput:false},{name:"modelRequirements",description:"Specific requirements for the model",isInput:false,isOutput:true}],templates:[{templateType:"PROMPT_TEMPLATE",name:"make-model-requirements",title:"Make modelRequirements",content:"You are experienced AI engineer, you need to create virtual assistant.\nWrite\n\n## Example\n\n```json\n{\n\"modelName\": \"gpt-4o\",\n\"systemMessage\": \"You are experienced AI engineer and helpfull assistant.\",\n\"temperature\": 0.7\n}\n```\n\n## Instructions\n\n- Your output format is JSON object\n- Write just the JSON object, no other text should be present\n- It contains the following keys:\n - `modelName`: The name of the model to use\n - `systemMessage`: The system message to provide context to the model\n - `temperature`: The sampling temperature to use\n\n### Key `modelName`\n\nPick from the following models:\n\n- {availableModelNames}\n\n### Key `systemMessage`\n\nThe system message is used to communicate instructions or provide context to the model at the beginning of a conversation. It is displayed in a different format compared to user messages, helping the model understand its role in the conversation. The system message typically guides the model's behavior, sets the tone, or specifies desired output from the model. By utilizing the system message effectively, users can steer the model towards generating more accurate and relevant responses.\n\nFor example:\n\n> You are an experienced AI engineer and helpful assistant.\n\n> You are a friendly and knowledgeable chatbot.\n\n### Key `temperature`\n\nThe sampling temperature, between 0 and 1. Higher values like 0.8 will make the output more random, while lower values like 0.2 will make it more focused and deterministic. If set to 0, the model will use log probability to automatically increase the temperature until certain thresholds are hit.\n\nYou can pick a value between 0 and 2. For example:\n\n- `0.1`: Low temperature, extremely conservative and deterministic\n- `0.5`: Medium temperature, balanced between conservative and creative\n- `1.0`: High temperature, creative and bit random\n- `1.5`: Very high temperature, extremely creative and often chaotic and unpredictable\n- `2.0`: Maximum temperature, completely random and unpredictable, for some extreme creative use cases\n\n# The assistant\n\nTake this description of the persona:\n\n> {personaDescription}",resultingParameterName:"modelRequirements",format:"JSON",dependentParameterNames:["availableModelNames","personaDescription"]}],knowledgeSources:[],knowledgePieces:[],personas:[],preparations:[],sourceFile:"./promptbook-collection/prepare-persona.book.md"}];
1549
1557
 
1550
1558
  /**
1551
1559
  * This error indicates that the promptbook in a markdown format cannot be parsed into a valid promptbook object
@@ -1720,7 +1728,7 @@ function isValidPipelineUrl(url) {
1720
1728
  if (!url.startsWith('https://')) {
1721
1729
  return false;
1722
1730
  }
1723
- if (!(url.endsWith('.book.md') || url.endsWith('.book') || url.endsWith('.ptbk.md') || url.endsWith('.ptbk'))) {
1731
+ if (!(url.endsWith('.book.md') || url.endsWith('.book') || url.endsWith('.book.md') || url.endsWith('.ptbk'))) {
1724
1732
  return false;
1725
1733
  }
1726
1734
  if (url.includes('#')) {
@@ -1789,9 +1797,9 @@ function validatePipelineCore(pipeline) {
1789
1797
  // <- Note: [🚲]
1790
1798
  throw new PipelineLogicError(spaceTrim(function (block) { return "\n Invalid promptbook URL \"".concat(pipeline.pipelineUrl, "\"\n\n ").concat(block(pipelineIdentification), "\n "); }));
1791
1799
  }
1792
- if (pipeline.promptbookVersion !== undefined && !isValidPromptbookVersion(pipeline.promptbookVersion)) {
1800
+ if (pipeline.bookVersion !== undefined && !isValidPromptbookVersion(pipeline.bookVersion)) {
1793
1801
  // <- Note: [🚲]
1794
- throw new PipelineLogicError(spaceTrim(function (block) { return "\n Invalid Promptbook Version \"".concat(pipeline.promptbookVersion, "\"\n\n ").concat(block(pipelineIdentification), "\n "); }));
1802
+ throw new PipelineLogicError(spaceTrim(function (block) { return "\n Invalid Promptbook Version \"".concat(pipeline.bookVersion, "\"\n\n ").concat(block(pipelineIdentification), "\n "); }));
1795
1803
  }
1796
1804
  // TODO: [🧠] Maybe do here some propper JSON-schema / ZOD checking
1797
1805
  if (!Array.isArray(pipeline.parameters)) {
@@ -3181,30 +3189,42 @@ function countCharacters(text) {
3181
3189
  return text.length;
3182
3190
  }
3183
3191
 
3192
+ /**
3193
+ * Number of characters per standard line with 11pt Arial font size.
3194
+ *
3195
+ * @public exported from `@promptbook/utils`
3196
+ */
3197
+ var CHARACTERS_PER_STANDARD_LINE = 63;
3198
+ /**
3199
+ * Number of lines per standard A4 page with 11pt Arial font size and standard margins and spacing.
3200
+ *
3201
+ * @public exported from `@promptbook/utils`
3202
+ */
3203
+ var LINES_PER_STANDARD_PAGE = 44;
3204
+
3184
3205
  /**
3185
3206
  * Counts number of lines in the text
3186
3207
  *
3208
+ * Note: This does not check only for the presence of newlines, but also for the length of the standard line.
3209
+ *
3187
3210
  * @public exported from `@promptbook/utils`
3188
3211
  */
3189
3212
  function countLines(text) {
3190
- if (text === '') {
3191
- return 0;
3192
- }
3193
- return text.split('\n').length;
3213
+ text = text.replace('\r\n', '\n');
3214
+ text = text.replace('\r', '\n');
3215
+ var lines = text.split('\n');
3216
+ return lines.reduce(function (count, line) { return count + Math.ceil(line.length / CHARACTERS_PER_STANDARD_LINE); }, 0);
3194
3217
  }
3195
3218
 
3196
3219
  /**
3197
3220
  * Counts number of pages in the text
3198
3221
  *
3222
+ * Note: This does not check only for the count of newlines, but also for the length of the standard line and length of the standard page.
3223
+ *
3199
3224
  * @public exported from `@promptbook/utils`
3200
3225
  */
3201
3226
  function countPages(text) {
3202
- if (text === '') {
3203
- return 0;
3204
- }
3205
- var pagesByLinesCount = Math.ceil(countLines(text) / 44);
3206
- var pagesByCharactersCount = Math.ceil(countCharacters(text) / 2772);
3207
- return Math.max(pagesByLinesCount, pagesByCharactersCount);
3227
+ return Math.ceil(countLines(text) / LINES_PER_STANDARD_PAGE);
3208
3228
  }
3209
3229
 
3210
3230
  /**
@@ -3745,7 +3765,7 @@ function executeAttempts(options) {
3745
3765
  promptTitle: template.title,
3746
3766
  promptMessage: replaceParameters(template.description || '', parameters),
3747
3767
  defaultValue: replaceParameters(preparedContent, parameters),
3748
- // TODO: [🧠] !! Figure out how to define placeholder in .ptbk.md file
3768
+ // TODO: [🧠] !! Figure out how to define placeholder in .book.md file
3749
3769
  placeholder: undefined,
3750
3770
  priority: priority,
3751
3771
  }))];
@@ -4311,7 +4331,7 @@ function executePipeline(options) {
4311
4331
  pipelineUrl: preparedPipeline.pipelineUrl,
4312
4332
  title: preparedPipeline.title,
4313
4333
  promptbookUsedVersion: PROMPTBOOK_ENGINE_VERSION,
4314
- promptbookRequestedVersion: preparedPipeline.promptbookVersion,
4334
+ promptbookRequestedVersion: preparedPipeline.bookVersion,
4315
4335
  description: preparedPipeline.description,
4316
4336
  promptExecutions: [],
4317
4337
  };
@@ -4660,7 +4680,7 @@ function preparePersona(personaDescription, tools, options) {
4660
4680
  collection = createCollectionFromJson.apply(void 0, __spreadArray([], __read(PipelineCollection), false));
4661
4681
  _b = createPipelineExecutor;
4662
4682
  _c = {};
4663
- return [4 /*yield*/, collection.getPipelineByUrl('https://promptbook.studio/promptbook/prepare-persona.ptbk.md')];
4683
+ return [4 /*yield*/, collection.getPipelineByUrl('https://promptbook.studio/promptbook/prepare-persona.book.md')];
4664
4684
  case 1:
4665
4685
  preparePersonaExecutor = _b.apply(void 0, [(_c.pipeline = _d.sent(),
4666
4686
  _c.tools = tools,
@@ -5417,12 +5437,12 @@ TODO: [🧊] This is how it can look in future
5417
5437
  */
5418
5438
  function clonePipeline(pipeline) {
5419
5439
  // Note: Not using spread operator (...) because @@@
5420
- var pipelineUrl = pipeline.pipelineUrl, sourceFile = pipeline.sourceFile, title = pipeline.title, promptbookVersion = pipeline.promptbookVersion, description = pipeline.description, parameters = pipeline.parameters, templates = pipeline.templates, knowledgeSources = pipeline.knowledgeSources, knowledgePieces = pipeline.knowledgePieces, personas = pipeline.personas, preparations = pipeline.preparations;
5440
+ var pipelineUrl = pipeline.pipelineUrl, sourceFile = pipeline.sourceFile, title = pipeline.title, bookVersion = pipeline.bookVersion, description = pipeline.description, parameters = pipeline.parameters, templates = pipeline.templates, knowledgeSources = pipeline.knowledgeSources, knowledgePieces = pipeline.knowledgePieces, personas = pipeline.personas, preparations = pipeline.preparations;
5421
5441
  return {
5422
5442
  pipelineUrl: pipelineUrl,
5423
5443
  sourceFile: sourceFile,
5424
5444
  title: title,
5425
- promptbookVersion: promptbookVersion,
5445
+ bookVersion: bookVersion,
5426
5446
  description: description,
5427
5447
  parameters: parameters,
5428
5448
  templates: templates,
@@ -5634,7 +5654,7 @@ var knowledgeCommandParser = {
5634
5654
  throw new ParseError("Source not valid");
5635
5655
  }
5636
5656
  if (sourceContent.startsWith('../') || sourceContent.startsWith('/') || /^[A-Z]:[\\/]+/i.test(sourceContent)) {
5637
- throw new ParseError("Source cannot be outside of the .ptbk.md folder");
5657
+ throw new ParseError("Source cannot be outside of the .book.md folder");
5638
5658
  }
5639
5659
  return {
5640
5660
  type: 'KNOWLEDGE',
@@ -6284,7 +6304,7 @@ function validateParameterName(parameterName) {
6284
6304
  /**
6285
6305
  * Parses the foreach command
6286
6306
  *
6287
- * Note: @@@ This command is used as foreach for new commands - it should NOT be used in any `.ptbk.md` file
6307
+ * Note: @@@ This command is used as foreach for new commands - it should NOT be used in any `.book.md` file
6288
6308
  *
6289
6309
  * @see `documentationUrl` for more details
6290
6310
  * @private within the commands folder
@@ -6434,7 +6454,7 @@ var foreachCommandParser = {
6434
6454
  },
6435
6455
  };
6436
6456
  /**
6437
- * TODO: [🍭] Make .ptbk.md file with examples of the FOREACH with wrong parsing and logic
6457
+ * TODO: [🍭] Make .book.md file with examples of the FOREACH with wrong parsing and logic
6438
6458
  */
6439
6459
 
6440
6460
  /**
@@ -7068,7 +7088,7 @@ var bookVersionCommandParser = {
7068
7088
  /**
7069
7089
  * Description of the BOOK_VERSION command
7070
7090
  */
7071
- description: "Which version of the Book language is the .ptbk.md using",
7091
+ description: "Which version of the Book language is the .book.md using",
7072
7092
  /**
7073
7093
  * Link to documentation
7074
7094
  */
@@ -7082,19 +7102,19 @@ var bookVersionCommandParser = {
7082
7102
  */
7083
7103
  parse: function (input) {
7084
7104
  var args = input.args;
7085
- var promptbookVersion = args.pop();
7086
- if (promptbookVersion === undefined) {
7105
+ var bookVersion = args.pop();
7106
+ if (bookVersion === undefined) {
7087
7107
  throw new ParseError("Version is required");
7088
7108
  }
7089
- if (!isValidPromptbookVersion(promptbookVersion)) {
7090
- throw new ParseError("Invalid Promptbook version \"".concat(promptbookVersion, "\""));
7109
+ if (!isValidPromptbookVersion(bookVersion)) {
7110
+ throw new ParseError("Invalid Promptbook version \"".concat(bookVersion, "\""));
7091
7111
  }
7092
7112
  if (args.length > 0 && !(((args.length === 1 && args[0]) || '').toUpperCase() === 'VERSION')) {
7093
7113
  throw new ParseError("Can not have more than one Promptbook version");
7094
7114
  }
7095
7115
  return {
7096
7116
  type: 'BOOK_VERSION',
7097
- promptbookVersion: promptbookVersion,
7117
+ bookVersion: bookVersion,
7098
7118
  };
7099
7119
  },
7100
7120
  /**
@@ -7104,7 +7124,7 @@ var bookVersionCommandParser = {
7104
7124
  */
7105
7125
  $applyToPipelineJson: function (command, $pipelineJson) {
7106
7126
  // TODO: Warn if the version is overridden
7107
- $pipelineJson.promptbookVersion = command.promptbookVersion;
7127
+ $pipelineJson.bookVersion = command.bookVersion;
7108
7128
  },
7109
7129
  /**
7110
7130
  * Converts the BOOK_VERSION command back to string
@@ -7157,9 +7177,9 @@ var urlCommandParser = {
7157
7177
  * Example usages of the URL command
7158
7178
  */
7159
7179
  examples: [
7160
- 'PIPELINE URL https://promptbook.studio/library/write-cv.ptbk.md',
7161
- 'URL https://promptbook.studio/library/write-cv.ptbk.md',
7162
- 'https://promptbook.studio/library/write-cv.ptbk.md',
7180
+ 'PIPELINE URL https://promptbook.studio/library/write-cv.book.md',
7181
+ 'URL https://promptbook.studio/library/write-cv.book.md',
7182
+ 'https://promptbook.studio/library/write-cv.book.md',
7163
7183
  ],
7164
7184
  /**
7165
7185
  * Parses the URL command
@@ -7360,7 +7380,7 @@ var instrumentCommandParser = {
7360
7380
  /**
7361
7381
  * Parses the boilerplate command
7362
7382
  *
7363
- * Note: @@@ This command is used as boilerplate for new commands - it should NOT be used in any `.ptbk.md` file
7383
+ * Note: @@@ This command is used as boilerplate for new commands - it should NOT be used in any `.book.md` file
7364
7384
  *
7365
7385
  * @see `documentationUrl` for more details
7366
7386
  * @private within the commands folder
@@ -7414,7 +7434,7 @@ var boilerplateCommandParser = {
7414
7434
  * Note: `$` is used to indicate that this function mutates given `pipelineJson`
7415
7435
  */
7416
7436
  $applyToPipelineJson: function (command, $pipelineJson) {
7417
- throw new ParseError("BOILERPLATE command is only for testing purposes and should not be used in the .ptbk.md file");
7437
+ throw new ParseError("BOILERPLATE command is only for testing purposes and should not be used in the .book.md file");
7418
7438
  },
7419
7439
  /**
7420
7440
  * Apply the BOILERPLATE command to the `pipelineJson`
@@ -7422,7 +7442,7 @@ var boilerplateCommandParser = {
7422
7442
  * Note: `$` is used to indicate that this function mutates given `templateJson`
7423
7443
  */
7424
7444
  $applyToTemplateJson: function (command, $templateJson, $pipelineJson) {
7425
- throw new ParseError("BOILERPLATE command is only for testing purposes and should not be used in the .ptbk.md file");
7445
+ throw new ParseError("BOILERPLATE command is only for testing purposes and should not be used in the .book.md file");
7426
7446
  },
7427
7447
  /**
7428
7448
  * Converts the BOILERPLATE command back to string
@@ -7438,7 +7458,7 @@ var boilerplateCommandParser = {
7438
7458
  * Note: This is used in `pipelineJsonToString` utility
7439
7459
  */
7440
7460
  takeFromPipelineJson: function (pipelineJson) {
7441
- throw new ParseError("BOILERPLATE command is only for testing purposes and should not be used in the .ptbk.md file");
7461
+ throw new ParseError("BOILERPLATE command is only for testing purposes and should not be used in the .book.md file");
7442
7462
  },
7443
7463
  /**
7444
7464
  * Reads the BOILERPLATE command from the `TemplateJson`
@@ -7446,7 +7466,7 @@ var boilerplateCommandParser = {
7446
7466
  * Note: This is used in `pipelineJsonToString` utility
7447
7467
  */
7448
7468
  takeFromTemplateJson: function ($templateJson) {
7449
- throw new ParseError("BOILERPLATE command is only for testing purposes and should not be used in the .ptbk.md file");
7469
+ throw new ParseError("BOILERPLATE command is only for testing purposes and should not be used in the .book.md file");
7450
7470
  },
7451
7471
  };
7452
7472
 
@@ -7775,7 +7795,7 @@ function splitMarkdownIntoSections(markdown) {
7775
7795
  return;
7776
7796
  }
7777
7797
  if (!section.startsWith('#')) {
7778
- section = "# Untitled\n\n".concat(section);
7798
+ section = "# ".concat(DEFAULT_TITLE, "\n\n").concat(section);
7779
7799
  }
7780
7800
  sections.push(section);
7781
7801
  buffer = [];
@@ -7839,7 +7859,7 @@ function flattenMarkdown(markdown) {
7839
7859
  var e_1, _a;
7840
7860
  var sections = splitMarkdownIntoSections(markdown);
7841
7861
  if (sections.length === 0) {
7842
- return '# Untitled';
7862
+ return "# ".concat(DEFAULT_TITLE);
7843
7863
  }
7844
7864
  var flattenedMarkdown = '';
7845
7865
  var parsedSections = sections.map(parseMarkdownSection);
@@ -7850,7 +7870,7 @@ function flattenMarkdown(markdown) {
7850
7870
  }
7851
7871
  else {
7852
7872
  parsedSections.unshift(firstSection);
7853
- flattenedMarkdown += "# Untitled" + "\n\n"; // <- [🧠] Maybe 3 new lines?
7873
+ flattenedMarkdown += "# ".concat(DEFAULT_TITLE) + "\n\n"; // <- [🧠] Maybe 3 new lines?
7854
7874
  }
7855
7875
  try {
7856
7876
  for (var parsedSections_1 = __values(parsedSections), parsedSections_1_1 = parsedSections_1.next(); !parsedSections_1_1.done; parsedSections_1_1 = parsedSections_1.next()) {
@@ -7922,8 +7942,8 @@ function titleToName(value) {
7922
7942
  * Note: This function does not validate logic of the pipeline only the parsing
7923
7943
  * Note: This function acts as compilation process
7924
7944
  *
7925
- * @param pipelineString {Promptbook} in string markdown format (.ptbk.md)
7926
- * @returns {Promptbook} compiled in JSON format (.ptbk.json)
7945
+ * @param pipelineString {Promptbook} in string markdown format (.book.md)
7946
+ * @returns {Promptbook} compiled in JSON format (.book.json)
7927
7947
  * @throws {ParseError} if the promptbook string is not valid
7928
7948
  * @public exported from `@promptbook/core`
7929
7949
  */
@@ -7932,7 +7952,7 @@ function pipelineStringToJsonSync(pipelineString) {
7932
7952
  var $pipelineJson = {
7933
7953
  title: undefined /* <- Note: [🍙] Putting here placeholder to keep `title` on top at final JSON */,
7934
7954
  pipelineUrl: undefined /* <- Note: Putting here placeholder to keep `pipelineUrl` on top at final JSON */,
7935
- promptbookVersion: undefined /* <- Note: By default no explicit version */,
7955
+ bookVersion: undefined /* <- Note: By default no explicit version */,
7936
7956
  description: undefined /* <- Note: [🍙] Putting here placeholder to keep `description` on top at final JSON */,
7937
7957
  parameters: [],
7938
7958
  templates: [],
@@ -8315,10 +8335,10 @@ function pipelineStringToJsonSync(pipelineString) {
8315
8335
  * Note: This function does not validate logic of the pipeline only the parsing
8316
8336
  * Note: This function acts as compilation process
8317
8337
  *
8318
- * @param pipelineString {Promptbook} in string markdown format (.ptbk.md)
8338
+ * @param pipelineString {Promptbook} in string markdown format (.book.md)
8319
8339
  * @param tools - Tools for the preparation and scraping - if not provided together with `llm`, the preparation will be skipped
8320
8340
  * @param options - Options and tools for the compilation
8321
- * @returns {Promptbook} compiled in JSON format (.ptbk.json)
8341
+ * @returns {Promptbook} compiled in JSON format (.book.json)
8322
8342
  * @throws {ParseError} if the promptbook string is not valid
8323
8343
  * @public exported from `@promptbook/core`
8324
8344
  */
@@ -9690,13 +9710,13 @@ function createCollectionFromDirectory(path, tools, options) {
9690
9710
  return [4 /*yield*/, listAllFiles(path, isRecursive, tools.fs)];
9691
9711
  case 1:
9692
9712
  fileNames = _b.sent();
9693
- // Note: First load all .ptbk.json and then .ptbk.md files
9694
- // .ptbk.json can be prepared so it is faster to load
9713
+ // Note: First load all .book.json and then .book.md files
9714
+ // .book.json can be prepared so it is faster to load
9695
9715
  fileNames.sort(function (a, b) {
9696
- if (a.endsWith('.ptbk.json') && b.endsWith('.ptbk.md')) {
9716
+ if (a.endsWith('.book.json') && b.endsWith('.book.md')) {
9697
9717
  return -1;
9698
9718
  }
9699
- if (a.endsWith('.ptbk.md') && b.endsWith('.ptbk.json')) {
9719
+ if (a.endsWith('.book.md') && b.endsWith('.book.json')) {
9700
9720
  return 1;
9701
9721
  }
9702
9722
  return 0;
@@ -9713,7 +9733,7 @@ function createCollectionFromDirectory(path, tools, options) {
9713
9733
  case 1:
9714
9734
  _e.trys.push([1, 8, , 9]);
9715
9735
  pipeline = null;
9716
- if (!fileName.endsWith('.ptbk.md')) return [3 /*break*/, 4];
9736
+ if (!fileName.endsWith('.book.md')) return [3 /*break*/, 4];
9717
9737
  return [4 /*yield*/, readFile(fileName, 'utf-8')];
9718
9738
  case 2:
9719
9739
  pipelineString = (_e.sent());
@@ -9725,7 +9745,7 @@ function createCollectionFromDirectory(path, tools, options) {
9725
9745
  pipeline = __assign(__assign({}, pipeline), { sourceFile: sourceFile });
9726
9746
  return [3 /*break*/, 7];
9727
9747
  case 4:
9728
- if (!fileName.endsWith('.ptbk.json')) return [3 /*break*/, 6];
9748
+ if (!fileName.endsWith('.book.json')) return [3 /*break*/, 6];
9729
9749
  _d = (_c = JSON).parse;
9730
9750
  return [4 /*yield*/, readFile(fileName, 'utf-8')];
9731
9751
  case 5:
@@ -9893,7 +9913,7 @@ function stringifyPipelineJson(pipeline) {
9893
9913
  return pipelineJsonStringified;
9894
9914
  }
9895
9915
  /**
9896
- * TODO: [🐝] Not Working propperly @see https://promptbook.studio/examples/mixed-knowledge.ptbk.md
9916
+ * TODO: [🐝] Not Working propperly @see https://promptbook.studio/examples/mixed-knowledge.book.md
9897
9917
  * TODO: [🧠][0] Maybe rename to `stringifyPipelineJson`, `stringifyIndexedJson`,...
9898
9918
  * TODO: [🧠] Maybe more elegant solution than replacing via regex
9899
9919
  * TODO: [🍙] Make some standard order of json properties
@@ -10074,7 +10094,7 @@ var FileCacheStorage = /** @class */ (function () {
10074
10094
  */
10075
10095
 
10076
10096
  /**
10077
- * Stores
10097
+ * Stores data in memory (HEAP)
10078
10098
  *
10079
10099
  * @public exported from `@promptbook/core`
10080
10100
  */
@@ -10204,13 +10224,18 @@ function cacheLlmTools(llmTools, options) {
10204
10224
  promptResult = _c.sent();
10205
10225
  return [3 /*break*/, 11];
10206
10226
  case 10: throw new PipelineExecutionError("Unknown model variant \"".concat(prompt.modelRequirements.modelVariant, "\""));
10207
- case 11: return [4 /*yield*/, storage.setItem(key, {
10227
+ case 11:
10228
+ // TODO: [🧠] !!!!! How to do timing in mixed cache / non-cache situation
10229
+ // promptResult.timing: FromtoItems
10230
+ return [4 /*yield*/, storage.setItem(key, {
10208
10231
  date: $currentDate(),
10209
10232
  promptbookVersion: PROMPTBOOK_ENGINE_VERSION,
10210
10233
  prompt: prompt,
10211
10234
  promptResult: promptResult,
10212
10235
  })];
10213
10236
  case 12:
10237
+ // TODO: [🧠] !!!!! How to do timing in mixed cache / non-cache situation
10238
+ // promptResult.timing: FromtoItems
10214
10239
  _c.sent();
10215
10240
  return [2 /*return*/, promptResult];
10216
10241
  }
@@ -10618,7 +10643,7 @@ function prettifyPipelineString(pipelineString, options) {
10618
10643
  function initializePrettifyCommand(program) {
10619
10644
  var _this = this;
10620
10645
  var prettifyCommand = program.command('prettify');
10621
- prettifyCommand.description(spaceTrim$1("\n Iterates over `.ptbk.md` files and does multiple enhancing operations on them:\n\n 1) Adds Mermaid graph\n 2) Prettifies the markdown\n "));
10646
+ prettifyCommand.description(spaceTrim$1("\n Iterates over `.book.md` files and does multiple enhancing operations on them:\n\n 1) Adds Mermaid graph\n 2) Prettifies the markdown\n "));
10622
10647
  prettifyCommand.argument('<filesGlob>',
10623
10648
  // <- TODO: [🧟‍♂️] Unite path to promptbook collection argument
10624
10649
  'Pipelines to prettify as glob pattern');
@@ -10642,7 +10667,7 @@ function initializePrettifyCommand(program) {
10642
10667
  case 3:
10643
10668
  if (!!filenames_1_1.done) return [3 /*break*/, 10];
10644
10669
  filename = filenames_1_1.value;
10645
- if (!filename.endsWith('.ptbk.md') && isVerbose) {
10670
+ if (!filename.endsWith('.book.md') && isVerbose) {
10646
10671
  console.info(colors.gray("Skipping ".concat(filename)));
10647
10672
  return [3 /*break*/, 9];
10648
10673
  }
@@ -11041,25 +11066,29 @@ function initializeRunCommand(program) {
11041
11066
  runCommand.description(spaceTrim$1("\n Runs a pipeline\n "));
11042
11067
  // TODO: [🧅] DRY command arguments
11043
11068
  runCommand.argument('<path>',
11044
- // <- Note: [🧟‍♂️] This is NOT promptbook collection directory BUT direct path to .ptbk.md file
11069
+ // <- Note: [🧟‍♂️] This is NOT promptbook collection directory BUT direct path to .book.md file
11045
11070
  'Path to book file');
11046
11071
  runCommand.option('-r, --reload', "Call LLM models even if same prompt with result is in the cache", false);
11047
11072
  runCommand.option('-v, --verbose', "Is output verbose", false);
11048
- runCommand.option('--no-interactive', "Input is not interactive", false);
11073
+ runCommand.option('--no-interactive', "Input is not interactive, if true you need to pass all the input parameters through --json");
11074
+ runCommand.option('-j, --json <json>', "Pass all or some input parameters as JSON record, if used the output is also returned as JSON");
11049
11075
  runCommand.option('-s, --save-report <path>', "Save report to file");
11050
- // TODO: !!!!!! Implement non-interactive mode - allow to pass input parameters as JSON
11051
- // TODO: !!!!!! JSON output
11052
11076
  runCommand.action(function (filePathRaw, options) { return __awaiter(_this, void 0, void 0, function () {
11053
- var isCacheReloaded, isVerbose, saveReport, prepareAndScrapeOptions, fs, filePath, filePathCandidates, filePathCandidates_1, filePathCandidates_1_1, filePathCandidate, e_1_1, llm, executables, tools, pipelineString, pipeline, error_1, pipelineExecutor, questions, response, inputParameters, result, isSuccessful, errors, warnings, outputParameters, executionReport, executionReportString, _a, _b, error, _c, _d, warning, _e, _f, key, value, separator;
11077
+ var isCacheReloaded, isInteractive, json, isVerbose, saveReport, inputParameters, prepareAndScrapeOptions, fs, filePath, filePathCandidates, filePathCandidates_1, filePathCandidates_1_1, filePathCandidate, e_1_1, llm, executables, tools, pipelineString, pipeline, error_1, pipelineExecutor, questions, response, result, isSuccessful, errors, warnings, outputParameters, executionReport, executionReportString, _a, _b, error, _c, _d, warning, _e, _f, key, value, separator;
11054
11078
  var e_1, _g, _h, e_2, _j, e_3, _k, e_4, _l;
11055
11079
  return __generator(this, function (_m) {
11056
11080
  switch (_m.label) {
11057
11081
  case 0:
11058
- isCacheReloaded = options.reload, options.interactive, isVerbose = options.verbose, saveReport = options.saveReport;
11082
+ isCacheReloaded = options.reload, isInteractive = options.interactive, json = options.json, isVerbose = options.verbose, saveReport = options.saveReport;
11059
11083
  if (saveReport && !saveReport.endsWith('.json') && !saveReport.endsWith('.md')) {
11060
11084
  console.error(colors.red("Report file must be .json or .md"));
11061
11085
  return [2 /*return*/, process.exit(1)];
11062
11086
  }
11087
+ inputParameters = {};
11088
+ if (json) {
11089
+ inputParameters = JSON.parse(json);
11090
+ // <- TODO: Maybe check shape of passed JSON and if its valid parameters Record
11091
+ }
11063
11092
  prepareAndScrapeOptions = {
11064
11093
  isVerbose: isVerbose,
11065
11094
  isCacheReloaded: isCacheReloaded,
@@ -11073,7 +11102,7 @@ function initializeRunCommand(program) {
11073
11102
  filePathRaw,
11074
11103
  "".concat(filePathRaw, ".md"),
11075
11104
  "".concat(filePathRaw, ".book.md"),
11076
- "".concat(filePathRaw, ".ptbk.md"),
11105
+ "".concat(filePathRaw, ".book.md"),
11077
11106
  ];
11078
11107
  _m.label = 1;
11079
11108
  case 1:
@@ -11177,8 +11206,8 @@ function initializeRunCommand(program) {
11177
11206
  tools: tools,
11178
11207
  isNotPreparedWarningSupressed: true,
11179
11208
  maxExecutionAttempts: 3,
11180
- // <- TODO: !!!!!! Why "LLM execution failed undefinedx"
11181
- maxParallelCount: 1, // <- TODO: !!!!!! Pass
11209
+ // <- TODO: Why "LLM execution failed undefinedx"
11210
+ maxParallelCount: 1, // <- TODO: Pass CLI argument
11182
11211
  });
11183
11212
  if (isVerbose) {
11184
11213
  console.info(colors.gray('--- Getting input parameters ---'));
@@ -11187,13 +11216,17 @@ function initializeRunCommand(program) {
11187
11216
  .filter(function (_a) {
11188
11217
  var isInput = _a.isInput;
11189
11218
  return isInput;
11219
+ })
11220
+ .filter(function (_a) {
11221
+ var name = _a.name;
11222
+ return typeof inputParameters[name] !== 'string';
11190
11223
  })
11191
11224
  .map(function (_a) {
11192
11225
  var name = _a.name, exampleValues = _a.exampleValues;
11193
11226
  var message = name;
11194
11227
  var initial = '';
11195
11228
  if (exampleValues && exampleValues.length > 0) {
11196
- var exampleValuesFiltered = exampleValues.filter(function (exampleValue) { return countLines(exampleValue) <= 1 && countCharacters(exampleValue) <= 30; });
11229
+ var exampleValuesFiltered = exampleValues.filter(function (exampleValue) { return countLines(exampleValue) <= 1; });
11197
11230
  if (exampleValuesFiltered.length !== 0) {
11198
11231
  message += " (e.g. ".concat(exampleValuesFiltered.join(', '), ")");
11199
11232
  }
@@ -11207,10 +11240,44 @@ function initializeRunCommand(program) {
11207
11240
  // TODO: Maybe use> validate: value => value < 18 ? `Forbidden` : true
11208
11241
  };
11209
11242
  });
11243
+ if (isInteractive === false && questions.length !== 0) {
11244
+ console.error(colors.red(spaceTrim$1(function (block) { return "\n When using --no-interactive you need to pass all the input parameters through --json\n\n You are missing:\n ".concat(block(pipeline.parameters
11245
+ .filter(function (_a) {
11246
+ var isInput = _a.isInput;
11247
+ return isInput;
11248
+ })
11249
+ .filter(function (_a) {
11250
+ var parameterName = _a.name;
11251
+ return !questions.some(function (_a) {
11252
+ var questionName = _a.name;
11253
+ return questionName === parameterName;
11254
+ });
11255
+ })
11256
+ .map(function (_a) {
11257
+ var name = _a.name, description = _a.description;
11258
+ return "- **".concat(name, "** ").concat(description);
11259
+ })
11260
+ .join('\n')), "\n\n Example:\n --json '").concat(JSON.stringify(Object.fromEntries(pipeline.parameters
11261
+ .filter(function (_a) {
11262
+ var isInput = _a.isInput;
11263
+ return isInput;
11264
+ })
11265
+ .map(function (_a) {
11266
+ var name = _a.name, exampleValues = _a.exampleValues;
11267
+ return [
11268
+ name,
11269
+ inputParameters[name] || (exampleValues || [])[0] || '...',
11270
+ ];
11271
+ })))
11272
+ .split("'")
11273
+ .join("\\'"), "'\n "); })));
11274
+ return [2 /*return*/, process.exit(1)];
11275
+ }
11210
11276
  return [4 /*yield*/, prompts(questions)];
11211
11277
  case 16:
11212
11278
  response = _m.sent();
11213
- inputParameters = response;
11279
+ inputParameters = __assign(__assign({}, inputParameters), response);
11280
+ // TODO: Maybe do some validation of the response (and --json argument which is passed)
11214
11281
  if (isVerbose) {
11215
11282
  console.info(colors.gray('--- Executing ---'));
11216
11283
  }
@@ -11247,7 +11314,9 @@ function initializeRunCommand(program) {
11247
11314
  console.info(colors.gray('--- Usage ---'));
11248
11315
  console.info(colors.cyan(usageToHuman(result.usage)));
11249
11316
  }
11250
- console.info(colors.gray('--- Result ---'));
11317
+ if (json === undefined || isVerbose === true) {
11318
+ console.info(colors.gray('--- Result ---'));
11319
+ }
11251
11320
  try {
11252
11321
  // TODO: [🧠] Should be errors or warnings shown first
11253
11322
  for (_a = __values(errors || []), _b = _a.next(); !_b.done; _b = _a.next()) {
@@ -11275,20 +11344,25 @@ function initializeRunCommand(program) {
11275
11344
  }
11276
11345
  finally { if (e_3) throw e_3.error; }
11277
11346
  }
11278
- try {
11279
- for (_e = __values(Object.keys(outputParameters)), _f = _e.next(); !_f.done; _f = _e.next()) {
11280
- key = _f.value;
11281
- value = outputParameters[key] || colors.grey(colors.italic('(nothing)'));
11282
- separator = countLines(value) > 1 || countWords(value) > 100 ? ':\n' : ': ';
11283
- console.info(colors.green(colors.bold(key) + separator + value));
11284
- }
11285
- }
11286
- catch (e_4_1) { e_4 = { error: e_4_1 }; }
11287
- finally {
11347
+ if (json === undefined) {
11288
11348
  try {
11289
- if (_f && !_f.done && (_l = _e.return)) _l.call(_e);
11349
+ for (_e = __values(Object.keys(outputParameters)), _f = _e.next(); !_f.done; _f = _e.next()) {
11350
+ key = _f.value;
11351
+ value = outputParameters[key] || colors.grey(colors.italic('(nothing)'));
11352
+ separator = countLines(value) > 1 || countWords(value) > 100 ? ':\n' : ': ';
11353
+ console.info(colors.green(colors.bold(key) + separator + value));
11354
+ }
11355
+ }
11356
+ catch (e_4_1) { e_4 = { error: e_4_1 }; }
11357
+ finally {
11358
+ try {
11359
+ if (_f && !_f.done && (_l = _e.return)) _l.call(_e);
11360
+ }
11361
+ finally { if (e_4) throw e_4.error; }
11290
11362
  }
11291
- finally { if (e_4) throw e_4.error; }
11363
+ }
11364
+ else {
11365
+ console.info(JSON.stringify(outputParameters, null, 4));
11292
11366
  }
11293
11367
  return [2 /*return*/, process.exit(0)];
11294
11368
  }
@@ -11296,7 +11370,7 @@ function initializeRunCommand(program) {
11296
11370
  }); });
11297
11371
  }
11298
11372
  /**
11299
- * TODO: !!!!!! Catch and wrap all errors from CLI
11373
+ * TODO: !!!!! Catch and wrap all errors from CLI
11300
11374
  * TODO: [🧠] Pass `maxExecutionAttempts`, `csvSettings`
11301
11375
  * TODO: [🥃][main] !!! Allow `ptbk run` without configuring any llm tools
11302
11376
  * Note: [🟡] Code in this file should never be published outside of `@promptbook/cli`
@@ -11311,7 +11385,7 @@ function initializeRunCommand(program) {
11311
11385
  function initializeTestCommand(program) {
11312
11386
  var _this = this;
11313
11387
  var testCommand = program.command('test');
11314
- testCommand.description(spaceTrim$1("\n Iterates over `.ptbk.md` and `.ptbk.json` and checks if they are parsable and logically valid\n "));
11388
+ testCommand.description(spaceTrim$1("\n Iterates over `.book.md` and `.book.json` and checks if they are parsable and logically valid\n "));
11315
11389
  testCommand.argument('<filesGlob>',
11316
11390
  // <- TODO: [🧟‍♂️] Unite path to promptbook collection argument
11317
11391
  'Pipelines to test as glob pattern');
@@ -11361,7 +11435,7 @@ function initializeTestCommand(program) {
11361
11435
  case 6:
11362
11436
  _f.trys.push([6, 13, , 14]);
11363
11437
  pipeline = void 0;
11364
- if (!filename.endsWith('.ptbk.md')) return [3 /*break*/, 9];
11438
+ if (!filename.endsWith('.book.md')) return [3 /*break*/, 9];
11365
11439
  return [4 /*yield*/, readFile(filename, 'utf-8')];
11366
11440
  case 7:
11367
11441
  pipelineMarkdown = (_f.sent());
@@ -11373,7 +11447,7 @@ function initializeTestCommand(program) {
11373
11447
  }
11374
11448
  _f.label = 9;
11375
11449
  case 9:
11376
- if (!filename.endsWith('.ptbk.json')) return [3 /*break*/, 11];
11450
+ if (!filename.endsWith('.book.json')) return [3 /*break*/, 11];
11377
11451
  _c = (_b = JSON).parse;
11378
11452
  return [4 /*yield*/, readFile(filename, 'utf-8')];
11379
11453
  case 10:
@@ -11460,13 +11534,16 @@ function promptbookCli() {
11460
11534
  });
11461
11535
  }
11462
11536
  /**
11463
- * TODO: [🧠] Maybe `run` command the default, instead of `ptbk run ./foo.ptbk.md` -> `ptbk ./foo.ptbk.md`
11537
+ * TODO: [🧠] Maybe `run` command the default, instead of `ptbk run ./foo.book.md` -> `ptbk ./foo.book.md`
11464
11538
  * TODO: [🥠] Do not export, its just for CLI script
11465
11539
  * TODO: [🕌] When more functionalities, rename
11466
11540
  * Note: 11:11
11467
11541
  * Note: [🟡] Code in this file should never be published outside of `@promptbook/cli`
11468
11542
  */
11469
11543
 
11544
+ /**
11545
+ * Note: [🔺] Purpose of this file is to export CLI for production environment
11546
+ */
11470
11547
  /**
11471
11548
  * Hidden utilities which should not be used by external consumers.
11472
11549
  *
@@ -11474,7 +11551,7 @@ function promptbookCli() {
11474
11551
  */
11475
11552
  var _CLI = {
11476
11553
  // Note: [🥠]
11477
- _initialize: promptbookCli,
11554
+ _initialize_promptbookCli: promptbookCli,
11478
11555
  };
11479
11556
  /**
11480
11557
  * Note: [🟡] Code in this file should never be published outside of `@promptbook/cli`
@@ -14028,7 +14105,7 @@ var MarkdownScraper = /** @class */ (function () {
14028
14105
  collection = createCollectionFromJson.apply(void 0, __spreadArray([], __read(PipelineCollection), false));
14029
14106
  _d = createPipelineExecutor;
14030
14107
  _g = {};
14031
- return [4 /*yield*/, collection.getPipelineByUrl('https://promptbook.studio/promptbook/prepare-knowledge-from-markdown.ptbk.md')];
14108
+ return [4 /*yield*/, collection.getPipelineByUrl('https://promptbook.studio/promptbook/prepare-knowledge-from-markdown.book.md')];
14032
14109
  case 1:
14033
14110
  prepareKnowledgeFromMarkdownExecutor = _d.apply(void 0, [(_g.pipeline = _k.sent(),
14034
14111
  _g.tools = {
@@ -14037,7 +14114,7 @@ var MarkdownScraper = /** @class */ (function () {
14037
14114
  _g)]);
14038
14115
  _e = createPipelineExecutor;
14039
14116
  _h = {};
14040
- return [4 /*yield*/, collection.getPipelineByUrl('https://promptbook.studio/promptbook/prepare-knowledge-title.ptbk.md')];
14117
+ return [4 /*yield*/, collection.getPipelineByUrl('https://promptbook.studio/promptbook/prepare-knowledge-title.book.md')];
14041
14118
  case 2:
14042
14119
  prepareTitleExecutor = _e.apply(void 0, [(_h.pipeline = _k.sent(),
14043
14120
  _h.tools = {
@@ -14046,7 +14123,7 @@ var MarkdownScraper = /** @class */ (function () {
14046
14123
  _h)]);
14047
14124
  _f = createPipelineExecutor;
14048
14125
  _j = {};
14049
- return [4 /*yield*/, collection.getPipelineByUrl('https://promptbook.studio/promptbook/prepare-knowledge-keywords.ptbk.md')];
14126
+ return [4 /*yield*/, collection.getPipelineByUrl('https://promptbook.studio/promptbook/prepare-knowledge-keywords.book.md')];
14050
14127
  case 3:
14051
14128
  prepareKeywordsExecutor = _f.apply(void 0, [(_j.pipeline = _k.sent(),
14052
14129
  _j.tools = {