@promptbook/cli 0.86.0-8 → 0.86.5
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 +48 -58
- package/esm/index.es.js +60 -27
- package/esm/index.es.js.map +1 -1
- package/esm/typings/src/cli/test/ptbk2.d.ts +5 -0
- package/esm/typings/src/conversion/compilePipeline.d.ts +1 -1
- package/esm/typings/src/conversion/compilePipelineOnRemoteServer.d.ts +1 -1
- package/esm/typings/src/conversion/parsePipeline.d.ts +1 -1
- package/esm/typings/src/conversion/pipelineJsonToString.d.ts +1 -1
- package/esm/typings/src/conversion/validation/_importPipeline.d.ts +6 -6
- package/esm/typings/src/pipeline/PipelineJson/PreparationJson.d.ts +1 -1
- package/package.json +2 -1
- package/umd/index.umd.js +64 -31
- package/umd/index.umd.js.map +1 -1
package/README.md
CHANGED
|
@@ -5,8 +5,8 @@
|
|
|
5
5
|
|
|
6
6
|
|
|
7
7
|
|
|
8
|
-
[ Promptbook](https://badge.fury.io/js/promptbook.svg)](https://www.npmjs.com/package/promptbook)
|
|
9
|
+
[ Promptbook](https://packagequality.com/shield/promptbook.svg)](https://packagequality.com/#?package=promptbook)
|
|
10
10
|
[](https://snyk.io/test/github/webgptorg/promptbook)
|
|
11
11
|
[](https://github.com/webgptorg/promptbook/issues)
|
|
12
12
|
|
|
@@ -17,18 +17,12 @@
|
|
|
17
17
|
## 🌟 New Features
|
|
18
18
|
|
|
19
19
|
- 📂 We have plugin for [VSCode](https://github.com/webgptorg/book-extension) to support `.book` file extension
|
|
20
|
+
- 🐳 Available [Docker image](https://hub.docker.com/r/hejny/promptbook/)
|
|
20
21
|
- 💫 Support of [`o3-mini` model by OpenAI](https://openai.com/index/openai-o3-mini/)
|
|
21
22
|
- 🐋 **Support of [DeepSeek models](https://www.npmjs.com/package/@promptbook/deepseek)**
|
|
22
|
-
- 💙 Working [the **Book** language v1.0.0](https://github.com/webgptorg/book)
|
|
23
|
-
- 🖤 Run books from CLI - `npx ptbk run path/to/your/book`
|
|
24
|
-
- 📚 Support of `.docx`, `.doc` and `.pdf` documents as knowledge
|
|
25
23
|
|
|
26
24
|
|
|
27
25
|
|
|
28
|
-
<blockquote style="color: #ff8811">
|
|
29
|
-
<b>⚠ Warning:</b> This is a pre-release version of the library. It is not yet ready for production use. Please look at <a href="https://www.npmjs.com/package/@promptbook/core?activeTab=versions">latest stable release</a>.
|
|
30
|
-
</blockquote>
|
|
31
|
-
|
|
32
26
|
## 📦 Package `@promptbook/cli`
|
|
33
27
|
|
|
34
28
|
- Promptbooks are [divided into several](#-packages) packages, all are published from [single monorepo](https://github.com/webgptorg/promptbook).
|
|
@@ -114,6 +108,8 @@ Rest of the documentation is common for **entire promptbook ecosystem**:
|
|
|
114
108
|
|
|
115
109
|
During the computer revolution, we have seen [multiple generations of computer languages](https://github.com/webgptorg/promptbook/discussions/180), from the physical rewiring of the vacuum tubes through low-level machine code to the high-level languages like Python or JavaScript. And now, we're on the edge of the **next revolution**!
|
|
116
110
|
|
|
111
|
+
|
|
112
|
+
|
|
117
113
|
It's a revolution of writing software in **plain human language** that is understandable and executable by both humans and machines – and it's going to change everything!
|
|
118
114
|
|
|
119
115
|
The incredible growth in power of microprocessors and the Moore's Law have been the driving force behind the ever-more powerful languages, and it's been an amazing journey! Similarly, the large language models (like GPT or Claude) are the next big thing in language technology, and they're set to transform the way we interact with computers.
|
|
@@ -171,34 +167,41 @@ We also have a community of developers and users of **Promptbook**:
|
|
|
171
167
|
- [Landing page `ptbk.io`](https://ptbk.io)
|
|
172
168
|
- [Github discussions](https://github.com/webgptorg/promptbook/discussions)
|
|
173
169
|
- [LinkedIn `Promptbook`](https://linkedin.com/company/promptbook)
|
|
174
|
-
- [Facebook `Promptbook`](https://www.facebook.com/61560776453536)
|
|
170
|
+
- [Facebook `Promptbook`](https://www.facebook.com/61560776453536)
|
|
175
171
|
|
|
176
172
|
And **Promptbook.studio** branded socials:
|
|
177
173
|
|
|
174
|
+
|
|
175
|
+
|
|
178
176
|
- [Instagram `@promptbook.studio`](https://www.instagram.com/promptbook.studio/)
|
|
179
177
|
|
|
178
|
+
|
|
179
|
+
|
|
180
180
|
And **Promptujeme** sub-brand:
|
|
181
181
|
|
|
182
|
-
|
|
182
|
+
*/Subbrand for Czech clients/*
|
|
183
|
+
|
|
184
|
+
|
|
183
185
|
|
|
184
186
|
- [Promptujeme.cz](https://www.promptujeme.cz/)
|
|
185
187
|
- [Facebook `Promptujeme`](https://www.facebook.com/promptujeme/)
|
|
186
188
|
|
|
189
|
+
|
|
187
190
|
And **Promptbook.city** branded socials:
|
|
188
191
|
|
|
189
|
-
|
|
192
|
+
*/Sub-brand for images and graphics generated via Promptbook prompting/*
|
|
190
193
|
|
|
191
194
|
- [Instagram `@promptbook.city`](https://www.instagram.com/promptbook.city/)
|
|
192
|
-
- [Facebook `Promptbook City`](https://www.facebook.com/61565718625569)
|
|
195
|
+
- [Facebook `Promptbook City`](https://www.facebook.com/61565718625569)
|
|
193
196
|
|
|
194
197
|
|
|
195
198
|
|
|
196
|
-
## 💙 Book language _(for prompt-engineer)_
|
|
197
199
|
|
|
198
200
|
|
|
199
201
|
|
|
202
|
+
## 💙 The Book language
|
|
203
|
+
|
|
200
204
|
|
|
201
|
-
## 💙 The blueprint of book language
|
|
202
205
|
|
|
203
206
|
Following is the documentation and blueprint of the Book language.
|
|
204
207
|
|
|
@@ -207,6 +210,11 @@ Following is the documentation and blueprint of the Book language.
|
|
|
207
210
|
```markdown
|
|
208
211
|
# 🌟 My first Book
|
|
209
212
|
|
|
213
|
+
- BOOK VERSION 1.0.0
|
|
214
|
+
- URL https://promptbook.studio/my-first-book/
|
|
215
|
+
|
|
216
|
+
# Write an article
|
|
217
|
+
|
|
210
218
|
- PERSONA Jane, marketing specialist with prior experience in writing articles about technology and artificial intelligence
|
|
211
219
|
- KNOWLEDGE https://ptbk.io
|
|
212
220
|
- KNOWLEDGE ./promptbook.pdf
|
|
@@ -219,59 +227,31 @@ Following is the documentation and blueprint of the Book language.
|
|
|
219
227
|
-> {article}
|
|
220
228
|
```
|
|
221
229
|
|
|
222
|
-
###
|
|
223
|
-
|
|
224
|
-
File is designed to be easy to read and write. It is strict subset of markdown. It is designed to be understandable by both humans and machines and without specific knowledge of the language.
|
|
225
|
-
|
|
226
|
-
It has file with `.book.md` or `.book` extension with `UTF-8` non BOM encoding.
|
|
227
|
-
|
|
228
|
-
As it is source code, it can leverage all the features of version control systems like git and does not suffer from the problems of binary formats, proprietary formats, or no-code solutions.
|
|
229
|
-
|
|
230
|
-
But unlike programming languages, it is designed to be understandable by non-programmers and non-technical people.
|
|
231
|
-
|
|
232
|
-
### Structure
|
|
233
|
-
|
|
234
|
-
Book is divided into sections. Each section starts with heading. The language itself is not sensitive to the type of heading _(`h1`, `h2`, `h3`, ...)_ but it is recommended to use `h1` for header section and `h2` for other sections.
|
|
235
|
-
|
|
236
|
-
### Header
|
|
237
|
-
|
|
238
|
-
Header is the first section of the book. It contains metadata about the pipeline. It is recommended to use `h1` heading for header section but it is not required.
|
|
239
|
-
|
|
240
|
-
### Parameter
|
|
230
|
+
### **What:** Workflows, Tasks and Parameters
|
|
241
231
|
|
|
242
|
-
|
|
232
|
+
- [PARAMETER](https://github.com/webgptorg/promptbook/blob/main/documents/commands/PARAMETER.md)
|
|
243
233
|
|
|
244
|
-
|
|
234
|
+
### **Who:** Personas
|
|
245
235
|
|
|
246
|
-
|
|
236
|
+
- [PERSONA](https://github.com/webgptorg/promptbook/blob/main/documents/commands/PERSONA.md)
|
|
247
237
|
|
|
248
|
-
|
|
249
|
-
- `content`
|
|
250
|
-
- `context`
|
|
251
|
-
- `knowledge`
|
|
252
|
-
- `examples`
|
|
253
|
-
- `modelName`
|
|
254
|
-
- `currentDate`
|
|
238
|
+
### **How:** Knowledge, Instruments and Actions
|
|
255
239
|
|
|
256
|
-
|
|
240
|
+
- [KNOWLEDGE](https://github.com/webgptorg/promptbook/blob/main/documents/commands/KNOWLEDGE.md)
|
|
241
|
+
- [INSTRUMENT](https://github.com/webgptorg/promptbook/blob/main/documents/commands/INSTRUMENT.md)
|
|
242
|
+
- [ACTION](https://github.com/webgptorg/promptbook/blob/main/documents/commands/ACTION.md)
|
|
257
243
|
|
|
258
|
-
###
|
|
244
|
+
### General principles of book language
|
|
259
245
|
|
|
260
|
-
|
|
246
|
+
Book language is based on markdown. It is subset of markdown. It is designed to be easy to read and write. It is designed to be understandable by both humans and machines and without specific knowledge of the language.
|
|
261
247
|
|
|
262
|
-
|
|
248
|
+
The file has `.book` extension. It uses `UTF-8` non BOM encoding.
|
|
263
249
|
|
|
264
|
-
|
|
250
|
+
Book has two variants: flat - which is just a prompt with no structure, and full - which has a structure with tasks, commands and prompts.
|
|
265
251
|
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
### Block
|
|
269
|
-
|
|
270
|
-
Todo todo
|
|
271
|
-
|
|
272
|
-
### Return parameter
|
|
252
|
+
As it is source code, it can leverage all the features of version control systems like git and does not suffer from the problems of binary formats, proprietary formats, or no-code solutions.
|
|
273
253
|
|
|
274
|
-
|
|
254
|
+
But unlike programming languages, it is designed to be understandable by non-programmers and non-technical people.
|
|
275
255
|
|
|
276
256
|
|
|
277
257
|
|
|
@@ -317,6 +297,7 @@ Or you can install them separately:
|
|
|
317
297
|
- **[@promptbook/templates](https://www.npmjs.com/package/@promptbook/templates)** - Usefull templates and examples of books which can be used as a starting point
|
|
318
298
|
- **[@promptbook/types](https://www.npmjs.com/package/@promptbook/types)** - Just typescript types used in the library
|
|
319
299
|
- ⭐ **[@promptbook/cli](https://www.npmjs.com/package/@promptbook/cli)** - Command line interface utilities for promptbooks
|
|
300
|
+
- 🐋 **[Docker image](https://hub.docker.com/r/hejny/promptbook/)** - Promptbook server
|
|
320
301
|
|
|
321
302
|
|
|
322
303
|
|
|
@@ -325,6 +306,11 @@ Or you can install them separately:
|
|
|
325
306
|
|
|
326
307
|
## 📚 Dictionary
|
|
327
308
|
|
|
309
|
+
|
|
310
|
+
|
|
311
|
+
|
|
312
|
+
|
|
313
|
+
|
|
328
314
|
### 📚 Dictionary
|
|
329
315
|
|
|
330
316
|
The following glossary is used to clarify certain concepts:
|
|
@@ -340,6 +326,8 @@ The following glossary is used to clarify certain concepts:
|
|
|
340
326
|
- **Retrieval-augmented generation** is a machine learning paradigm where a model generates text by retrieving relevant information from a large database of text. This approach combines the benefits of generative models and retrieval models.
|
|
341
327
|
- **Longtail** refers to non-common or rare events, items, or entities that are not well-represented in the training data of machine learning models. Longtail items are often challenging for models to predict accurately.
|
|
342
328
|
|
|
329
|
+
|
|
330
|
+
|
|
343
331
|
_Note: Thos section is not complete dictionary, more list of general AI / LLM terms that has connection with Promptbook_
|
|
344
332
|
|
|
345
333
|
#### Promptbook core
|
|
@@ -400,6 +388,8 @@ _Note: Thos section is not complete dictionary, more list of general AI / LLM te
|
|
|
400
388
|
- [👮 Agent adversary expectations](https://github.com/webgptorg/promptbook/discussions/39)
|
|
401
389
|
- [view more](https://github.com/webgptorg/promptbook/discussions/categories/concepts)
|
|
402
390
|
|
|
391
|
+
|
|
392
|
+
|
|
403
393
|
### Terms specific to Promptbook TypeScript implementation
|
|
404
394
|
|
|
405
395
|
- Anonymous mode
|
|
@@ -479,7 +469,7 @@ See [TODO.md](./TODO.md)
|
|
|
479
469
|
<div style="display: flex; align-items: center; gap: 20px;">
|
|
480
470
|
|
|
481
471
|
<a href="https://promptbook.studio/">
|
|
482
|
-
<img src="./
|
|
472
|
+
<img src="./design/promptbook-studio-logo.png" alt="Partner 3" height="100">
|
|
483
473
|
</a>
|
|
484
474
|
|
|
485
475
|
<a href="https://technologickainkubace.org/en/about-technology-incubation/about-the-project/">
|
package/esm/index.es.js
CHANGED
|
@@ -8,6 +8,7 @@ import hexEncoder from 'crypto-js/enc-hex';
|
|
|
8
8
|
import sha256 from 'crypto-js/sha256';
|
|
9
9
|
import * as dotenv from 'dotenv';
|
|
10
10
|
import { spawn } from 'child_process';
|
|
11
|
+
import JSZip from 'jszip';
|
|
11
12
|
import { format } from 'prettier';
|
|
12
13
|
import parserHtml from 'prettier/parser-html';
|
|
13
14
|
import { BehaviorSubject } from 'rxjs';
|
|
@@ -43,7 +44,7 @@ var BOOK_LANGUAGE_VERSION = '1.0.0';
|
|
|
43
44
|
* @generated
|
|
44
45
|
* @see https://github.com/webgptorg/promptbook
|
|
45
46
|
*/
|
|
46
|
-
var PROMPTBOOK_ENGINE_VERSION = '0.86.
|
|
47
|
+
var PROMPTBOOK_ENGINE_VERSION = '0.86.5';
|
|
47
48
|
/**
|
|
48
49
|
* TODO: string_promptbook_version should be constrained to the all versions of Promptbook engine
|
|
49
50
|
* Note: [💞] Ignore a discrepancy between file name and entity name
|
|
@@ -549,6 +550,7 @@ function $initializeHelloCommand(program) {
|
|
|
549
550
|
var _this = this;
|
|
550
551
|
var helloCommand = program.command('hello');
|
|
551
552
|
helloCommand.description(spaceTrim("\n Just command for testing\n "));
|
|
553
|
+
helloCommand.alias('hi');
|
|
552
554
|
helloCommand.argument('[name]', 'Your name', 'Paul');
|
|
553
555
|
helloCommand.option('-g, --greeting <greeting>', "Greeting", 'Hello');
|
|
554
556
|
helloCommand.action(function (name, _a) {
|
|
@@ -2922,6 +2924,8 @@ function $initializeListModelsCommand(program) {
|
|
|
2922
2924
|
var _this = this;
|
|
2923
2925
|
var listModelsCommand = program.command('list-models');
|
|
2924
2926
|
listModelsCommand.description(spaceTrim("\n List all available and configured LLM models\n "));
|
|
2927
|
+
listModelsCommand.alias('models');
|
|
2928
|
+
listModelsCommand.alias('llm');
|
|
2925
2929
|
listModelsCommand.action(function () { return __awaiter(_this, void 0, void 0, function () {
|
|
2926
2930
|
var llm;
|
|
2927
2931
|
return __generator(this, function (_a) {
|
|
@@ -3607,6 +3611,7 @@ function $initializeListScrapersCommand(program) {
|
|
|
3607
3611
|
var _this = this;
|
|
3608
3612
|
var listModelsCommand = program.command('list-scrapers');
|
|
3609
3613
|
listModelsCommand.description(spaceTrim("\n List all available and configured scrapers and executables\n "));
|
|
3614
|
+
listModelsCommand.alias('scrapers');
|
|
3610
3615
|
listModelsCommand.action(function () { return __awaiter(_this, void 0, void 0, function () {
|
|
3611
3616
|
var scrapers, executables;
|
|
3612
3617
|
return __generator(this, function (_a) {
|
|
@@ -3798,7 +3803,7 @@ function capitalize(word) {
|
|
|
3798
3803
|
* Converts promptbook in JSON format to string format
|
|
3799
3804
|
*
|
|
3800
3805
|
* @deprecated TODO: [🥍][🧠] Backup original files in `PipelineJson` same as in Promptbook.studio
|
|
3801
|
-
* @param pipelineJson Promptbook in JSON format (.
|
|
3806
|
+
* @param pipelineJson Promptbook in JSON format (.bookc)
|
|
3802
3807
|
* @returns Promptbook in string format (.book.md)
|
|
3803
3808
|
* @public exported from `@promptbook/core`
|
|
3804
3809
|
*/
|
|
@@ -10744,7 +10749,7 @@ function flattenMarkdown(markdown) {
|
|
|
10744
10749
|
* Note: This function acts as compilation process
|
|
10745
10750
|
*
|
|
10746
10751
|
* @param pipelineString {Promptbook} in string markdown format (.book.md)
|
|
10747
|
-
* @returns {Promptbook} compiled in JSON format (.
|
|
10752
|
+
* @returns {Promptbook} compiled in JSON format (.bookc)
|
|
10748
10753
|
* @throws {ParseError} if the promptbook string is not valid
|
|
10749
10754
|
* @public exported from `@promptbook/core`
|
|
10750
10755
|
*/
|
|
@@ -11212,7 +11217,7 @@ function parsePipeline(pipelineString) {
|
|
|
11212
11217
|
* @param pipelineString {Promptbook} in string markdown format (.book.md)
|
|
11213
11218
|
* @param tools - Tools for the preparation and scraping - if not provided together with `llm`, the preparation will be skipped
|
|
11214
11219
|
* @param options - Options and tools for the compilation
|
|
11215
|
-
* @returns {Promptbook} compiled in JSON format (.
|
|
11220
|
+
* @returns {Promptbook} compiled in JSON format (.bookc)
|
|
11216
11221
|
* @throws {ParseError} if the promptbook string is not valid
|
|
11217
11222
|
* @public exported from `@promptbook/core`
|
|
11218
11223
|
*/
|
|
@@ -12006,7 +12011,7 @@ function createCollectionFromDirectory(rootPath, tools, options) {
|
|
|
12006
12011
|
}
|
|
12007
12012
|
madeLibraryFilePath = join(rootPath, "".concat(DEFAULT_PIPELINE_COLLECTION_BASE_FILENAME
|
|
12008
12013
|
// <- TODO: [🦒] Allow to override (pass different value into the function)
|
|
12009
|
-
, ".
|
|
12014
|
+
, ".bookc"));
|
|
12010
12015
|
return [4 /*yield*/, isFileExisting(madeLibraryFilePath, tools.fs)];
|
|
12011
12016
|
case 3:
|
|
12012
12017
|
if (!(_f.sent())) ;
|
|
@@ -12028,13 +12033,13 @@ function createCollectionFromDirectory(rootPath, tools, options) {
|
|
|
12028
12033
|
return [4 /*yield*/, listAllFiles(rootPath, isRecursive, tools.fs)];
|
|
12029
12034
|
case 1:
|
|
12030
12035
|
fileNames = _b.sent();
|
|
12031
|
-
// Note: First load
|
|
12032
|
-
// `.
|
|
12036
|
+
// Note: First load compiled `.bookc` files and then source `.book` files
|
|
12037
|
+
// `.bookc` are already compiled and can be used faster
|
|
12033
12038
|
fileNames.sort(function (a, b) {
|
|
12034
|
-
if (a.endsWith('.json') && (b.endsWith('.book') || b.endsWith('.book'))) {
|
|
12039
|
+
if ((a.endsWith('.bookc') || a.endsWith('.book.json')) && (b.endsWith('.book') || b.endsWith('.book.md'))) {
|
|
12035
12040
|
return -1;
|
|
12036
12041
|
}
|
|
12037
|
-
if ((a.endsWith('.book') || a.endsWith('.book')) && b.endsWith('.json')) {
|
|
12042
|
+
if ((a.endsWith('.book') || a.endsWith('.book.md')) && (b.endsWith('.bookc') || b.endsWith('.book.json'))) {
|
|
12038
12043
|
return 1;
|
|
12039
12044
|
}
|
|
12040
12045
|
return 0;
|
|
@@ -12051,7 +12056,7 @@ function createCollectionFromDirectory(rootPath, tools, options) {
|
|
|
12051
12056
|
case 1:
|
|
12052
12057
|
_f.trys.push([1, 8, , 9]);
|
|
12053
12058
|
pipeline = null;
|
|
12054
|
-
if (!(fileName.endsWith('.book') || fileName.endsWith('.book'))) return [3 /*break*/, 4];
|
|
12059
|
+
if (!(fileName.endsWith('.book') || fileName.endsWith('.book.md'))) return [3 /*break*/, 4];
|
|
12055
12060
|
_c = validatePipelineString;
|
|
12056
12061
|
return [4 /*yield*/, readFile(fileName, 'utf-8')];
|
|
12057
12062
|
case 2:
|
|
@@ -12064,7 +12069,7 @@ function createCollectionFromDirectory(rootPath, tools, options) {
|
|
|
12064
12069
|
pipeline = __assign(__assign({}, pipeline), { sourceFile: sourceFile });
|
|
12065
12070
|
return [3 /*break*/, 7];
|
|
12066
12071
|
case 4:
|
|
12067
|
-
if (!fileName.endsWith('.book.json')) return [3 /*break*/, 6];
|
|
12072
|
+
if (!(fileName.endsWith('.bookc') || fileName.endsWith('.book.json'))) return [3 /*break*/, 6];
|
|
12068
12073
|
_e = (_d = JSON).parse;
|
|
12069
12074
|
return [4 /*yield*/, readFile(fileName, 'utf-8')];
|
|
12070
12075
|
case 5:
|
|
@@ -12269,13 +12274,16 @@ function $initializeMakeCommand(program) {
|
|
|
12269
12274
|
var _this = this;
|
|
12270
12275
|
var makeCommand = program.command('make');
|
|
12271
12276
|
makeCommand.description(spaceTrim("\n Makes a new pipeline collection in given folder\n "));
|
|
12277
|
+
makeCommand.alias('compile');
|
|
12278
|
+
makeCommand.alias('prepare');
|
|
12279
|
+
makeCommand.alias('build');
|
|
12272
12280
|
// TODO: [🧅] DRY command arguments
|
|
12273
12281
|
makeCommand.argument('[path]',
|
|
12274
12282
|
// <- TODO: [🧟♂️] Unite path to promptbook collection argument
|
|
12275
12283
|
'Path to promptbook collection directory', DEFAULT_BOOKS_DIRNAME);
|
|
12276
12284
|
makeCommand.option('--project-name', "Name of the project for whom collection is", 'Untitled Promptbook project');
|
|
12277
12285
|
makeCommand.option('--root-url <url>', "Root URL of all pipelines to make", undefined);
|
|
12278
|
-
makeCommand.option('-f, --format <format>', spaceTrim("\n Output format of builded collection \"javascript\", \"typescript\" or \"json\"\n\n Note: You can use multiple formats separated by comma\n "), '
|
|
12286
|
+
makeCommand.option('-f, --format <format>', spaceTrim("\n Output format of builded collection \"bookc\", \"javascript\", \"typescript\" or \"json\"\n\n Note: You can use multiple formats separated by comma\n "), 'bookc' /* <- Note: [🏳🌈] */);
|
|
12279
12287
|
makeCommand.option('--no-validation', "Do not validate logic of pipelines in collection", true);
|
|
12280
12288
|
makeCommand.option('--validation', "Types of validations separated by comma (options \"logic\",\"imports\")", 'logic,imports');
|
|
12281
12289
|
makeCommand.option('-r, --reload', "Call LLM models even if same prompt with result is in the cache", false);
|
|
@@ -12285,7 +12293,7 @@ function $initializeMakeCommand(program) {
|
|
|
12285
12293
|
makeCommand.action(function (path, _a) {
|
|
12286
12294
|
var projectName = _a.projectName, rootUrl = _a.rootUrl, format = _a.format, functionName = _a.functionName, validation = _a.validation, isCacheReloaded = _a.reload, isVerbose = _a.verbose, output = _a.output;
|
|
12287
12295
|
return __awaiter(_this, void 0, void 0, function () {
|
|
12288
|
-
var formats, validations, prepareAndScrapeOptions, fs, llm, executables, tools, collection, pipelinesUrls, validations_1, validations_1_1, validation_1, pipelinesUrls_1, pipelinesUrls_1_1, pipelineUrl, pipeline, e_1_1, e_2_1, collectionJson, collectionJsonString, collectionJsonItems, saveFile;
|
|
12296
|
+
var formats, validations, prepareAndScrapeOptions, fs, llm, executables, tools, collection, pipelinesUrls, validations_1, validations_1_1, validation_1, pipelinesUrls_1, pipelinesUrls_1_1, pipelineUrl, pipeline, e_1_1, e_2_1, collectionJson, collectionJsonString, collectionJsonItems, saveFile, bookcBundle;
|
|
12289
12297
|
var _b, e_2, _c, e_1, _d;
|
|
12290
12298
|
var _this = this;
|
|
12291
12299
|
return __generator(this, function (_e) {
|
|
@@ -12421,7 +12429,7 @@ function $initializeMakeCommand(program) {
|
|
|
12421
12429
|
return spaceTrim(collectionJsonString.substring(1, collectionJsonString.length - 1));
|
|
12422
12430
|
})();
|
|
12423
12431
|
saveFile = function (extension, content) { return __awaiter(_this, void 0, void 0, function () {
|
|
12424
|
-
var filename;
|
|
12432
|
+
var filename, data;
|
|
12425
12433
|
return __generator(this, function (_a) {
|
|
12426
12434
|
switch (_a.label) {
|
|
12427
12435
|
case 0:
|
|
@@ -12434,36 +12442,55 @@ function $initializeMakeCommand(program) {
|
|
|
12434
12442
|
return [4 /*yield*/, mkdir(dirname(filename), { recursive: true })];
|
|
12435
12443
|
case 1:
|
|
12436
12444
|
_a.sent();
|
|
12445
|
+
if (!(typeof content === 'string')) return [3 /*break*/, 3];
|
|
12437
12446
|
return [4 /*yield*/, writeFile(filename, content, 'utf-8')];
|
|
12438
12447
|
case 2:
|
|
12439
12448
|
_a.sent();
|
|
12449
|
+
return [3 /*break*/, 6];
|
|
12450
|
+
case 3: return [4 /*yield*/, content.generateAsync({ type: 'nodebuffer', streamFiles: true })];
|
|
12451
|
+
case 4:
|
|
12452
|
+
data = _a.sent();
|
|
12453
|
+
return [4 /*yield*/, writeFile(filename, data)];
|
|
12454
|
+
case 5:
|
|
12455
|
+
_a.sent();
|
|
12456
|
+
_a.label = 6;
|
|
12457
|
+
case 6:
|
|
12440
12458
|
// Note: Log despite of verbose mode
|
|
12441
12459
|
console.info(colors.green("Made ".concat(filename.split('\\').join('/'))));
|
|
12442
12460
|
return [2 /*return*/];
|
|
12443
12461
|
}
|
|
12444
12462
|
});
|
|
12445
12463
|
}); };
|
|
12446
|
-
if (!formats.includes('
|
|
12447
|
-
formats = formats.filter(function (format) { return format !== '
|
|
12448
|
-
|
|
12464
|
+
if (!formats.includes('bookc')) return [3 /*break*/, 22];
|
|
12465
|
+
formats = formats.filter(function (format) { return format !== 'bookc'; });
|
|
12466
|
+
bookcBundle = new JSZip();
|
|
12467
|
+
bookcBundle.file('index.book.json', collectionJsonString);
|
|
12468
|
+
return [4 /*yield*/, saveFile('bookc', bookcBundle)];
|
|
12449
12469
|
case 21:
|
|
12450
12470
|
_e.sent();
|
|
12451
12471
|
_e.label = 22;
|
|
12452
12472
|
case 22:
|
|
12453
|
-
if (!
|
|
12454
|
-
formats = formats.filter(function (format) { return format !== '
|
|
12455
|
-
return [4 /*yield*/, saveFile('
|
|
12473
|
+
if (!formats.includes('json')) return [3 /*break*/, 24];
|
|
12474
|
+
formats = formats.filter(function (format) { return format !== 'json'; });
|
|
12475
|
+
return [4 /*yield*/, saveFile('json', collectionJsonString)];
|
|
12456
12476
|
case 23:
|
|
12457
|
-
|
|
12477
|
+
_e.sent();
|
|
12458
12478
|
_e.label = 24;
|
|
12459
12479
|
case 24:
|
|
12460
|
-
if (!(formats.includes('
|
|
12461
|
-
formats = formats.filter(function (format) { return format !== '
|
|
12462
|
-
return [4 /*yield*/, saveFile('
|
|
12480
|
+
if (!(formats.includes('javascript') || formats.includes('js'))) return [3 /*break*/, 26];
|
|
12481
|
+
formats = formats.filter(function (format) { return format !== 'javascript' && format !== 'js'; });
|
|
12482
|
+
return [4 /*yield*/, saveFile('js', spaceTrim(function (block) { return "\n // ".concat(block(GENERATOR_WARNING_BY_PROMPTBOOK_CLI), "\n\n import { createCollectionFromJson } from '@promptbook/core';\n\n /**\n * Pipeline collection for ").concat(projectName, "\n *\n * ").concat(block(GENERATOR_WARNING_BY_PROMPTBOOK_CLI), "\n *\n * @generated\n * @private internal cache for `").concat(functionName, "`\n */\n let pipelineCollection = null;\n\n\n /**\n * Get pipeline collection for ").concat(projectName, "\n *\n * ").concat(block(GENERATOR_WARNING_BY_PROMPTBOOK_CLI), "\n *\n * @generated\n * @returns {PipelineCollection} Library of promptbooks for ").concat(projectName, "\n */\n export function ").concat(functionName, "(){\n if(pipelineCollection===null){\n pipelineCollection = createCollectionFromJson(\n ").concat(block(collectionJsonItems), "\n );\n }\n\n return pipelineCollection;\n }\n "); }))];
|
|
12463
12483
|
case 25:
|
|
12464
|
-
_e.sent();
|
|
12484
|
+
(_e.sent()) + '\n';
|
|
12465
12485
|
_e.label = 26;
|
|
12466
12486
|
case 26:
|
|
12487
|
+
if (!(formats.includes('typescript') || formats.includes('ts'))) return [3 /*break*/, 28];
|
|
12488
|
+
formats = formats.filter(function (format) { return format !== 'typescript' && format !== 'ts'; });
|
|
12489
|
+
return [4 /*yield*/, saveFile('ts', spaceTrim(function (block) { return "\n // ".concat(block(GENERATOR_WARNING_BY_PROMPTBOOK_CLI), "\n\n import { createCollectionFromJson } from '@promptbook/core';\n import type { PipelineCollection } from '@promptbook/types';\n\n /**\n * Pipeline collection for ").concat(projectName, "\n *\n * ").concat(block(GENERATOR_WARNING_BY_PROMPTBOOK_CLI), "\n *\n * @private internal cache for `").concat(functionName, "`\n * @generated\n */\n let pipelineCollection: null | PipelineCollection = null;\n\n\n /**\n * Get pipeline collection for ").concat(projectName, "\n *\n * ").concat(block(GENERATOR_WARNING_BY_PROMPTBOOK_CLI), "\n *\n * @generated\n * @returns {PipelineCollection} Library of promptbooks for ").concat(projectName, "\n */\n export function ").concat(functionName, "(): PipelineCollection{\n if(pipelineCollection===null){\n\n // TODO: !!6 Use book string literal notation\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n pipelineCollection = (createCollectionFromJson as (..._: any) => PipelineCollection)(\n ").concat(block(collectionJsonItems), "\n );\n }\n\n return pipelineCollection;\n }\n "); }) + '\n')];
|
|
12490
|
+
case 27:
|
|
12491
|
+
_e.sent();
|
|
12492
|
+
_e.label = 28;
|
|
12493
|
+
case 28:
|
|
12467
12494
|
if (formats.length > 0) {
|
|
12468
12495
|
console.warn(colors.yellow("Format ".concat(formats.join(' and '), " is not supported")));
|
|
12469
12496
|
}
|
|
@@ -13266,6 +13293,7 @@ function $initializeRunCommand(program) {
|
|
|
13266
13293
|
var _this = this;
|
|
13267
13294
|
var runCommand = program.command('run', { isDefault: true });
|
|
13268
13295
|
runCommand.description(spaceTrim("\n Runs a pipeline\n "));
|
|
13296
|
+
runCommand.alias('execute');
|
|
13269
13297
|
// TODO: [🧅] DRY command arguments
|
|
13270
13298
|
runCommand.argument('[pipelineSource]', 'Path to book file OR URL to book file, if not provided it will be asked');
|
|
13271
13299
|
runCommand.option('-r, --reload', "Call LLM models even if same prompt with result is in the cache", false);
|
|
@@ -13281,6 +13309,10 @@ function $initializeRunCommand(program) {
|
|
|
13281
13309
|
switch (_m.label) {
|
|
13282
13310
|
case 0:
|
|
13283
13311
|
isCacheReloaded = options.reload, isInteractive = options.interactive, isFormfactorUsed = options.formfactor, json = options.json, isVerbose = options.verbose, saveReport = options.saveReport;
|
|
13312
|
+
if (pipelineSource.includes('-') && normalizeToKebabCase(pipelineSource) === pipelineSource) {
|
|
13313
|
+
console.error(colors.red("\"\"".concat(pipelineSource, "\" is not a valid command or book. See 'ptbk --help'.")));
|
|
13314
|
+
return [2 /*return*/, process.exit(1)];
|
|
13315
|
+
}
|
|
13284
13316
|
if (saveReport && !saveReport.endsWith('.json') && !saveReport.endsWith('.md')) {
|
|
13285
13317
|
console.error(colors.red("Report file must be .json or .md"));
|
|
13286
13318
|
return [2 /*return*/, process.exit(1)];
|
|
@@ -14072,6 +14104,7 @@ function $initializeStartServerCommand(program) {
|
|
|
14072
14104
|
startServerCommand.option('-r, --reload', "Call LLM models even if same prompt with result is in the cache", false);
|
|
14073
14105
|
startServerCommand.option('-v, --verbose', "Is output verbose", false);
|
|
14074
14106
|
startServerCommand.description(spaceTrim("\n Starts a remote server to execute books\n "));
|
|
14107
|
+
startServerCommand.alias('server');
|
|
14075
14108
|
startServerCommand.action(function (path, _a) {
|
|
14076
14109
|
var portRaw = _a.port, rawUrl = _a.url, isAnonymousModeAllowed = _a.allowAnonymous, isCacheReloaded = _a.reload, isVerbose = _a.verbose;
|
|
14077
14110
|
return __awaiter(_this, void 0, void 0, function () {
|
|
@@ -14169,7 +14202,7 @@ function $initializeStartServerCommand(program) {
|
|
|
14169
14202
|
function $initializeTestCommand(program) {
|
|
14170
14203
|
var _this = this;
|
|
14171
14204
|
var testCommand = program.command('test');
|
|
14172
|
-
testCommand.description(spaceTrim("\n Iterates over `.book.md` and `.
|
|
14205
|
+
testCommand.description(spaceTrim("\n Iterates over `.book.md` and `.bookc` and checks if they are parsable and logically valid\n "));
|
|
14173
14206
|
testCommand.argument('<filesGlob>',
|
|
14174
14207
|
// <- TODO: [🧟♂️] Unite path to promptbook collection argument
|
|
14175
14208
|
'Pipelines to test as glob pattern');
|
|
@@ -14234,7 +14267,7 @@ function $initializeTestCommand(program) {
|
|
|
14234
14267
|
}
|
|
14235
14268
|
_g.label = 10;
|
|
14236
14269
|
case 10:
|
|
14237
|
-
if (!filename.endsWith('.
|
|
14270
|
+
if (!filename.endsWith('.bookc')) return [3 /*break*/, 12];
|
|
14238
14271
|
_d = (_c = JSON).parse;
|
|
14239
14272
|
return [4 /*yield*/, readFile(filename, 'utf-8')];
|
|
14240
14273
|
case 11:
|