@promptbook/node 0.63.0-5 → 0.63.0-7

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/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-4';
18
+ var PROMPTBOOK_VERSION = '0.63.0-6';
18
19
  // TODO: !!!! List here all the versions and annotate + put into script
19
20
 
20
21
  /*! *****************************************************************************
@@ -689,7 +690,7 @@ function forEachAsync(array, options, callbackfunction) {
689
690
  });
690
691
  }
691
692
 
692
- var PipelineCollection = [{title:"Prepare Knowledge from Markdown",pipelineUrl:"https://promptbook.studio/promptbook/prepare-knowledge-from-markdown.ptbk.md",promptbookVersion:"0.63.0-4",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-4",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-4",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-4",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-4",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-4",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-4",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-4",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-6",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-6",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-6",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-6",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-6",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-6",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-6",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-6",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
694
 
694
695
  /**
695
696
  * This error indicates that the promptbook in a markdown format cannot be parsed into a valid promptbook object
@@ -5789,6 +5790,75 @@ var CollectionError = /** @class */ (function (_super) {
5789
5790
  return CollectionError;
5790
5791
  }(Error));
5791
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
+
5792
5862
  /**
5793
5863
  * Reads all files in the directory
5794
5864
  *
@@ -5803,53 +5873,60 @@ function listAllFiles(path, isRecursive) {
5803
5873
  var e_1, _g;
5804
5874
  return __generator(this, function (_h) {
5805
5875
  switch (_h.label) {
5806
- case 0: return [4 /*yield*/, readdir(path, {
5807
- withFileTypes: true /* Note: This is not working: recursive: isRecursive */,
5808
- })];
5876
+ case 0: return [4 /*yield*/, isDirectoryExisting(path)];
5809
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:
5810
5886
  dirents = _h.sent();
5811
5887
  fileNames = dirents.filter(function (dirent) { return dirent.isFile(); }).map(function (_a) {
5812
5888
  var name = _a.name;
5813
5889
  return join(path, name);
5814
5890
  });
5815
- if (!isRecursive) return [3 /*break*/, 9];
5816
- _h.label = 2;
5817
- case 2:
5818
- _h.trys.push([2, 7, 8, 9]);
5819
- _a = __values(dirents.filter(function (dirent) { return dirent.isDirectory(); })), _b = _a.next();
5891
+ if (!isRecursive) return [3 /*break*/, 10];
5820
5892
  _h.label = 3;
5821
5893
  case 3:
5822
- 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];
5823
5899
  dirent = _b.value;
5824
5900
  subPath = join(path, dirent.name);
5825
5901
  _d = (_c = fileNames.push).apply;
5826
5902
  _e = [fileNames];
5827
5903
  _f = [[]];
5828
5904
  return [4 /*yield*/, listAllFiles(subPath, isRecursive)];
5829
- case 4:
5830
- _d.apply(_c, _e.concat([__spreadArray.apply(void 0, _f.concat([__read.apply(void 0, [(_h.sent())]), false]))]));
5831
- _h.label = 5;
5832
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:
5833
5909
  _b = _a.next();
5834
- return [3 /*break*/, 3];
5835
- case 6: return [3 /*break*/, 9];
5836
- case 7:
5910
+ return [3 /*break*/, 4];
5911
+ case 7: return [3 /*break*/, 10];
5912
+ case 8:
5837
5913
  e_1_1 = _h.sent();
5838
5914
  e_1 = { error: e_1_1 };
5839
- return [3 /*break*/, 9];
5840
- case 8:
5915
+ return [3 /*break*/, 10];
5916
+ case 9:
5841
5917
  try {
5842
5918
  if (_b && !_b.done && (_g = _a.return)) _g.call(_a);
5843
5919
  }
5844
5920
  finally { if (e_1) throw e_1.error; }
5845
5921
  return [7 /*endfinally*/];
5846
- case 9: return [2 /*return*/, fileNames];
5922
+ case 10: return [2 /*return*/, fileNames];
5847
5923
  }
5848
5924
  });
5849
5925
  });
5850
5926
  }
5851
5927
  /**
5852
5928
  * Note: [🟢] This code should never be published outside of `@promptbook/node` and `@promptbook/cli` and `@promptbook/cli`
5929
+ * TODO: [🖇] What about symlinks?
5853
5930
  */
5854
5931
 
5855
5932
  /**
@@ -5970,7 +6047,7 @@ function createCollectionFromPromise(promptbookSourcesPromiseOrFactory) {
5970
6047
  */
5971
6048
  function createCollectionFromDirectory(path, options) {
5972
6049
  return __awaiter(this, void 0, void 0, function () {
5973
- 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;
5974
6051
  var _this = this;
5975
6052
  return __generator(this, function (_f) {
5976
6053
  switch (_f.label) {
@@ -5979,12 +6056,9 @@ function createCollectionFromDirectory(path, options) {
5979
6056
  throw new Error('Function `createCollectionFromDirectory` can only be run in Node.js environment because it reads the file system.');
5980
6057
  }
5981
6058
  makedLibraryFilePath = join$1(path, "".concat(PIPELINE_COLLECTION_BASE_FILENAME, ".json"));
5982
- return [4 /*yield*/, access(makedLibraryFilePath, constants.R_OK)
5983
- .then(function () { return true; })
5984
- .catch(function () { return false; })];
6059
+ return [4 /*yield*/, isFileExisting(makedLibraryFilePath)];
5985
6060
  case 1:
5986
- makedLibraryFileExists = _f.sent();
5987
- if (!makedLibraryFileExists) {
6061
+ if (!(_f.sent())) {
5988
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.")));
5989
6063
  }
5990
6064
  else {
@@ -6148,6 +6222,7 @@ function createCollectionFromDirectory(path, options) {
6148
6222
  }
6149
6223
  /**
6150
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
6151
6226
  */
6152
6227
 
6153
6228
  /**
@@ -7315,17 +7390,14 @@ var FilesStorage = /** @class */ (function () {
7315
7390
  */
7316
7391
  FilesStorage.prototype.getItem = function (key) {
7317
7392
  return __awaiter(this, void 0, void 0, function () {
7318
- var filename, isFileExisting, fileContent, value;
7393
+ var filename, fileContent, value;
7319
7394
  return __generator(this, function (_a) {
7320
7395
  switch (_a.label) {
7321
7396
  case 0:
7322
7397
  filename = this.getFilenameForKey(key);
7323
- return [4 /*yield*/, stat(filename)
7324
- .then(function (fileStat) { return fileStat.isFile(); })
7325
- .catch(function () { return false; })];
7398
+ return [4 /*yield*/, isFileExisting(filename)];
7326
7399
  case 1:
7327
- isFileExisting = _a.sent();
7328
- if (!isFileExisting) {
7400
+ if (!(_a.sent())) {
7329
7401
  return [2 /*return*/, null];
7330
7402
  }
7331
7403
  return [4 /*yield*/, readFile(filename, 'utf-8')];