@promptbook/cli 0.86.5 โ†’ 0.86.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@promptbook/cli",
3
- "version": "0.86.5",
3
+ "version": "0.86.6",
4
4
  "description": "It's time for a paradigm shift. The future of software in plain English, French or Latin",
5
5
  "private": false,
6
6
  "sideEffects": false,
package/umd/index.umd.js CHANGED
@@ -54,7 +54,7 @@
54
54
  * @generated
55
55
  * @see https://github.com/webgptorg/promptbook
56
56
  */
57
- var PROMPTBOOK_ENGINE_VERSION = '0.86.5';
57
+ var PROMPTBOOK_ENGINE_VERSION = '0.86.6';
58
58
  /**
59
59
  * TODO: string_promptbook_version should be constrained to the all versions of Promptbook engine
60
60
  * Note: [๐Ÿ’ž] Ignore a discrepancy between file name and entity name
@@ -7597,7 +7597,9 @@
7597
7597
  return __generator(this, function (_a) {
7598
7598
  dependentParameterNames = task.dependentParameterNames;
7599
7599
  preparedContent = undefined;
7600
- if (knowledgePiecesCount > 0 && !dependentParameterNames.includes('knowledge')) {
7600
+ if (task.taskType === 'PROMPT_TASK' &&
7601
+ knowledgePiecesCount > 0 &&
7602
+ !dependentParameterNames.includes('knowledge')) {
7601
7603
  preparedContent = spaceTrim.spaceTrim("\n {content}\n\n ## Knowledge\n\n {knowledge}\n ");
7602
7604
  // <- TODO: [๐Ÿง ][๐Ÿงป] Cutomize shape/language/formatting of the addition to the prompt
7603
7605
  dependentParameterNames = __spreadArray(__spreadArray([], __read(dependentParameterNames), false), [
@@ -13027,31 +13029,31 @@
13027
13029
  */
13028
13030
  function $getCompiledBook(tools, pipelineSource, options) {
13029
13031
  return __awaiter(this, void 0, void 0, function () {
13030
- var fs, fetch, filePathRaw, filePath, filePathCandidates, filePathCandidates_1, filePathCandidates_1_1, filePathCandidate, pipelineString, _a, pipelineJson, e_1_1, rootDirname, _loop_1, i, state_1, response_1, pipelineString, pipelineJson, pipelineJson;
13032
+ var fs, fetch, filePathRaw, filePath, filePathCandidates, filePathCandidates_1, filePathCandidates_1_1, filePathCandidate, pipelineString, _a, pipelineJson, compiledFilePath, bookcBundle, data, e_1_1, rootDirname, _loop_1, i, state_1, response_1, pipelineString, pipelineJson, pipelineJson;
13031
13033
  var e_1, _b;
13032
13034
  var _this = this;
13033
13035
  return __generator(this, function (_c) {
13034
13036
  switch (_c.label) {
13035
13037
  case 0:
13036
13038
  fs = tools.fs, fetch = tools.fetch;
13037
- if (!isValidFilePath(pipelineSource)) return [3 /*break*/, 10];
13039
+ if (!isValidFilePath(pipelineSource)) return [3 /*break*/, 12];
13038
13040
  filePathRaw = pipelineSource;
13039
13041
  filePath = null;
13040
13042
  filePathCandidates = [filePathRaw, "".concat(filePathRaw, ".md"), "".concat(filePathRaw, ".book"), "".concat(filePathRaw, ".book")];
13041
13043
  filePathCandidates = __spreadArray(__spreadArray([], __read(filePathCandidates), false), __read(filePathCandidates.map(function (path) { return path.split('\\').join('/'); })), false);
13042
13044
  _c.label = 1;
13043
13045
  case 1:
13044
- _c.trys.push([1, 8, 9, 10]);
13046
+ _c.trys.push([1, 10, 11, 12]);
13045
13047
  filePathCandidates_1 = __values(filePathCandidates), filePathCandidates_1_1 = filePathCandidates_1.next();
13046
13048
  _c.label = 2;
13047
13049
  case 2:
13048
- if (!!filePathCandidates_1_1.done) return [3 /*break*/, 7];
13050
+ if (!!filePathCandidates_1_1.done) return [3 /*break*/, 9];
13049
13051
  filePathCandidate = filePathCandidates_1_1.value;
13050
13052
  return [4 /*yield*/, isFileExisting(filePathCandidate, fs)
13051
13053
  // <- TODO: Also test that among the candidates the file is book not just any file
13052
13054
  ];
13053
13055
  case 3:
13054
- if (!_c.sent()) return [3 /*break*/, 6];
13056
+ if (!_c.sent()) return [3 /*break*/, 8];
13055
13057
  filePath = filePathCandidate;
13056
13058
  _a = validatePipelineString;
13057
13059
  return [4 /*yield*/, fs.readFile(filePath, 'utf-8')];
@@ -13060,23 +13062,32 @@
13060
13062
  return [4 /*yield*/, compilePipeline(pipelineString, tools, __assign({ rootDirname: process.cwd() }, options))];
13061
13063
  case 5:
13062
13064
  pipelineJson = _c.sent();
13063
- return [2 /*return*/, pipelineJson];
13065
+ compiledFilePath = filePath.replace('.book.md', '.book').replace('.book', '.bookc');
13066
+ bookcBundle = new JSZip__default["default"]();
13067
+ bookcBundle.file('index.book.json', JSON.stringify([pipelineJson]));
13068
+ return [4 /*yield*/, bookcBundle.generateAsync({ type: 'nodebuffer', streamFiles: true })];
13064
13069
  case 6:
13070
+ data = _c.sent();
13071
+ return [4 /*yield*/, fs.writeFile(compiledFilePath, data)];
13072
+ case 7:
13073
+ _c.sent();
13074
+ return [2 /*return*/, pipelineJson];
13075
+ case 8:
13065
13076
  filePathCandidates_1_1 = filePathCandidates_1.next();
13066
13077
  return [3 /*break*/, 2];
13067
- case 7: return [3 /*break*/, 10];
13068
- case 8:
13078
+ case 9: return [3 /*break*/, 12];
13079
+ case 10:
13069
13080
  e_1_1 = _c.sent();
13070
13081
  e_1 = { error: e_1_1 };
13071
- return [3 /*break*/, 10];
13072
- case 9:
13082
+ return [3 /*break*/, 12];
13083
+ case 11:
13073
13084
  try {
13074
13085
  if (filePathCandidates_1_1 && !filePathCandidates_1_1.done && (_b = filePathCandidates_1.return)) _b.call(filePathCandidates_1);
13075
13086
  }
13076
13087
  finally { if (e_1) throw e_1.error; }
13077
13088
  return [7 /*endfinally*/];
13078
- case 10:
13079
- if (!isValidPipelineUrl(pipelineSource)) return [3 /*break*/, 14];
13089
+ case 12:
13090
+ if (!isValidPipelineUrl(pipelineSource)) return [3 /*break*/, 16];
13080
13091
  rootDirname = process.cwd();
13081
13092
  _loop_1 = function (i) {
13082
13093
  var booksDirname, collection_1, pipeline;
@@ -13127,47 +13138,47 @@
13127
13138
  });
13128
13139
  };
13129
13140
  i = 0;
13130
- _c.label = 11;
13131
- case 11:
13132
- if (!(i < LOOP_LIMIT)) return [3 /*break*/, 14];
13141
+ _c.label = 13;
13142
+ case 13:
13143
+ if (!(i < LOOP_LIMIT)) return [3 /*break*/, 16];
13133
13144
  return [5 /*yield**/, _loop_1(i)];
13134
- case 12:
13145
+ case 14:
13135
13146
  state_1 = _c.sent();
13136
13147
  if (typeof state_1 === "object")
13137
13148
  return [2 /*return*/, state_1.value];
13138
13149
  switch (state_1) {
13139
- case "break-up_to_root": return [3 /*break*/, 14];
13150
+ case "break-up_to_root": return [3 /*break*/, 16];
13140
13151
  }
13141
- _c.label = 13;
13142
- case 13:
13152
+ _c.label = 15;
13153
+ case 15:
13143
13154
  i++;
13144
- return [3 /*break*/, 11];
13145
- case 14:
13146
- if (!isValidPipelineUrl(pipelineSource)) return [3 /*break*/, 18];
13155
+ return [3 /*break*/, 13];
13156
+ case 16:
13157
+ if (!isValidPipelineUrl(pipelineSource)) return [3 /*break*/, 20];
13147
13158
  return [4 /*yield*/, fetch(pipelineSource)];
13148
- case 15:
13159
+ case 17:
13149
13160
  response_1 = _c.sent();
13150
13161
  if (response_1.status >= 300) {
13151
13162
  throw new NotFoundError(spaceTrim__default["default"](function (block) { return "\n Book not found on URL:\n ".concat(block(pipelineSource), "\n\n Request failed with status ").concat(block(response_1.status.toString()), " ").concat(block(response_1.statusText), "\n "); }));
13152
13163
  }
13153
13164
  return [4 /*yield*/, response_1.text()];
13154
- case 16:
13165
+ case 18:
13155
13166
  pipelineString = _c.sent();
13156
13167
  // console.log({ pipelineString });
13157
13168
  if (!isValidPipelineString(pipelineString)) {
13158
13169
  throw new NotFoundError(spaceTrim__default["default"](function (block) { return "\n Book not found on URL:\n ".concat(block(pipelineSource), "\n\n Requested URL does not seem to contain a valid book\n "); }));
13159
13170
  }
13160
13171
  return [4 /*yield*/, compilePipeline(pipelineString, tools, __assign({ rootDirname: null }, options))];
13161
- case 17:
13172
+ case 19:
13162
13173
  pipelineJson = _c.sent();
13163
13174
  return [2 /*return*/, pipelineJson];
13164
- case 18:
13165
- if (!isValidPipelineString(pipelineSource)) return [3 /*break*/, 20];
13175
+ case 20:
13176
+ if (!isValidPipelineString(pipelineSource)) return [3 /*break*/, 22];
13166
13177
  return [4 /*yield*/, compilePipeline(pipelineSource, tools, __assign({ rootDirname: null }, options))];
13167
- case 19:
13178
+ case 21:
13168
13179
  pipelineJson = _c.sent();
13169
13180
  return [2 /*return*/, pipelineJson];
13170
- case 20: /* not else */ throw new NotFoundError(spaceTrim__default["default"](function (block) { return "\n Book not found:\n ".concat(block(pipelineSource), "\n\n Pipelines can be loaded from:\n 1) As a file ./books/write-cv.book\n 2) As a URL https://promptbook.studio/hejny/write-cv.book found in ./books folder recursively\n 2) As a URL https://promptbook.studio/hejny/write-cv.book fetched from the internet\n 3) As a string\n\n\n "); }));
13181
+ case 22: /* not else */ throw new NotFoundError(spaceTrim__default["default"](function (block) { return "\n Book not found:\n ".concat(block(pipelineSource), "\n\n Pipelines can be loaded from:\n 1) As a file ./books/write-cv.book\n 2) As a URL https://promptbook.studio/hejny/write-cv.book found in ./books folder recursively\n 2) As a URL https://promptbook.studio/hejny/write-cv.book fetched from the internet\n 3) As a string\n\n\n "); }));
13171
13182
  }
13172
13183
  });
13173
13184
  });