@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/README.md CHANGED
@@ -146,17 +146,22 @@ Promptbook project is ecosystem of multiple projects and tools, following is a l
146
146
  <tr>
147
147
  <td><a href="https://github.com/webgptorg/book">Book language</a></td>
148
148
  <td>
149
- Book is a markdown-like language to define core entities like personas, knowledge, tasks,.... It is designed to be understandable by non-programmers and non-technical people<hr>
149
+ Book is a human-understandable markup language for writing AI applications such as chatbots, knowledge bases, agents, avarars, translators, automations and more.
150
+ <hr>
150
151
  There is also <a href="https://github.com/webgptorg/book-extension">a plugin for VSCode</a> to support <code>.book</code> file extension
151
152
  </td>
152
153
  </tr>
153
154
  <tr>
154
155
  <td><a href="https://github.com/webgptorg/promptbook">Promptbook Engine</a></td>
155
- <td>Promptbook implementation in TypeScript released as <a href="https://www.npmjs.com/package/@promptbook/core#-packages-for-developers">multiple NPM packages</a> and <a href="https://hub.docker.com/r/hejny/promptbook">Docker HUB</a></td>
156
+ <td>
157
+ Promptbook engine can run applications written in Book language. It is released as <a href="https://www.npmjs.com/package/@promptbook/core#-packages-for-developers">multiple NPM packages</a> and <a href="https://hub.docker.com/r/hejny/promptbook">Docker HUB</a>
158
+ </td>
156
159
  </tr>
157
160
  <tr>
158
161
  <td><a href="https://promptbook.studio">Promptbook Studio</a></td>
159
- <td>Studio to write Books and instantly publish them as miniapps</td>
162
+ <td>
163
+ Promptbook.studio is a web-based editor and runner for book applications. It is still in the experimental MVP stage.
164
+ </td>
160
165
  </tr>
161
166
  </tbody>
162
167
  </table>
@@ -175,25 +180,25 @@ And **Promptbook.studio** branded socials:
175
180
 
176
181
  - [Instagram `@promptbook.studio`](https://www.instagram.com/promptbook.studio/)
177
182
 
178
-
179
-
180
183
  And **Promptujeme** sub-brand:
181
184
 
182
- */Subbrand for Czech clients/*
185
+ _/Subbrand for Czech clients/_
186
+
183
187
 
184
188
 
185
189
 
186
190
  - [Promptujeme.cz](https://www.promptujeme.cz/)
187
191
  - [Facebook `Promptujeme`](https://www.facebook.com/promptujeme/)
188
192
 
189
-
190
193
  And **Promptbook.city** branded socials:
191
194
 
192
- */Sub-brand for images and graphics generated via Promptbook prompting/*
195
+ _/Sub-brand for images and graphics generated via Promptbook prompting/_
193
196
 
194
197
  - [Instagram `@promptbook.city`](https://www.instagram.com/promptbook.city/)
195
198
  - [Facebook `Promptbook City`](https://www.facebook.com/61565718625569)
196
199
 
200
+ ##
201
+
197
202
 
198
203
 
199
204
 
package/esm/index.es.js CHANGED
@@ -44,7 +44,7 @@ var BOOK_LANGUAGE_VERSION = '1.0.0';
44
44
  * @generated
45
45
  * @see https://github.com/webgptorg/promptbook
46
46
  */
47
- var PROMPTBOOK_ENGINE_VERSION = '0.86.5';
47
+ var PROMPTBOOK_ENGINE_VERSION = '0.86.6';
48
48
  /**
49
49
  * TODO: string_promptbook_version should be constrained to the all versions of Promptbook engine
50
50
  * Note: [๐Ÿ’ž] Ignore a discrepancy between file name and entity name
@@ -7587,7 +7587,9 @@ function prepareTasks(pipeline, tools, options) {
7587
7587
  return __generator(this, function (_a) {
7588
7588
  dependentParameterNames = task.dependentParameterNames;
7589
7589
  preparedContent = undefined;
7590
- if (knowledgePiecesCount > 0 && !dependentParameterNames.includes('knowledge')) {
7590
+ if (task.taskType === 'PROMPT_TASK' &&
7591
+ knowledgePiecesCount > 0 &&
7592
+ !dependentParameterNames.includes('knowledge')) {
7591
7593
  preparedContent = spaceTrim$1("\n {content}\n\n ## Knowledge\n\n {knowledge}\n ");
7592
7594
  // <- TODO: [๐Ÿง ][๐Ÿงป] Cutomize shape/language/formatting of the addition to the prompt
7593
7595
  dependentParameterNames = __spreadArray(__spreadArray([], __read(dependentParameterNames), false), [
@@ -13017,31 +13019,31 @@ function isValidPipelineString(pipelineString) {
13017
13019
  */
13018
13020
  function $getCompiledBook(tools, pipelineSource, options) {
13019
13021
  return __awaiter(this, void 0, void 0, function () {
13020
- 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;
13022
+ 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;
13021
13023
  var e_1, _b;
13022
13024
  var _this = this;
13023
13025
  return __generator(this, function (_c) {
13024
13026
  switch (_c.label) {
13025
13027
  case 0:
13026
13028
  fs = tools.fs, fetch = tools.fetch;
13027
- if (!isValidFilePath(pipelineSource)) return [3 /*break*/, 10];
13029
+ if (!isValidFilePath(pipelineSource)) return [3 /*break*/, 12];
13028
13030
  filePathRaw = pipelineSource;
13029
13031
  filePath = null;
13030
13032
  filePathCandidates = [filePathRaw, "".concat(filePathRaw, ".md"), "".concat(filePathRaw, ".book"), "".concat(filePathRaw, ".book")];
13031
13033
  filePathCandidates = __spreadArray(__spreadArray([], __read(filePathCandidates), false), __read(filePathCandidates.map(function (path) { return path.split('\\').join('/'); })), false);
13032
13034
  _c.label = 1;
13033
13035
  case 1:
13034
- _c.trys.push([1, 8, 9, 10]);
13036
+ _c.trys.push([1, 10, 11, 12]);
13035
13037
  filePathCandidates_1 = __values(filePathCandidates), filePathCandidates_1_1 = filePathCandidates_1.next();
13036
13038
  _c.label = 2;
13037
13039
  case 2:
13038
- if (!!filePathCandidates_1_1.done) return [3 /*break*/, 7];
13040
+ if (!!filePathCandidates_1_1.done) return [3 /*break*/, 9];
13039
13041
  filePathCandidate = filePathCandidates_1_1.value;
13040
13042
  return [4 /*yield*/, isFileExisting(filePathCandidate, fs)
13041
13043
  // <- TODO: Also test that among the candidates the file is book not just any file
13042
13044
  ];
13043
13045
  case 3:
13044
- if (!_c.sent()) return [3 /*break*/, 6];
13046
+ if (!_c.sent()) return [3 /*break*/, 8];
13045
13047
  filePath = filePathCandidate;
13046
13048
  _a = validatePipelineString;
13047
13049
  return [4 /*yield*/, fs.readFile(filePath, 'utf-8')];
@@ -13050,23 +13052,32 @@ function $getCompiledBook(tools, pipelineSource, options) {
13050
13052
  return [4 /*yield*/, compilePipeline(pipelineString, tools, __assign({ rootDirname: process.cwd() }, options))];
13051
13053
  case 5:
13052
13054
  pipelineJson = _c.sent();
13053
- return [2 /*return*/, pipelineJson];
13055
+ compiledFilePath = filePath.replace('.book.md', '.book').replace('.book', '.bookc');
13056
+ bookcBundle = new JSZip();
13057
+ bookcBundle.file('index.book.json', JSON.stringify([pipelineJson]));
13058
+ return [4 /*yield*/, bookcBundle.generateAsync({ type: 'nodebuffer', streamFiles: true })];
13054
13059
  case 6:
13060
+ data = _c.sent();
13061
+ return [4 /*yield*/, fs.writeFile(compiledFilePath, data)];
13062
+ case 7:
13063
+ _c.sent();
13064
+ return [2 /*return*/, pipelineJson];
13065
+ case 8:
13055
13066
  filePathCandidates_1_1 = filePathCandidates_1.next();
13056
13067
  return [3 /*break*/, 2];
13057
- case 7: return [3 /*break*/, 10];
13058
- case 8:
13068
+ case 9: return [3 /*break*/, 12];
13069
+ case 10:
13059
13070
  e_1_1 = _c.sent();
13060
13071
  e_1 = { error: e_1_1 };
13061
- return [3 /*break*/, 10];
13062
- case 9:
13072
+ return [3 /*break*/, 12];
13073
+ case 11:
13063
13074
  try {
13064
13075
  if (filePathCandidates_1_1 && !filePathCandidates_1_1.done && (_b = filePathCandidates_1.return)) _b.call(filePathCandidates_1);
13065
13076
  }
13066
13077
  finally { if (e_1) throw e_1.error; }
13067
13078
  return [7 /*endfinally*/];
13068
- case 10:
13069
- if (!isValidPipelineUrl(pipelineSource)) return [3 /*break*/, 14];
13079
+ case 12:
13080
+ if (!isValidPipelineUrl(pipelineSource)) return [3 /*break*/, 16];
13070
13081
  rootDirname = process.cwd();
13071
13082
  _loop_1 = function (i) {
13072
13083
  var booksDirname, collection_1, pipeline;
@@ -13117,47 +13128,47 @@ function $getCompiledBook(tools, pipelineSource, options) {
13117
13128
  });
13118
13129
  };
13119
13130
  i = 0;
13120
- _c.label = 11;
13121
- case 11:
13122
- if (!(i < LOOP_LIMIT)) return [3 /*break*/, 14];
13131
+ _c.label = 13;
13132
+ case 13:
13133
+ if (!(i < LOOP_LIMIT)) return [3 /*break*/, 16];
13123
13134
  return [5 /*yield**/, _loop_1(i)];
13124
- case 12:
13135
+ case 14:
13125
13136
  state_1 = _c.sent();
13126
13137
  if (typeof state_1 === "object")
13127
13138
  return [2 /*return*/, state_1.value];
13128
13139
  switch (state_1) {
13129
- case "break-up_to_root": return [3 /*break*/, 14];
13140
+ case "break-up_to_root": return [3 /*break*/, 16];
13130
13141
  }
13131
- _c.label = 13;
13132
- case 13:
13142
+ _c.label = 15;
13143
+ case 15:
13133
13144
  i++;
13134
- return [3 /*break*/, 11];
13135
- case 14:
13136
- if (!isValidPipelineUrl(pipelineSource)) return [3 /*break*/, 18];
13145
+ return [3 /*break*/, 13];
13146
+ case 16:
13147
+ if (!isValidPipelineUrl(pipelineSource)) return [3 /*break*/, 20];
13137
13148
  return [4 /*yield*/, fetch(pipelineSource)];
13138
- case 15:
13149
+ case 17:
13139
13150
  response_1 = _c.sent();
13140
13151
  if (response_1.status >= 300) {
13141
13152
  throw new NotFoundError(spaceTrim(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 "); }));
13142
13153
  }
13143
13154
  return [4 /*yield*/, response_1.text()];
13144
- case 16:
13155
+ case 18:
13145
13156
  pipelineString = _c.sent();
13146
13157
  // console.log({ pipelineString });
13147
13158
  if (!isValidPipelineString(pipelineString)) {
13148
13159
  throw new NotFoundError(spaceTrim(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 "); }));
13149
13160
  }
13150
13161
  return [4 /*yield*/, compilePipeline(pipelineString, tools, __assign({ rootDirname: null }, options))];
13151
- case 17:
13162
+ case 19:
13152
13163
  pipelineJson = _c.sent();
13153
13164
  return [2 /*return*/, pipelineJson];
13154
- case 18:
13155
- if (!isValidPipelineString(pipelineSource)) return [3 /*break*/, 20];
13165
+ case 20:
13166
+ if (!isValidPipelineString(pipelineSource)) return [3 /*break*/, 22];
13156
13167
  return [4 /*yield*/, compilePipeline(pipelineSource, tools, __assign({ rootDirname: null }, options))];
13157
- case 19:
13168
+ case 21:
13158
13169
  pipelineJson = _c.sent();
13159
13170
  return [2 /*return*/, pipelineJson];
13160
- case 20: /* not else */ throw new NotFoundError(spaceTrim(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
+ case 22: /* not else */ throw new NotFoundError(spaceTrim(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 "); }));
13161
13172
  }
13162
13173
  });
13163
13174
  });