@promptbook/node 0.63.0-4 → 0.63.0-6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1,4 +1,4 @@
1
- <!-- ⚠️ WARNING: This section has been generated so that any manual changes will be overwritten -->
1
+ <!-- ⚠️ WARNING: This code has been generated so that any manual changes will be overwritten -->
2
2
 
3
3
  # ![Promptbook logo - cube with letters P and B](./other/design/logo-h1.png) Promptbook
4
4
 
package/esm/index.es.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import colors from 'colors';
2
- import { readdir, access, constants, readFile, stat, writeFile, mkdir, unlink } from 'fs/promises';
2
+ import { stat, access, constants, readdir, readFile, writeFile, mkdir, unlink } from 'fs/promises';
3
3
  import { join as join$1, dirname } from 'path';
4
4
  import spaceTrim, { spaceTrim as spaceTrim$1 } from 'spacetrim';
5
5
  import { format } from 'prettier';
@@ -11,10 +11,11 @@ import OpenAI from 'openai';
11
11
  import hexEncoder from 'crypto-js/enc-hex';
12
12
  import sha256 from 'crypto-js/sha256';
13
13
 
14
+ // ⚠️ WARNING: This code has been generated so that any manual changes will be overwritten
14
15
  /**
15
16
  * The version of the Promptbook library
16
17
  */
17
- var PROMPTBOOK_VERSION = '0.63.0-3';
18
+ var PROMPTBOOK_VERSION = '0.63.0-5';
18
19
  // TODO: !!!! List here all the versions and annotate + put into script
19
20
 
20
21
  /*! *****************************************************************************
@@ -181,6 +182,7 @@ function deepFreezeWithSameType(objectValue) {
181
182
  * TODO: [🧠] Is there a way how to meaningfully test this utility
182
183
  */
183
184
 
185
+ // <- TODO: [🧠] Better system for generator warnings - not always "code" and "by `@promptbook/cli`"
184
186
  /**
185
187
  * The maximum number of iterations for a loops
186
188
  *
@@ -688,7 +690,7 @@ function forEachAsync(array, options, callbackfunction) {
688
690
  });
689
691
  }
690
692
 
691
- var PipelineCollection = [{title:"Prepare Knowledge from Markdown",pipelineUrl:"https://promptbook.studio/promptbook/prepare-knowledge-from-markdown.ptbk.md",promptbookVersion:"0.63.0-3",parameters:[{name:"knowledgeContent",description:"Markdown document content",isInput:true,isOutput:false},{name:"knowledgePieces",description:"The knowledge JSON object",isInput:false,isOutput:true}],promptTemplates:[{blockType:"PROMPT_TEMPLATE",name:"knowledge",title:"Knowledge",modelRequirements:{modelVariant:"CHAT",modelName:"claude-3-opus-20240229"},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}",dependentParameterNames:["knowledgeContent"],resultingParameterName:"knowledgePieces"}],knowledgeSources:[],knowledgePieces:[],personas:[],preparations:[{id:1,promptbookVersion:"0.63.0-3",usage:{price:{value:0},input:{tokensCount:{value:0},charactersCount:{value:0},wordsCount:{value:0},sentencesCount:{value:0},linesCount:{value:0},paragraphsCount:{value:0},pagesCount:{value:0}},output:{tokensCount:{value:0},charactersCount:{value:0},wordsCount:{value:0},sentencesCount:{value:0},linesCount:{value:0},paragraphsCount:{value:0},pagesCount:{value:0}}}}],sourceFile:"./promptbook-collection/prepare-knowledge-from-markdown.ptbk.md"},{title:"Prepare Keywords",pipelineUrl:"https://promptbook.studio/promptbook/prepare-knowledge-keywords.ptbk.md",promptbookVersion:"0.63.0-3",parameters:[{name:"knowledgePieceContent",description:"The content",isInput:true,isOutput:false},{name:"keywords",description:"Keywords separated by comma",isInput:false,isOutput:true}],promptTemplates:[{blockType:"PROMPT_TEMPLATE",name:"knowledge",title:"Knowledge",modelRequirements:{modelVariant:"CHAT",modelName:"claude-3-opus-20240229"},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}",dependentParameterNames:["knowledgePieceContent"],resultingParameterName:"keywords"}],knowledgeSources:[],knowledgePieces:[],personas:[],preparations:[{id:1,promptbookVersion:"0.63.0-3",usage:{price:{value:0},input:{tokensCount:{value:0},charactersCount:{value:0},wordsCount:{value:0},sentencesCount:{value:0},linesCount:{value:0},paragraphsCount:{value:0},pagesCount:{value:0}},output:{tokensCount:{value:0},charactersCount:{value:0},wordsCount:{value:0},sentencesCount:{value:0},linesCount:{value:0},paragraphsCount:{value:0},pagesCount:{value:0}}}}],sourceFile:"./promptbook-collection/prepare-knowledge-keywords.ptbk.md"},{title:"Prepare Title",pipelineUrl:"https://promptbook.studio/promptbook/prepare-knowledge-title.ptbk.md",promptbookVersion:"0.63.0-3",parameters:[{name:"knowledgePieceContent",description:"The content",isInput:true,isOutput:false},{name:"title",description:"The title of the document",isInput:false,isOutput:true}],promptTemplates:[{blockType:"PROMPT_TEMPLATE",name:"knowledge",title:"Knowledge",modelRequirements:{modelVariant:"CHAT",modelName:"claude-3-opus-20240229"},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}",expectations:{words:{min:1,max:8}},dependentParameterNames:["knowledgePieceContent"],resultingParameterName:"title"}],knowledgeSources:[],knowledgePieces:[],personas:[],preparations:[{id:1,promptbookVersion:"0.63.0-3",usage:{price:{value:0},input:{tokensCount:{value:0},charactersCount:{value:0},wordsCount:{value:0},sentencesCount:{value:0},linesCount:{value:0},paragraphsCount:{value:0},pagesCount:{value:0}},output:{tokensCount:{value:0},charactersCount:{value:0},wordsCount:{value:0},sentencesCount:{value:0},linesCount:{value:0},paragraphsCount:{value:0},pagesCount:{value:0}}}}],sourceFile:"./promptbook-collection/prepare-knowledge-title.ptbk.md"},{title:"Prepare Keywords",pipelineUrl:"https://promptbook.studio/promptbook/prepare-persona.ptbk.md",promptbookVersion:"0.63.0-3",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}],promptTemplates:[{blockType:"PROMPT_TEMPLATE",name:"make-model-requirements",title:"Make modelRequirements",modelRequirements:{modelVariant:"CHAT",modelName:"gpt-4-turbo"},content:"You are experienced AI engineer, you need to create virtual assistant.\nWrite\n\n## Sample\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### Option `modelName`\n\nPick from the following models:\n\n- {availableModelNames}\n\n### Option `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### Option `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}",expectFormat:"JSON",dependentParameterNames:["availableModelNames","personaDescription"],resultingParameterName:"modelRequirements"}],knowledgeSources:[],knowledgePieces:[],personas:[],preparations:[{id:1,promptbookVersion:"0.63.0-3",usage:{price:{value:0},input:{tokensCount:{value:0},charactersCount:{value:0},wordsCount:{value:0},sentencesCount:{value:0},linesCount:{value:0},paragraphsCount:{value:0},pagesCount:{value:0}},output:{tokensCount:{value:0},charactersCount:{value:0},wordsCount:{value:0},sentencesCount:{value:0},linesCount:{value:0},paragraphsCount:{value:0},pagesCount:{value:0}}}}],sourceFile:"./promptbook-collection/prepare-persona.ptbk.md"}];
693
+ var PipelineCollection = [{title:"Prepare Knowledge from Markdown",pipelineUrl:"https://promptbook.studio/promptbook/prepare-knowledge-from-markdown.ptbk.md",promptbookVersion:"0.63.0-5",parameters:[{name:"knowledgeContent",description:"Markdown document content",isInput:true,isOutput:false},{name:"knowledgePieces",description:"The knowledge JSON object",isInput:false,isOutput:true}],promptTemplates:[{blockType:"PROMPT_TEMPLATE",name:"knowledge",title:"Knowledge",modelRequirements:{modelVariant:"CHAT",modelName:"claude-3-opus-20240229"},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}",dependentParameterNames:["knowledgeContent"],resultingParameterName:"knowledgePieces"}],knowledgeSources:[],knowledgePieces:[],personas:[],preparations:[{id:1,promptbookVersion:"0.63.0-5",usage:{price:{value:0},input:{tokensCount:{value:0},charactersCount:{value:0},wordsCount:{value:0},sentencesCount:{value:0},linesCount:{value:0},paragraphsCount:{value:0},pagesCount:{value:0}},output:{tokensCount:{value:0},charactersCount:{value:0},wordsCount:{value:0},sentencesCount:{value:0},linesCount:{value:0},paragraphsCount:{value:0},pagesCount:{value:0}}}}],sourceFile:"./promptbook-collection/prepare-knowledge-from-markdown.ptbk.md"},{title:"Prepare Keywords",pipelineUrl:"https://promptbook.studio/promptbook/prepare-knowledge-keywords.ptbk.md",promptbookVersion:"0.63.0-5",parameters:[{name:"knowledgePieceContent",description:"The content",isInput:true,isOutput:false},{name:"keywords",description:"Keywords separated by comma",isInput:false,isOutput:true}],promptTemplates:[{blockType:"PROMPT_TEMPLATE",name:"knowledge",title:"Knowledge",modelRequirements:{modelVariant:"CHAT",modelName:"claude-3-opus-20240229"},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}",dependentParameterNames:["knowledgePieceContent"],resultingParameterName:"keywords"}],knowledgeSources:[],knowledgePieces:[],personas:[],preparations:[{id:1,promptbookVersion:"0.63.0-5",usage:{price:{value:0},input:{tokensCount:{value:0},charactersCount:{value:0},wordsCount:{value:0},sentencesCount:{value:0},linesCount:{value:0},paragraphsCount:{value:0},pagesCount:{value:0}},output:{tokensCount:{value:0},charactersCount:{value:0},wordsCount:{value:0},sentencesCount:{value:0},linesCount:{value:0},paragraphsCount:{value:0},pagesCount:{value:0}}}}],sourceFile:"./promptbook-collection/prepare-knowledge-keywords.ptbk.md"},{title:"Prepare Title",pipelineUrl:"https://promptbook.studio/promptbook/prepare-knowledge-title.ptbk.md",promptbookVersion:"0.63.0-5",parameters:[{name:"knowledgePieceContent",description:"The content",isInput:true,isOutput:false},{name:"title",description:"The title of the document",isInput:false,isOutput:true}],promptTemplates:[{blockType:"PROMPT_TEMPLATE",name:"knowledge",title:"Knowledge",modelRequirements:{modelVariant:"CHAT",modelName:"claude-3-opus-20240229"},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}",expectations:{words:{min:1,max:8}},dependentParameterNames:["knowledgePieceContent"],resultingParameterName:"title"}],knowledgeSources:[],knowledgePieces:[],personas:[],preparations:[{id:1,promptbookVersion:"0.63.0-5",usage:{price:{value:0},input:{tokensCount:{value:0},charactersCount:{value:0},wordsCount:{value:0},sentencesCount:{value:0},linesCount:{value:0},paragraphsCount:{value:0},pagesCount:{value:0}},output:{tokensCount:{value:0},charactersCount:{value:0},wordsCount:{value:0},sentencesCount:{value:0},linesCount:{value:0},paragraphsCount:{value:0},pagesCount:{value:0}}}}],sourceFile:"./promptbook-collection/prepare-knowledge-title.ptbk.md"},{title:"Prepare Keywords",pipelineUrl:"https://promptbook.studio/promptbook/prepare-persona.ptbk.md",promptbookVersion:"0.63.0-5",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}],promptTemplates:[{blockType:"PROMPT_TEMPLATE",name:"make-model-requirements",title:"Make modelRequirements",modelRequirements:{modelVariant:"CHAT",modelName:"gpt-4-turbo"},content:"You are experienced AI engineer, you need to create virtual assistant.\nWrite\n\n## Sample\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### Option `modelName`\n\nPick from the following models:\n\n- {availableModelNames}\n\n### Option `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### Option `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}",expectFormat:"JSON",dependentParameterNames:["availableModelNames","personaDescription"],resultingParameterName:"modelRequirements"}],knowledgeSources:[],knowledgePieces:[],personas:[],preparations:[{id:1,promptbookVersion:"0.63.0-5",usage:{price:{value:0},input:{tokensCount:{value:0},charactersCount:{value:0},wordsCount:{value:0},sentencesCount:{value:0},linesCount:{value:0},paragraphsCount:{value:0},pagesCount:{value:0}},output:{tokensCount:{value:0},charactersCount:{value:0},wordsCount:{value:0},sentencesCount:{value:0},linesCount:{value:0},paragraphsCount:{value:0},pagesCount:{value:0}}}}],sourceFile:"./promptbook-collection/prepare-persona.ptbk.md"}];
692
694
 
693
695
  /**
694
696
  * This error indicates that the promptbook in a markdown format cannot be parsed into a valid promptbook object
@@ -5788,6 +5790,75 @@ var CollectionError = /** @class */ (function (_super) {
5788
5790
  return CollectionError;
5789
5791
  }(Error));
5790
5792
 
5793
+ /**
5794
+ * Checks if the file exists
5795
+ *
5796
+ * @private within the repository
5797
+ */
5798
+ function isFileExisting(filePath) {
5799
+ return __awaiter(this, void 0, void 0, function () {
5800
+ var isReadAccessAllowed, isFile;
5801
+ return __generator(this, function (_a) {
5802
+ switch (_a.label) {
5803
+ case 0: return [4 /*yield*/, access(filePath, constants.R_OK)
5804
+ .then(function () { return true; })
5805
+ .catch(function () { return false; })];
5806
+ case 1:
5807
+ isReadAccessAllowed = _a.sent();
5808
+ if (!isReadAccessAllowed) {
5809
+ return [2 /*return*/, false];
5810
+ }
5811
+ return [4 /*yield*/, stat(filePath)
5812
+ .then(function (fileStat) { return fileStat.isFile(); })
5813
+ .catch(function () { return false; })];
5814
+ case 2:
5815
+ isFile = _a.sent();
5816
+ return [2 /*return*/, isFile];
5817
+ }
5818
+ });
5819
+ });
5820
+ }
5821
+ /**
5822
+ * Note: [🟢] This code should never be published outside of `@promptbook/node` and `@promptbook/cli` and `@promptbook/cli`
5823
+ * TODO: [🐠] This can be a validator - with variants that return true/false and variants that throw errors with meaningless messages
5824
+ * TODO: [🖇] What about symlinks?
5825
+ */
5826
+
5827
+ /**
5828
+ * Checks if the directory exists
5829
+ *
5830
+ * @private within the repository
5831
+ */
5832
+ function isDirectoryExisting(directoryPath) {
5833
+ return __awaiter(this, void 0, void 0, function () {
5834
+ var isReadAccessAllowed, isDirectory;
5835
+ return __generator(this, function (_a) {
5836
+ switch (_a.label) {
5837
+ case 0: return [4 /*yield*/, access(directoryPath, constants.R_OK)
5838
+ .then(function () { return true; })
5839
+ .catch(function () { return false; })];
5840
+ case 1:
5841
+ isReadAccessAllowed = _a.sent();
5842
+ if (!isReadAccessAllowed) {
5843
+ return [2 /*return*/, false];
5844
+ }
5845
+ return [4 /*yield*/, stat(directoryPath)
5846
+ .then(function (fileStat) { return fileStat.isDirectory(); })
5847
+ .catch(function () { return false; })];
5848
+ case 2:
5849
+ isDirectory = _a.sent();
5850
+ return [2 /*return*/, isDirectory];
5851
+ }
5852
+ });
5853
+ });
5854
+ }
5855
+ /**
5856
+ * Note: [🟢] This code should never be published outside of `@promptbook/node` and `@promptbook/cli` and `@promptbook/cli`
5857
+ * TODO: [🐠] This can be a validator - with variants that return true/false and variants that throw errors with meaningless messages
5858
+ * TODO: [🧠][📂] "directory" vs "folder"
5859
+ * TODO: [🖇] What about symlinks?
5860
+ */
5861
+
5791
5862
  /**
5792
5863
  * Reads all files in the directory
5793
5864
  *
@@ -5802,53 +5873,60 @@ function listAllFiles(path, isRecursive) {
5802
5873
  var e_1, _g;
5803
5874
  return __generator(this, function (_h) {
5804
5875
  switch (_h.label) {
5805
- case 0: return [4 /*yield*/, readdir(path, {
5806
- withFileTypes: true /* Note: This is not working: recursive: isRecursive */,
5807
- })];
5876
+ case 0: return [4 /*yield*/, isDirectoryExisting(path)];
5808
5877
  case 1:
5878
+ if (!(_h.sent())) {
5879
+ throw new Error("Directory \"".concat(path, "\" does not exist or is not readable"));
5880
+ // <- TODO: Use some custom error class
5881
+ }
5882
+ return [4 /*yield*/, readdir(path, {
5883
+ withFileTypes: true /* Note: This is not working: recursive: isRecursive */,
5884
+ })];
5885
+ case 2:
5809
5886
  dirents = _h.sent();
5810
5887
  fileNames = dirents.filter(function (dirent) { return dirent.isFile(); }).map(function (_a) {
5811
5888
  var name = _a.name;
5812
5889
  return join(path, name);
5813
5890
  });
5814
- if (!isRecursive) return [3 /*break*/, 9];
5815
- _h.label = 2;
5816
- case 2:
5817
- _h.trys.push([2, 7, 8, 9]);
5818
- _a = __values(dirents.filter(function (dirent) { return dirent.isDirectory(); })), _b = _a.next();
5891
+ if (!isRecursive) return [3 /*break*/, 10];
5819
5892
  _h.label = 3;
5820
5893
  case 3:
5821
- if (!!_b.done) return [3 /*break*/, 6];
5894
+ _h.trys.push([3, 8, 9, 10]);
5895
+ _a = __values(dirents.filter(function (dirent) { return dirent.isDirectory(); })), _b = _a.next();
5896
+ _h.label = 4;
5897
+ case 4:
5898
+ if (!!_b.done) return [3 /*break*/, 7];
5822
5899
  dirent = _b.value;
5823
5900
  subPath = join(path, dirent.name);
5824
5901
  _d = (_c = fileNames.push).apply;
5825
5902
  _e = [fileNames];
5826
5903
  _f = [[]];
5827
5904
  return [4 /*yield*/, listAllFiles(subPath, isRecursive)];
5828
- case 4:
5829
- _d.apply(_c, _e.concat([__spreadArray.apply(void 0, _f.concat([__read.apply(void 0, [(_h.sent())]), false]))]));
5830
- _h.label = 5;
5831
5905
  case 5:
5906
+ _d.apply(_c, _e.concat([__spreadArray.apply(void 0, _f.concat([__read.apply(void 0, [(_h.sent())]), false]))]));
5907
+ _h.label = 6;
5908
+ case 6:
5832
5909
  _b = _a.next();
5833
- return [3 /*break*/, 3];
5834
- case 6: return [3 /*break*/, 9];
5835
- case 7:
5910
+ return [3 /*break*/, 4];
5911
+ case 7: return [3 /*break*/, 10];
5912
+ case 8:
5836
5913
  e_1_1 = _h.sent();
5837
5914
  e_1 = { error: e_1_1 };
5838
- return [3 /*break*/, 9];
5839
- case 8:
5915
+ return [3 /*break*/, 10];
5916
+ case 9:
5840
5917
  try {
5841
5918
  if (_b && !_b.done && (_g = _a.return)) _g.call(_a);
5842
5919
  }
5843
5920
  finally { if (e_1) throw e_1.error; }
5844
5921
  return [7 /*endfinally*/];
5845
- case 9: return [2 /*return*/, fileNames];
5922
+ case 10: return [2 /*return*/, fileNames];
5846
5923
  }
5847
5924
  });
5848
5925
  });
5849
5926
  }
5850
5927
  /**
5851
5928
  * Note: [🟢] This code should never be published outside of `@promptbook/node` and `@promptbook/cli` and `@promptbook/cli`
5929
+ * TODO: [🖇] What about symlinks?
5852
5930
  */
5853
5931
 
5854
5932
  /**
@@ -5969,7 +6047,7 @@ function createCollectionFromPromise(promptbookSourcesPromiseOrFactory) {
5969
6047
  */
5970
6048
  function createCollectionFromDirectory(path, options) {
5971
6049
  return __awaiter(this, void 0, void 0, function () {
5972
- var makedLibraryFilePath, makedLibraryFileExists, _a, _b, isRecursive, _c, isVerbose, _d, isLazyLoaded, _e, isCrashedOnError, collection;
6050
+ var makedLibraryFilePath, _a, _b, isRecursive, _c, isVerbose, _d, isLazyLoaded, _e, isCrashedOnError, collection;
5973
6051
  var _this = this;
5974
6052
  return __generator(this, function (_f) {
5975
6053
  switch (_f.label) {
@@ -5978,12 +6056,9 @@ function createCollectionFromDirectory(path, options) {
5978
6056
  throw new Error('Function `createCollectionFromDirectory` can only be run in Node.js environment because it reads the file system.');
5979
6057
  }
5980
6058
  makedLibraryFilePath = join$1(path, "".concat(PIPELINE_COLLECTION_BASE_FILENAME, ".json"));
5981
- return [4 /*yield*/, access(makedLibraryFilePath, constants.R_OK)
5982
- .then(function () { return true; })
5983
- .catch(function () { return false; })];
6059
+ return [4 /*yield*/, isFileExisting(makedLibraryFilePath)];
5984
6060
  case 1:
5985
- makedLibraryFileExists = _f.sent();
5986
- if (!makedLibraryFileExists) {
6061
+ if (!(_f.sent())) {
5987
6062
  console.info(colors.yellow("Tip: Prebuild your pipeline collection (file with supposed prebuild ".concat(makedLibraryFilePath, " not found) with CLI util \"ptbk make\" to speed up the collection creation.")));
5988
6063
  }
5989
6064
  else {
@@ -6147,6 +6222,7 @@ function createCollectionFromDirectory(path, options) {
6147
6222
  }
6148
6223
  /**
6149
6224
  * Note: [🟢] This code should never be published outside of `@promptbook/node` and `@promptbook/cli` and `@promptbook/cli`
6225
+ * TODO: [🖇] What about symlinks? Maybe option isSymlinksFollowed
6150
6226
  */
6151
6227
 
6152
6228
  /**
@@ -7314,17 +7390,14 @@ var FilesStorage = /** @class */ (function () {
7314
7390
  */
7315
7391
  FilesStorage.prototype.getItem = function (key) {
7316
7392
  return __awaiter(this, void 0, void 0, function () {
7317
- var filename, isFileExisting, fileContent, value;
7393
+ var filename, fileContent, value;
7318
7394
  return __generator(this, function (_a) {
7319
7395
  switch (_a.label) {
7320
7396
  case 0:
7321
7397
  filename = this.getFilenameForKey(key);
7322
- return [4 /*yield*/, stat(filename)
7323
- .then(function (fileStat) { return fileStat.isFile(); })
7324
- .catch(function () { return false; })];
7398
+ return [4 /*yield*/, isFileExisting(filename)];
7325
7399
  case 1:
7326
- isFileExisting = _a.sent();
7327
- if (!isFileExisting) {
7400
+ if (!(_a.sent())) {
7328
7401
  return [2 /*return*/, null];
7329
7402
  }
7330
7403
  return [4 /*yield*/, readFile(filename, 'utf-8')];