@promptbook/legacy-documents 0.74.0-7 → 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 +44 -27
  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 +2 -2
  51. package/umd/index.umd.js +44 -27
  52. package/umd/index.umd.js.map +1 -1
  53. /package/esm/typings/src/storage/{memory → local-storage}/utils/makePromptbookStorageFromWebStorage.d.ts +0 -0
@@ -1,6 +1,6 @@
1
1
  import type { PromptbookStorage } from '../_common/PromptbookStorage';
2
2
  /**
3
- * Stores
3
+ * Stores data in memory (HEAP)
4
4
  *
5
5
  * @public exported from `@promptbook/core`
6
6
  */
@@ -1,5 +1,5 @@
1
1
  import type { Promisable } from 'type-fest';
2
- import type { PromptbookStorage } from '../../_common/PromptbookStorage';
2
+ import type { PromptbookStorage } from '../_common/PromptbookStorage';
3
3
  /**
4
4
  * This class behaves like LocalStorage but separates keys by prefix
5
5
  *
@@ -1,3 +1,4 @@
1
+ import type { string_formfactor_name } from '../../formfactors/_common/string_formfactor_name';
1
2
  import type { ModelRequirements } from '../ModelRequirements';
2
3
  import type { string_filename } from '../typeAliases';
3
4
  import type { string_markdown_text } from '../typeAliases';
@@ -26,12 +27,12 @@ export type PipelineJson = {
26
27
  * Note: It must be unique across all pipeline collections
27
28
  * Note: It must use HTTPs URL
28
29
  * Tip: You can do versioning in the URL
29
- * For example: https://promptbook.studio/webgpt/write-website-content-cs.ptbk.md@1.0.0
30
+ * For example: https://promptbook.studio/webgpt/write-website-content-cs.book.md@1.0.0
30
31
  * Warning: Do not hash part of the URL, hash part is used for identification of the template in the pipeline
31
32
  */
32
33
  readonly pipelineUrl?: string_pipeline_url;
33
34
  /**
34
- * Internal helper for tracking the source `.ptbk.md` file of the pipeline
35
+ * Internal helper for tracking the source `.book.md` file of the pipeline
35
36
  */
36
37
  readonly sourceFile?: string_filename;
37
38
  /**
@@ -40,14 +41,20 @@ export type PipelineJson = {
40
41
  */
41
42
  readonly title: string_markdown_text;
42
43
  /**
43
- * Version of the .ptbk.json file
44
+ * Version of the Book language
45
+ *
46
+ * @see https://github.com/webgptorg/book
44
47
  */
45
- readonly promptbookVersion?: string_semantic_version;
48
+ readonly bookVersion?: string_semantic_version;
46
49
  /**
47
50
  * Description of the promptbook
48
51
  * It can use multiple paragraphs of simple markdown formatting like **bold**, *italic*, [link](https://example.com), ... BUT not code blocks and structure
49
52
  */
50
53
  readonly description?: string_markdown_text;
54
+ /**
55
+ * Name of the formfactor that the pipeline is shaped for
56
+ */
57
+ readonly formfactorName: string_formfactor_name;
51
58
  /**
52
59
  * Set of variables that are used across the pipeline
53
60
  */
@@ -18,5 +18,5 @@ export type PreparationJson = {
18
18
  /**
19
19
  * TODO: [🍙] Make some standard order of json properties
20
20
  * TODO: Maybe put here used `modelName`
21
- * TODO: [🍥] When using `date` it changes all examples .ptbk.json files each time so until some more elegant solution omit the time from prepared pipeline
21
+ * TODO: [🍥] When using `date` it changes all examples .book.json files each time so until some more elegant solution omit the time from prepared pipeline
22
22
  */
@@ -95,7 +95,7 @@ export type CommonPrompt = {
95
95
  /**
96
96
  * Unique identifier of the pipeline with specific template name as hash
97
97
  *
98
- * @example https://promptbook.studio/webgpt/write-website-content-cs.ptbk.md#keywords
98
+ * @example https://promptbook.studio/webgpt/write-website-content-cs.book.md#keywords
99
99
  */
100
100
  readonly pipelineUrl?: string_pipeline_url_with_hashtemplate;
101
101
  /**
@@ -298,13 +298,13 @@ export type string_base_url = string;
298
298
  /**
299
299
  * Semantic helper
300
300
  *
301
- * For example `"https://promptbook.studio/webgpt/write-website-content-cs.ptbk.md"`
301
+ * For example `"https://promptbook.studio/webgpt/write-website-content-cs.book.md"`
302
302
  */
303
303
  export type string_pipeline_url = string;
304
304
  /**
305
305
  * Semantic helper
306
306
  *
307
- * For example `"https://promptbook.studio/webgpt/write-website-content-cs.ptbk.md#keywords"`
307
+ * For example `"https://promptbook.studio/webgpt/write-website-content-cs.book.md#keywords"`
308
308
  */
309
309
  export type string_pipeline_url_with_hashtemplate = string;
310
310
  /**
@@ -0,0 +1,12 @@
1
+ /**
2
+ * Number of characters per standard line with 11pt Arial font size.
3
+ *
4
+ * @public exported from `@promptbook/utils`
5
+ */
6
+ export declare const CHARACTERS_PER_STANDARD_LINE = 63;
7
+ /**
8
+ * Number of lines per standard A4 page with 11pt Arial font size and standard margins and spacing.
9
+ *
10
+ * @public exported from `@promptbook/utils`
11
+ */
12
+ export declare const LINES_PER_STANDARD_PAGE = 44;
@@ -2,6 +2,8 @@ import type { ExpectationAmount } from '../../types/PipelineJson/Expectations';
2
2
  /**
3
3
  * Counts number of lines in the text
4
4
  *
5
+ * Note: This does not check only for the presence of newlines, but also for the length of the standard line.
6
+ *
5
7
  * @public exported from `@promptbook/utils`
6
8
  */
7
9
  export declare function countLines(text: string): ExpectationAmount;
@@ -2,6 +2,8 @@ import type { ExpectationAmount } from '../../types/PipelineJson/Expectations';
2
2
  /**
3
3
  * Counts number of pages in the text
4
4
  *
5
+ * 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.
6
+ *
5
7
  * @public exported from `@promptbook/utils`
6
8
  */
7
9
  export declare function countPages(text: string): ExpectationAmount;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@promptbook/legacy-documents",
3
- "version": "0.74.0-7",
3
+ "version": "0.75.0-0",
4
4
  "description": "Supercharge your use of large language models",
5
5
  "private": false,
6
6
  "sideEffects": false,
@@ -53,7 +53,7 @@
53
53
  "module": "./esm/index.es.js",
54
54
  "typings": "./esm/typings/src/_packages/legacy-documents.index.d.ts",
55
55
  "peerDependencies": {
56
- "@promptbook/core": "0.74.0-7"
56
+ "@promptbook/core": "0.75.0-0"
57
57
  },
58
58
  "dependencies": {
59
59
  "colors": "1.4.0",
package/umd/index.umd.js CHANGED
@@ -23,7 +23,7 @@
23
23
  *
24
24
  * @see https://github.com/webgptorg/promptbook
25
25
  */
26
- var PROMPTBOOK_ENGINE_VERSION = '0.74.0-6';
26
+ var PROMPTBOOK_ENGINE_VERSION = '0.74.0-13';
27
27
  /**
28
28
  * TODO: string_promptbook_version should be constrained to the all versions of Promptbook engine
29
29
  */
@@ -1225,7 +1225,7 @@
1225
1225
  * Note: [🟢] Code in this file should never be never released in packages that could be imported into browser environment
1226
1226
  */
1227
1227
 
1228
- 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"}];
1228
+ 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"}];
1229
1229
 
1230
1230
  /**
1231
1231
  * Prettify the html code
@@ -1273,13 +1273,13 @@
1273
1273
  /**
1274
1274
  * Converts promptbook in JSON format to string format
1275
1275
  *
1276
- * @param pipelineJson Promptbook in JSON format (.ptbk.json)
1277
- * @returns Promptbook in string format (.ptbk.md)
1276
+ * @param pipelineJson Promptbook in JSON format (.book.json)
1277
+ * @returns Promptbook in string format (.book.md)
1278
1278
  * @public exported from `@promptbook/core`
1279
1279
  */
1280
1280
  function pipelineJsonToString(pipelineJson) {
1281
1281
  var e_1, _a, e_2, _b, e_3, _c, e_4, _d, e_5, _e, e_6, _f;
1282
- var title = pipelineJson.title, pipelineUrl = pipelineJson.pipelineUrl, promptbookVersion = pipelineJson.promptbookVersion, description = pipelineJson.description, parameters = pipelineJson.parameters, templates = pipelineJson.templates;
1282
+ var title = pipelineJson.title, pipelineUrl = pipelineJson.pipelineUrl, bookVersion = pipelineJson.bookVersion, description = pipelineJson.description, parameters = pipelineJson.parameters, templates = pipelineJson.templates;
1283
1283
  var pipelineString = "# ".concat(title);
1284
1284
  if (description) {
1285
1285
  pipelineString += '\n\n';
@@ -1289,8 +1289,10 @@
1289
1289
  if (pipelineUrl) {
1290
1290
  commands.push("PIPELINE URL ".concat(pipelineUrl));
1291
1291
  }
1292
- commands.push("PROMPTBOOK VERSION ".concat(promptbookVersion));
1293
- // TODO: [main] !!! This increase size of the bundle and is probbably not necessary
1292
+ if (bookVersion !== "undefined") {
1293
+ commands.push("BOOK VERSION ".concat(bookVersion));
1294
+ }
1295
+ // TODO: [main] !!!!! This increases size of the bundle and is probbably not necessary
1294
1296
  pipelineString = prettifyMarkdown(pipelineString);
1295
1297
  try {
1296
1298
  for (var _g = __values(parameters.filter(function (_a) {
@@ -1470,7 +1472,7 @@
1470
1472
  * TODO: [🧠] Is there a way to auto-detect missing features in pipelineJsonToString
1471
1473
  * TODO: [🏛] Maybe make some markdown builder
1472
1474
  * TODO: [🏛] Escape all
1473
- * TODO: [🧠] Should be in generated .ptbk.md file GENERATOR_WARNING
1475
+ * TODO: [🧠] Should be in generated .book.md file GENERATOR_WARNING
1474
1476
  */
1475
1477
 
1476
1478
  /**
@@ -1617,7 +1619,7 @@
1617
1619
  if (!url.startsWith('https://')) {
1618
1620
  return false;
1619
1621
  }
1620
- if (!(url.endsWith('.book.md') || url.endsWith('.book') || url.endsWith('.ptbk.md') || url.endsWith('.ptbk'))) {
1622
+ if (!(url.endsWith('.book.md') || url.endsWith('.book') || url.endsWith('.book.md') || url.endsWith('.ptbk'))) {
1621
1623
  return false;
1622
1624
  }
1623
1625
  if (url.includes('#')) {
@@ -1686,9 +1688,9 @@
1686
1688
  // <- Note: [🚲]
1687
1689
  throw new PipelineLogicError(spaceTrim.spaceTrim(function (block) { return "\n Invalid promptbook URL \"".concat(pipeline.pipelineUrl, "\"\n\n ").concat(block(pipelineIdentification), "\n "); }));
1688
1690
  }
1689
- if (pipeline.promptbookVersion !== undefined && !isValidPromptbookVersion(pipeline.promptbookVersion)) {
1691
+ if (pipeline.bookVersion !== undefined && !isValidPromptbookVersion(pipeline.bookVersion)) {
1690
1692
  // <- Note: [🚲]
1691
- throw new PipelineLogicError(spaceTrim.spaceTrim(function (block) { return "\n Invalid Promptbook Version \"".concat(pipeline.promptbookVersion, "\"\n\n ").concat(block(pipelineIdentification), "\n "); }));
1693
+ throw new PipelineLogicError(spaceTrim.spaceTrim(function (block) { return "\n Invalid Promptbook Version \"".concat(pipeline.bookVersion, "\"\n\n ").concat(block(pipelineIdentification), "\n "); }));
1692
1694
  }
1693
1695
  // TODO: [🧠] Maybe do here some propper JSON-schema / ZOD checking
1694
1696
  if (!Array.isArray(pipeline.parameters)) {
@@ -2919,7 +2921,7 @@
2919
2921
  collection = createCollectionFromJson.apply(void 0, __spreadArray([], __read(PipelineCollection), false));
2920
2922
  _b = createPipelineExecutor;
2921
2923
  _c = {};
2922
- return [4 /*yield*/, collection.getPipelineByUrl('https://promptbook.studio/promptbook/prepare-persona.ptbk.md')];
2924
+ return [4 /*yield*/, collection.getPipelineByUrl('https://promptbook.studio/promptbook/prepare-persona.book.md')];
2923
2925
  case 1:
2924
2926
  preparePersonaExecutor = _b.apply(void 0, [(_c.pipeline = _d.sent(),
2925
2927
  _c.tools = tools,
@@ -3529,13 +3531,14 @@
3529
3531
  */
3530
3532
  function clonePipeline(pipeline) {
3531
3533
  // Note: Not using spread operator (...) because @@@
3532
- 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;
3534
+ 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;
3533
3535
  return {
3534
3536
  pipelineUrl: pipelineUrl,
3535
3537
  sourceFile: sourceFile,
3536
3538
  title: title,
3537
- promptbookVersion: promptbookVersion,
3539
+ bookVersion: bookVersion,
3538
3540
  description: description,
3541
+ formfactorName: formfactorName,
3539
3542
  parameters: parameters,
3540
3543
  templates: templates,
3541
3544
  knowledgeSources: knowledgeSources,
@@ -4479,28 +4482,42 @@
4479
4482
  return text.length;
4480
4483
  }
4481
4484
 
4485
+ /**
4486
+ * Number of characters per standard line with 11pt Arial font size.
4487
+ *
4488
+ * @public exported from `@promptbook/utils`
4489
+ */
4490
+ var CHARACTERS_PER_STANDARD_LINE = 63;
4491
+ /**
4492
+ * Number of lines per standard A4 page with 11pt Arial font size and standard margins and spacing.
4493
+ *
4494
+ * @public exported from `@promptbook/utils`
4495
+ */
4496
+ var LINES_PER_STANDARD_PAGE = 44;
4497
+
4482
4498
  /**
4483
4499
  * Counts number of lines in the text
4484
4500
  *
4501
+ * Note: This does not check only for the presence of newlines, but also for the length of the standard line.
4502
+ *
4485
4503
  * @public exported from `@promptbook/utils`
4486
4504
  */
4487
4505
  function countLines(text) {
4488
- if (text === '') {
4489
- return 0;
4490
- }
4491
- return text.split('\n').length;
4506
+ text = text.replace('\r\n', '\n');
4507
+ text = text.replace('\r', '\n');
4508
+ var lines = text.split('\n');
4509
+ return lines.reduce(function (count, line) { return count + Math.ceil(line.length / CHARACTERS_PER_STANDARD_LINE); }, 0);
4492
4510
  }
4493
4511
 
4494
4512
  /**
4495
4513
  * Counts number of pages in the text
4496
4514
  *
4515
+ * 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.
4516
+ *
4497
4517
  * @public exported from `@promptbook/utils`
4498
4518
  */
4499
4519
  function countPages(text) {
4500
- var sentencesPerPage = 5; // Assuming each page has 5 sentences
4501
- var sentences = text.split(/[.!?]+/).filter(function (sentence) { return sentence.trim() !== ''; });
4502
- var pageCount = Math.ceil(sentences.length / sentencesPerPage);
4503
- return pageCount;
4520
+ return Math.ceil(countLines(text) / LINES_PER_STANDARD_PAGE);
4504
4521
  }
4505
4522
 
4506
4523
  /**
@@ -4780,7 +4797,7 @@
4780
4797
  promptTitle: template.title,
4781
4798
  promptMessage: replaceParameters(template.description || '', parameters),
4782
4799
  defaultValue: replaceParameters(preparedContent, parameters),
4783
- // TODO: [🧠] !! Figure out how to define placeholder in .ptbk.md file
4800
+ // TODO: [🧠] !! Figure out how to define placeholder in .book.md file
4784
4801
  placeholder: undefined,
4785
4802
  priority: priority,
4786
4803
  }))];
@@ -5346,7 +5363,7 @@
5346
5363
  pipelineUrl: preparedPipeline.pipelineUrl,
5347
5364
  title: preparedPipeline.title,
5348
5365
  promptbookUsedVersion: PROMPTBOOK_ENGINE_VERSION,
5349
- promptbookRequestedVersion: preparedPipeline.promptbookVersion,
5366
+ promptbookRequestedVersion: preparedPipeline.bookVersion,
5350
5367
  description: preparedPipeline.description,
5351
5368
  promptExecutions: [],
5352
5369
  };
@@ -5742,7 +5759,7 @@
5742
5759
  collection = createCollectionFromJson.apply(void 0, __spreadArray([], __read(PipelineCollection), false));
5743
5760
  _d = createPipelineExecutor;
5744
5761
  _g = {};
5745
- return [4 /*yield*/, collection.getPipelineByUrl('https://promptbook.studio/promptbook/prepare-knowledge-from-markdown.ptbk.md')];
5762
+ return [4 /*yield*/, collection.getPipelineByUrl('https://promptbook.studio/promptbook/prepare-knowledge-from-markdown.book.md')];
5746
5763
  case 1:
5747
5764
  prepareKnowledgeFromMarkdownExecutor = _d.apply(void 0, [(_g.pipeline = _k.sent(),
5748
5765
  _g.tools = {
@@ -5751,7 +5768,7 @@
5751
5768
  _g)]);
5752
5769
  _e = createPipelineExecutor;
5753
5770
  _h = {};
5754
- return [4 /*yield*/, collection.getPipelineByUrl('https://promptbook.studio/promptbook/prepare-knowledge-title.ptbk.md')];
5771
+ return [4 /*yield*/, collection.getPipelineByUrl('https://promptbook.studio/promptbook/prepare-knowledge-title.book.md')];
5755
5772
  case 2:
5756
5773
  prepareTitleExecutor = _e.apply(void 0, [(_h.pipeline = _k.sent(),
5757
5774
  _h.tools = {
@@ -5760,7 +5777,7 @@
5760
5777
  _h)]);
5761
5778
  _f = createPipelineExecutor;
5762
5779
  _j = {};
5763
- return [4 /*yield*/, collection.getPipelineByUrl('https://promptbook.studio/promptbook/prepare-knowledge-keywords.ptbk.md')];
5780
+ return [4 /*yield*/, collection.getPipelineByUrl('https://promptbook.studio/promptbook/prepare-knowledge-keywords.book.md')];
5764
5781
  case 3:
5765
5782
  prepareKeywordsExecutor = _f.apply(void 0, [(_j.pipeline = _k.sent(),
5766
5783
  _j.tools = {