@promptbook/markdown-utils 0.74.0-8 → 0.75.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.
Files changed (53) hide show
  1. package/README.md +2 -11
  2. package/esm/index.es.js +54 -32
  3. package/esm/index.es.js.map +1 -1
  4. package/esm/typings/promptbook-collection/index.d.ts +3 -0
  5. package/esm/typings/src/_packages/core.index.d.ts +17 -1
  6. package/esm/typings/src/_packages/types.index.d.ts +10 -0
  7. package/esm/typings/src/_packages/utils.index.d.ts +4 -0
  8. package/esm/typings/src/cli/cli-commands/run.d.ts +1 -1
  9. package/esm/typings/src/cli/main.d.ts +4 -1
  10. package/esm/typings/src/cli/promptbookCli.d.ts +1 -1
  11. package/esm/typings/src/cli/test/ptbk.d.ts +1 -1
  12. package/esm/typings/src/collection/collectionToJson.test.d.ts +1 -1
  13. package/esm/typings/src/collection/constructors/createCollectionFromDirectory.d.ts +1 -1
  14. package/esm/typings/src/commands/BOOK_VERSION/BookVersionCommand.d.ts +1 -1
  15. package/esm/typings/src/commands/FOREACH/foreachCommandParser.d.ts +2 -2
  16. package/esm/typings/src/commands/FORMFACTOR/FormfactorCommand.d.ts +11 -0
  17. package/esm/typings/src/commands/FORMFACTOR/formfactorCommand.test.d.ts +1 -0
  18. package/esm/typings/src/commands/FORMFACTOR/formfactorCommandParser.d.ts +11 -0
  19. package/esm/typings/src/commands/_BOILERPLATE/boilerplateCommandParser.d.ts +1 -1
  20. package/esm/typings/src/commands/_common/types/CommandParser.d.ts +2 -0
  21. package/esm/typings/src/commands/index.d.ts +1 -1
  22. package/esm/typings/src/config.d.ts +6 -0
  23. package/esm/typings/src/conversion/pipelineJsonToString.d.ts +3 -3
  24. package/esm/typings/src/conversion/pipelineStringToJson.d.ts +2 -2
  25. package/esm/typings/src/conversion/pipelineStringToJsonSync.d.ts +2 -2
  26. package/esm/typings/src/conversion/utils/stringifyPipelineJson.d.ts +1 -1
  27. package/esm/typings/src/conversion/validation/_importPipeline.d.ts +7 -7
  28. package/esm/typings/src/formats/_common/FormatDefinition.d.ts +1 -1
  29. package/esm/typings/src/formats/_common/FormatSubvalueDefinition.d.ts +1 -1
  30. package/esm/typings/src/formfactors/_common/AbstractFormfactorDefinition.d.ts +29 -0
  31. package/esm/typings/src/formfactors/_common/FormfactorDefinition.d.ts +5 -0
  32. package/esm/typings/src/formfactors/_common/string_formfactor_name.d.ts +5 -0
  33. package/esm/typings/src/formfactors/chat/ChatFormfactorDefinition.d.ts +10 -0
  34. package/esm/typings/src/formfactors/generic/GenericFormfactorDefinition.d.ts +10 -0
  35. package/esm/typings/src/formfactors/index.d.ts +14 -0
  36. package/esm/typings/src/pipeline/pipeline-interface/PipelineInterface.d.ts +22 -0
  37. package/esm/typings/src/pipeline/pipeline-interface/getPipelineInterface.d.ts +11 -0
  38. package/esm/typings/src/pipeline/pipeline-interface/isPipelineImplementingInterface.d.ts +25 -0
  39. package/esm/typings/src/pipeline/pipeline-interface/isPipelineInterfacesEqual.d.ts +11 -0
  40. package/esm/typings/src/storage/blackhole/BlackholeStorage.d.ts +33 -0
  41. package/esm/typings/src/storage/memory/MemoryStorage.d.ts +1 -1
  42. package/esm/typings/src/storage/{memory/utils → utils}/PrefixStorage.d.ts +1 -1
  43. package/esm/typings/src/types/PipelineJson/PipelineJson.d.ts +11 -4
  44. package/esm/typings/src/types/PipelineJson/PreparationJson.d.ts +1 -1
  45. package/esm/typings/src/types/Prompt.d.ts +1 -1
  46. package/esm/typings/src/types/typeAliases.d.ts +2 -2
  47. package/esm/typings/src/utils/expectation-counters/config.d.ts +12 -0
  48. package/esm/typings/src/utils/expectation-counters/countLines.d.ts +2 -0
  49. package/esm/typings/src/utils/expectation-counters/countPages.d.ts +2 -0
  50. package/package.json +1 -1
  51. package/umd/index.umd.js +54 -32
  52. package/umd/index.umd.js.map +1 -1
  53. /package/esm/typings/src/storage/{memory → local-storage}/utils/makePromptbookStorageFromWebStorage.d.ts +0 -0
package/README.md CHANGED
@@ -18,7 +18,7 @@ Build responsible, controlled and transparent applications on top of LLM models!
18
18
 
19
19
  ## ✨ New Features
20
20
 
21
- - 💙 Working on [the **Book** language v1](https://github.com/webgptorg/book)
21
+ - 💙 Working [the **Book** language v1.0.0](https://github.com/webgptorg/book)
22
22
  - 📚 Support of `.docx`, `.doc` and `.pdf` documents
23
23
  - ✨ **Support of [OpenAI o1 model](https://openai.com/o1/)**
24
24
 
@@ -148,7 +148,7 @@ Following is the documentation and blueprint of the Book language.
148
148
 
149
149
  File is designed to be easy to read and write. It is strict subset of markdown. It is designed to be understandable by both humans and machines and without specific knowledge of the language.
150
150
 
151
- It has file with `.ptbk.md` or `.book` extension with `UTF-8` non BOM encoding.
151
+ It has file with `.book.md` or `.book` extension with `UTF-8` non BOM encoding.
152
152
 
153
153
  As it is source code, it can leverage all the features of version control systems like git and does not suffer from the problems of binary formats, proprietary formats, or no-code solutions.
154
154
 
@@ -241,11 +241,6 @@ Or you can install them separately:
241
241
 
242
242
  ## 📚 Dictionary
243
243
 
244
-
245
-
246
-
247
-
248
-
249
244
  ### 📚 Dictionary
250
245
 
251
246
  The following glossary is used to clarify certain concepts:
@@ -261,8 +256,6 @@ The following glossary is used to clarify certain concepts:
261
256
  - **Retrieval-augmented generation** is a machine learning paradigm where a model generates text by retrieving relevant information from a large database of text. This approach combines the benefits of generative models and retrieval models.
262
257
  - **Longtail** refers to non-common or rare events, items, or entities that are not well-represented in the training data of machine learning models. Longtail items are often challenging for models to predict accurately.
263
258
 
264
-
265
-
266
259
  _Note: Thos section is not complete dictionary, more list of general AI / LLM terms that has connection with Promptbook_
267
260
 
268
261
  #### Promptbook core
@@ -323,8 +316,6 @@ _Note: Thos section is not complete dictionary, more list of general AI / LLM te
323
316
  - [👮 Agent adversary expectations](https://github.com/webgptorg/promptbook/discussions/39)
324
317
  - [view more](https://github.com/webgptorg/promptbook/discussions/categories/concepts)
325
318
 
326
-
327
-
328
319
  ### Terms specific to Promptbook TypeScript implementation
329
320
 
330
321
  - Anonymous mode
package/esm/index.es.js CHANGED
@@ -20,7 +20,7 @@ var BOOK_LANGUAGE_VERSION = '1.0.0';
20
20
  *
21
21
  * @see https://github.com/webgptorg/promptbook
22
22
  */
23
- var PROMPTBOOK_ENGINE_VERSION = '0.74.0-7';
23
+ var PROMPTBOOK_ENGINE_VERSION = '0.74.0-13';
24
24
  /**
25
25
  * TODO: string_promptbook_version should be constrained to the all versions of Promptbook engine
26
26
  */
@@ -355,7 +355,7 @@ function extractJsonBlock(markdown) {
355
355
  * TODO: [🏢] Make this logic part of `JsonFormatDefinition` or `isValidJsonString`
356
356
  */
357
357
 
358
- 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"}];
358
+ var PipelineCollection = [{title:"Prepare Knowledge from Markdown",pipelineUrl:"https://promptbook.studio/promptbook/prepare-knowledge-from-markdown.book.md",formfactorName:"GENERIC",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",formfactorName:"GENERIC",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",formfactorName:"GENERIC",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",formfactorName:"GENERIC",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"}];
359
359
 
360
360
  /**
361
361
  * Prettify the html code
@@ -394,13 +394,13 @@ function prettifyMarkdown(content) {
394
394
  /**
395
395
  * Converts promptbook in JSON format to string format
396
396
  *
397
- * @param pipelineJson Promptbook in JSON format (.ptbk.json)
398
- * @returns Promptbook in string format (.ptbk.md)
397
+ * @param pipelineJson Promptbook in JSON format (.book.json)
398
+ * @returns Promptbook in string format (.book.md)
399
399
  * @public exported from `@promptbook/core`
400
400
  */
401
401
  function pipelineJsonToString(pipelineJson) {
402
402
  var e_1, _a, e_2, _b, e_3, _c, e_4, _d, e_5, _e, e_6, _f;
403
- var title = pipelineJson.title, pipelineUrl = pipelineJson.pipelineUrl, promptbookVersion = pipelineJson.promptbookVersion, description = pipelineJson.description, parameters = pipelineJson.parameters, templates = pipelineJson.templates;
403
+ var title = pipelineJson.title, pipelineUrl = pipelineJson.pipelineUrl, bookVersion = pipelineJson.bookVersion, description = pipelineJson.description, parameters = pipelineJson.parameters, templates = pipelineJson.templates;
404
404
  var pipelineString = "# ".concat(title);
405
405
  if (description) {
406
406
  pipelineString += '\n\n';
@@ -410,8 +410,10 @@ function pipelineJsonToString(pipelineJson) {
410
410
  if (pipelineUrl) {
411
411
  commands.push("PIPELINE URL ".concat(pipelineUrl));
412
412
  }
413
- commands.push("PROMPTBOOK VERSION ".concat(promptbookVersion));
414
- // TODO: [main] !!! This increase size of the bundle and is probbably not necessary
413
+ if (bookVersion !== "undefined") {
414
+ commands.push("BOOK VERSION ".concat(bookVersion));
415
+ }
416
+ // TODO: [main] !!!!! This increases size of the bundle and is probbably not necessary
415
417
  pipelineString = prettifyMarkdown(pipelineString);
416
418
  try {
417
419
  for (var _g = __values(parameters.filter(function (_a) {
@@ -591,7 +593,7 @@ function templateParameterJsonToString(templateParameterJson) {
591
593
  * TODO: [🧠] Is there a way to auto-detect missing features in pipelineJsonToString
592
594
  * TODO: [🏛] Maybe make some markdown builder
593
595
  * TODO: [🏛] Escape all
594
- * TODO: [🧠] Should be in generated .ptbk.md file GENERATOR_WARNING
596
+ * TODO: [🧠] Should be in generated .book.md file GENERATOR_WARNING
595
597
  */
596
598
 
597
599
  /**
@@ -813,6 +815,13 @@ function $asDeeplyFrozenSerializableJson(name, objectValue) {
813
815
  * @private within the repository
814
816
  */
815
817
  var GENERATOR_WARNING = "\u26A0\uFE0F WARNING: This code has been generated so that any manual changes will be overwritten";
818
+ // <- TODO: [🐊] Pick the best claim
819
+ /**
820
+ * When the title is not provided, the default title is used
821
+ *
822
+ * @public exported from `@promptbook/core`
823
+ */
824
+ var DEFAULT_TITLE = "Untitled";
816
825
  // <- TODO: [🧠] Better system for generator warnings - not always "code" and "by `@promptbook/cli`"
817
826
  /**
818
827
  * The maximum number of iterations for a loops
@@ -1058,7 +1067,7 @@ function isValidPipelineUrl(url) {
1058
1067
  if (!url.startsWith('https://')) {
1059
1068
  return false;
1060
1069
  }
1061
- if (!(url.endsWith('.book.md') || url.endsWith('.book') || url.endsWith('.ptbk.md') || url.endsWith('.ptbk'))) {
1070
+ if (!(url.endsWith('.book.md') || url.endsWith('.book') || url.endsWith('.book.md') || url.endsWith('.ptbk'))) {
1062
1071
  return false;
1063
1072
  }
1064
1073
  if (url.includes('#')) {
@@ -1127,9 +1136,9 @@ function validatePipelineCore(pipeline) {
1127
1136
  // <- Note: [🚲]
1128
1137
  throw new PipelineLogicError(spaceTrim$1(function (block) { return "\n Invalid promptbook URL \"".concat(pipeline.pipelineUrl, "\"\n\n ").concat(block(pipelineIdentification), "\n "); }));
1129
1138
  }
1130
- if (pipeline.promptbookVersion !== undefined && !isValidPromptbookVersion(pipeline.promptbookVersion)) {
1139
+ if (pipeline.bookVersion !== undefined && !isValidPromptbookVersion(pipeline.bookVersion)) {
1131
1140
  // <- Note: [🚲]
1132
- throw new PipelineLogicError(spaceTrim$1(function (block) { return "\n Invalid Promptbook Version \"".concat(pipeline.promptbookVersion, "\"\n\n ").concat(block(pipelineIdentification), "\n "); }));
1141
+ throw new PipelineLogicError(spaceTrim$1(function (block) { return "\n Invalid Promptbook Version \"".concat(pipeline.bookVersion, "\"\n\n ").concat(block(pipelineIdentification), "\n "); }));
1133
1142
  }
1134
1143
  // TODO: [🧠] Maybe do here some propper JSON-schema / ZOD checking
1135
1144
  if (!Array.isArray(pipeline.parameters)) {
@@ -2778,7 +2787,7 @@ function preparePersona(personaDescription, tools, options) {
2778
2787
  collection = createCollectionFromJson.apply(void 0, __spreadArray([], __read(PipelineCollection), false));
2779
2788
  _b = createPipelineExecutor;
2780
2789
  _c = {};
2781
- return [4 /*yield*/, collection.getPipelineByUrl('https://promptbook.studio/promptbook/prepare-persona.ptbk.md')];
2790
+ return [4 /*yield*/, collection.getPipelineByUrl('https://promptbook.studio/promptbook/prepare-persona.book.md')];
2782
2791
  case 1:
2783
2792
  preparePersonaExecutor = _b.apply(void 0, [(_c.pipeline = _d.sent(),
2784
2793
  _c.tools = tools,
@@ -3450,13 +3459,14 @@ TODO: [🧊] This is how it can look in future
3450
3459
  */
3451
3460
  function clonePipeline(pipeline) {
3452
3461
  // Note: Not using spread operator (...) because @@@
3453
- 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;
3462
+ var pipelineUrl = pipeline.pipelineUrl, sourceFile = pipeline.sourceFile, title = pipeline.title, bookVersion = pipeline.bookVersion, description = pipeline.description, formfactorName = pipeline.formfactorName, parameters = pipeline.parameters, templates = pipeline.templates, knowledgeSources = pipeline.knowledgeSources, knowledgePieces = pipeline.knowledgePieces, personas = pipeline.personas, preparations = pipeline.preparations;
3454
3463
  return {
3455
3464
  pipelineUrl: pipelineUrl,
3456
3465
  sourceFile: sourceFile,
3457
3466
  title: title,
3458
- promptbookVersion: promptbookVersion,
3467
+ bookVersion: bookVersion,
3459
3468
  description: description,
3469
+ formfactorName: formfactorName,
3460
3470
  parameters: parameters,
3461
3471
  templates: templates,
3462
3472
  knowledgeSources: knowledgeSources,
@@ -4263,30 +4273,42 @@ function countCharacters(text) {
4263
4273
  return text.length;
4264
4274
  }
4265
4275
 
4276
+ /**
4277
+ * Number of characters per standard line with 11pt Arial font size.
4278
+ *
4279
+ * @public exported from `@promptbook/utils`
4280
+ */
4281
+ var CHARACTERS_PER_STANDARD_LINE = 63;
4282
+ /**
4283
+ * Number of lines per standard A4 page with 11pt Arial font size and standard margins and spacing.
4284
+ *
4285
+ * @public exported from `@promptbook/utils`
4286
+ */
4287
+ var LINES_PER_STANDARD_PAGE = 44;
4288
+
4266
4289
  /**
4267
4290
  * Counts number of lines in the text
4268
4291
  *
4292
+ * Note: This does not check only for the presence of newlines, but also for the length of the standard line.
4293
+ *
4269
4294
  * @public exported from `@promptbook/utils`
4270
4295
  */
4271
4296
  function countLines(text) {
4272
- if (text === '') {
4273
- return 0;
4274
- }
4275
- return text.split('\n').length;
4297
+ text = text.replace('\r\n', '\n');
4298
+ text = text.replace('\r', '\n');
4299
+ var lines = text.split('\n');
4300
+ return lines.reduce(function (count, line) { return count + Math.ceil(line.length / CHARACTERS_PER_STANDARD_LINE); }, 0);
4276
4301
  }
4277
4302
 
4278
4303
  /**
4279
4304
  * Counts number of pages in the text
4280
4305
  *
4306
+ * 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.
4307
+ *
4281
4308
  * @public exported from `@promptbook/utils`
4282
4309
  */
4283
4310
  function countPages(text) {
4284
- if (text === '') {
4285
- return 0;
4286
- }
4287
- var pagesByLinesCount = Math.ceil(countLines(text) / 44);
4288
- var pagesByCharactersCount = Math.ceil(countCharacters(text) / 2772);
4289
- return Math.max(pagesByLinesCount, pagesByCharactersCount);
4311
+ return Math.ceil(countLines(text) / LINES_PER_STANDARD_PAGE);
4290
4312
  }
4291
4313
 
4292
4314
  /**
@@ -4566,7 +4588,7 @@ function executeAttempts(options) {
4566
4588
  promptTitle: template.title,
4567
4589
  promptMessage: replaceParameters(template.description || '', parameters),
4568
4590
  defaultValue: replaceParameters(preparedContent, parameters),
4569
- // TODO: [🧠] !! Figure out how to define placeholder in .ptbk.md file
4591
+ // TODO: [🧠] !! Figure out how to define placeholder in .book.md file
4570
4592
  placeholder: undefined,
4571
4593
  priority: priority,
4572
4594
  }))];
@@ -5132,7 +5154,7 @@ function executePipeline(options) {
5132
5154
  pipelineUrl: preparedPipeline.pipelineUrl,
5133
5155
  title: preparedPipeline.title,
5134
5156
  promptbookUsedVersion: PROMPTBOOK_ENGINE_VERSION,
5135
- promptbookRequestedVersion: preparedPipeline.promptbookVersion,
5157
+ promptbookRequestedVersion: preparedPipeline.bookVersion,
5136
5158
  description: preparedPipeline.description,
5137
5159
  promptExecutions: [],
5138
5160
  };
@@ -5528,7 +5550,7 @@ var MarkdownScraper = /** @class */ (function () {
5528
5550
  collection = createCollectionFromJson.apply(void 0, __spreadArray([], __read(PipelineCollection), false));
5529
5551
  _d = createPipelineExecutor;
5530
5552
  _g = {};
5531
- return [4 /*yield*/, collection.getPipelineByUrl('https://promptbook.studio/promptbook/prepare-knowledge-from-markdown.ptbk.md')];
5553
+ return [4 /*yield*/, collection.getPipelineByUrl('https://promptbook.studio/promptbook/prepare-knowledge-from-markdown.book.md')];
5532
5554
  case 1:
5533
5555
  prepareKnowledgeFromMarkdownExecutor = _d.apply(void 0, [(_g.pipeline = _k.sent(),
5534
5556
  _g.tools = {
@@ -5537,7 +5559,7 @@ var MarkdownScraper = /** @class */ (function () {
5537
5559
  _g)]);
5538
5560
  _e = createPipelineExecutor;
5539
5561
  _h = {};
5540
- return [4 /*yield*/, collection.getPipelineByUrl('https://promptbook.studio/promptbook/prepare-knowledge-title.ptbk.md')];
5562
+ return [4 /*yield*/, collection.getPipelineByUrl('https://promptbook.studio/promptbook/prepare-knowledge-title.book.md')];
5541
5563
  case 2:
5542
5564
  prepareTitleExecutor = _e.apply(void 0, [(_h.pipeline = _k.sent(),
5543
5565
  _h.tools = {
@@ -5546,7 +5568,7 @@ var MarkdownScraper = /** @class */ (function () {
5546
5568
  _h)]);
5547
5569
  _f = createPipelineExecutor;
5548
5570
  _j = {};
5549
- return [4 /*yield*/, collection.getPipelineByUrl('https://promptbook.studio/promptbook/prepare-knowledge-keywords.ptbk.md')];
5571
+ return [4 /*yield*/, collection.getPipelineByUrl('https://promptbook.studio/promptbook/prepare-knowledge-keywords.book.md')];
5550
5572
  case 3:
5551
5573
  prepareKeywordsExecutor = _f.apply(void 0, [(_j.pipeline = _k.sent(),
5552
5574
  _j.tools = {
@@ -5904,7 +5926,7 @@ function splitMarkdownIntoSections(markdown) {
5904
5926
  return;
5905
5927
  }
5906
5928
  if (!section.startsWith('#')) {
5907
- section = "# Untitled\n\n".concat(section);
5929
+ section = "# ".concat(DEFAULT_TITLE, "\n\n").concat(section);
5908
5930
  }
5909
5931
  sections.push(section);
5910
5932
  buffer = [];
@@ -5968,7 +5990,7 @@ function flattenMarkdown(markdown) {
5968
5990
  var e_1, _a;
5969
5991
  var sections = splitMarkdownIntoSections(markdown);
5970
5992
  if (sections.length === 0) {
5971
- return '# Untitled';
5993
+ return "# ".concat(DEFAULT_TITLE);
5972
5994
  }
5973
5995
  var flattenedMarkdown = '';
5974
5996
  var parsedSections = sections.map(parseMarkdownSection);
@@ -5979,7 +6001,7 @@ function flattenMarkdown(markdown) {
5979
6001
  }
5980
6002
  else {
5981
6003
  parsedSections.unshift(firstSection);
5982
- flattenedMarkdown += "# Untitled" + "\n\n"; // <- [🧠] Maybe 3 new lines?
6004
+ flattenedMarkdown += "# ".concat(DEFAULT_TITLE) + "\n\n"; // <- [🧠] Maybe 3 new lines?
5983
6005
  }
5984
6006
  try {
5985
6007
  for (var parsedSections_1 = __values(parsedSections), parsedSections_1_1 = parsedSections_1.next(); !parsedSections_1_1.done; parsedSections_1_1 = parsedSections_1.next()) {