@promptbook/cli 0.78.3 → 0.79.0

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.
@@ -1,4 +1,4 @@
1
- import type { WritableDeep } from 'type-fest';
1
+ import type { SetOptional, WritableDeep } from 'type-fest';
2
2
  import type { PipelineJson } from '../../../pipeline/PipelineJson/PipelineJson';
3
3
  import type { TaskJson } from '../../../pipeline/PipelineJson/TaskJson';
4
4
  import type { string_markdown_text } from '../../../types/typeAliases';
@@ -140,7 +140,7 @@ export type $TaskJson = {
140
140
  *
141
141
  * @private internal helper for command parsers
142
142
  */
143
- export type $PipelineJson = WritableDeep<PipelineJson>;
143
+ export type $PipelineJson = WritableDeep<SetOptional<PipelineJson, 'formfactorName'>>;
144
144
  /**
145
145
  * @@@
146
146
  */
@@ -8,7 +8,12 @@ export declare const GeneratorFormfactorDefinition: {
8
8
  readonly description: "@@@";
9
9
  readonly documentationUrl: "https://github.com/webgptorg/promptbook/discussions/184";
10
10
  readonly pipelineInterface: {
11
- readonly inputParameters: readonly [];
11
+ readonly inputParameters: readonly [{
12
+ readonly name: "nonce";
13
+ readonly description: "Just to prevent GENERATOR to be set as implicit formfactor";
14
+ readonly isInput: true;
15
+ readonly isOutput: false;
16
+ }];
12
17
  readonly outputParameters: readonly [];
13
18
  };
14
19
  };
@@ -96,7 +96,12 @@ export declare const FORMFACTOR_DEFINITIONS: readonly [{
96
96
  readonly description: "@@@";
97
97
  readonly documentationUrl: "https://github.com/webgptorg/promptbook/discussions/177";
98
98
  readonly pipelineInterface: {
99
- readonly inputParameters: readonly [];
99
+ readonly inputParameters: readonly [{
100
+ readonly name: "nonce";
101
+ readonly description: "Just to prevent EXPERIMENTAL_MATCHER to be set as implicit formfactor";
102
+ readonly isInput: true;
103
+ readonly isOutput: false;
104
+ }];
100
105
  readonly outputParameters: readonly [];
101
106
  };
102
107
  }, {
@@ -104,7 +109,12 @@ export declare const FORMFACTOR_DEFINITIONS: readonly [{
104
109
  readonly description: "@@@";
105
110
  readonly documentationUrl: "https://github.com/webgptorg/promptbook/discussions/184";
106
111
  readonly pipelineInterface: {
107
- readonly inputParameters: readonly [];
112
+ readonly inputParameters: readonly [{
113
+ readonly name: "nonce";
114
+ readonly description: "Just to prevent GENERATOR to be set as implicit formfactor";
115
+ readonly isInput: true;
116
+ readonly isOutput: false;
117
+ }];
108
118
  readonly outputParameters: readonly [];
109
119
  };
110
120
  }];
@@ -8,7 +8,12 @@ export declare const MatcherFormfactorDefinition: {
8
8
  readonly description: "@@@";
9
9
  readonly documentationUrl: "https://github.com/webgptorg/promptbook/discussions/177";
10
10
  readonly pipelineInterface: {
11
- readonly inputParameters: readonly [];
11
+ readonly inputParameters: readonly [{
12
+ readonly name: "nonce";
13
+ readonly description: "Just to prevent EXPERIMENTAL_MATCHER to be set as implicit formfactor";
14
+ readonly isInput: true;
15
+ readonly isOutput: false;
16
+ }];
12
17
  readonly outputParameters: readonly [];
13
18
  };
14
19
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@promptbook/cli",
3
- "version": "0.78.3",
3
+ "version": "0.79.0",
4
4
  "description": "It's time for a paradigm shift. The future of software in plain English, French or Latin",
5
5
  "--note-0": " <- [🐊]",
6
6
  "private": false,
package/umd/index.umd.js CHANGED
@@ -49,7 +49,7 @@
49
49
  *
50
50
  * @see https://github.com/webgptorg/promptbook
51
51
  */
52
- var PROMPTBOOK_ENGINE_VERSION = '0.78.2';
52
+ var PROMPTBOOK_ENGINE_VERSION = '0.78.4';
53
53
  /**
54
54
  * TODO: string_promptbook_version should be constrained to the all versions of Promptbook engine
55
55
  * Note: [💞] Ignore a discrepancy between file name and entity name
@@ -1546,6 +1546,9 @@
1546
1546
  */
1547
1547
  function $deepFreeze(objectValue) {
1548
1548
  var e_1, _a;
1549
+ if (Array.isArray(objectValue)) {
1550
+ return Object.freeze(objectValue.map(function (item) { return $deepFreeze(item); }));
1551
+ }
1549
1552
  var propertyNames = Object.getOwnPropertyNames(objectValue);
1550
1553
  try {
1551
1554
  for (var propertyNames_1 = __values(propertyNames), propertyNames_1_1 = propertyNames_1.next(); !propertyNames_1_1.done; propertyNames_1_1 = propertyNames_1.next()) {
@@ -6545,6 +6548,133 @@
6545
6548
  * @see https://docs.anthropic.com/en/docs/test-and-evaluate/strengthen-guardrails/increase-consistency#specify-the-desired-output-format
6546
6549
  */
6547
6550
 
6551
+ /**
6552
+ * @@@
6553
+ *
6554
+ * @deprecated https://github.com/webgptorg/promptbook/pull/186
6555
+ * @see https://github.com/webgptorg/promptbook/discussions/171
6556
+ *
6557
+ * @public exported from `@promptbook/core`
6558
+ */
6559
+ function getPipelineInterface(pipeline) {
6560
+ var e_1, _a, e_2, _b;
6561
+ var pipelineInterface = {
6562
+ inputParameters: [],
6563
+ outputParameters: [],
6564
+ };
6565
+ try {
6566
+ for (var _c = __values(pipeline.parameters), _d = _c.next(); !_d.done; _d = _c.next()) {
6567
+ var parameter = _d.value;
6568
+ var isInput = parameter.isInput, isOutput = parameter.isOutput;
6569
+ if (isInput) {
6570
+ pipelineInterface.inputParameters.push(deepClone(parameter));
6571
+ }
6572
+ if (isOutput) {
6573
+ pipelineInterface.outputParameters.push(deepClone(parameter));
6574
+ }
6575
+ }
6576
+ }
6577
+ catch (e_1_1) { e_1 = { error: e_1_1 }; }
6578
+ finally {
6579
+ try {
6580
+ if (_d && !_d.done && (_a = _c.return)) _a.call(_c);
6581
+ }
6582
+ finally { if (e_1) throw e_1.error; }
6583
+ }
6584
+ try {
6585
+ for (var _e = __values(['inputParameters', 'outputParameters']), _f = _e.next(); !_f.done; _f = _e.next()) {
6586
+ var key = _f.value;
6587
+ pipelineInterface[key].sort(function (_a, _b) {
6588
+ var name1 = _a.name;
6589
+ var name2 = _b.name;
6590
+ return name1.localeCompare(name2);
6591
+ });
6592
+ }
6593
+ }
6594
+ catch (e_2_1) { e_2 = { error: e_2_1 }; }
6595
+ finally {
6596
+ try {
6597
+ if (_f && !_f.done && (_b = _e.return)) _b.call(_e);
6598
+ }
6599
+ finally { if (e_2) throw e_2.error; }
6600
+ }
6601
+ return $deepFreeze(pipelineInterface);
6602
+ }
6603
+
6604
+ /**
6605
+ * @@@
6606
+ *
6607
+ * @deprecated https://github.com/webgptorg/promptbook/pull/186
6608
+ * @see https://github.com/webgptorg/promptbook/discussions/171
6609
+ *
6610
+ * @public exported from `@promptbook/core`
6611
+ */
6612
+ function isPipelineInterfacesEqual(pipelineInterface1, pipelineInterface2) {
6613
+ var e_1, _a, e_2, _b;
6614
+ try {
6615
+ for (var _c = __values(['inputParameters', 'outputParameters']), _d = _c.next(); !_d.done; _d = _c.next()) {
6616
+ var whichParameters = _d.value;
6617
+ var parameters1 = pipelineInterface1[whichParameters]; // <- Note: `isPipelineInterfacesEqual` is just temporary solution, no need to fix this
6618
+ var parameters2 = pipelineInterface2[whichParameters];
6619
+ if (parameters1.length !== parameters2.length) {
6620
+ return false;
6621
+ }
6622
+ var _loop_1 = function (parameter) {
6623
+ var matchingParameter = parameters2.find(function (_a) {
6624
+ var name = _a.name;
6625
+ return name === parameter.name;
6626
+ });
6627
+ if (!matchingParameter) {
6628
+ return { value: false };
6629
+ }
6630
+ // Note: Do not compare description, it is not relevant for compatibility
6631
+ if (matchingParameter.isInput !== parameter.isInput) {
6632
+ return { value: false };
6633
+ }
6634
+ if (matchingParameter.isOutput !== parameter.isOutput) {
6635
+ return { value: false };
6636
+ }
6637
+ };
6638
+ try {
6639
+ for (var parameters1_1 = (e_2 = void 0, __values(parameters1)), parameters1_1_1 = parameters1_1.next(); !parameters1_1_1.done; parameters1_1_1 = parameters1_1.next()) {
6640
+ var parameter = parameters1_1_1.value;
6641
+ var state_1 = _loop_1(parameter);
6642
+ if (typeof state_1 === "object")
6643
+ return state_1.value;
6644
+ }
6645
+ }
6646
+ catch (e_2_1) { e_2 = { error: e_2_1 }; }
6647
+ finally {
6648
+ try {
6649
+ if (parameters1_1_1 && !parameters1_1_1.done && (_b = parameters1_1.return)) _b.call(parameters1_1);
6650
+ }
6651
+ finally { if (e_2) throw e_2.error; }
6652
+ }
6653
+ }
6654
+ }
6655
+ catch (e_1_1) { e_1 = { error: e_1_1 }; }
6656
+ finally {
6657
+ try {
6658
+ if (_d && !_d.done && (_a = _c.return)) _a.call(_c);
6659
+ }
6660
+ finally { if (e_1) throw e_1.error; }
6661
+ }
6662
+ return true;
6663
+ }
6664
+
6665
+ /**
6666
+ * @@@
6667
+ *
6668
+ * @deprecated https://github.com/webgptorg/promptbook/pull/186
6669
+ * @see https://github.com/webgptorg/promptbook/discussions/171
6670
+ *
6671
+ * @public exported from `@promptbook/core`
6672
+ */
6673
+ function isPipelineImplementingInterface(options) {
6674
+ var pipeline = options.pipeline, pipelineInterface = options.pipelineInterface;
6675
+ return isPipelineInterfacesEqual(getPipelineInterface(pipeline), pipelineInterface);
6676
+ }
6677
+
6548
6678
  /**
6549
6679
  * All available task types
6550
6680
  *
@@ -7688,7 +7818,13 @@
7688
7818
  documentationUrl: "https://github.com/webgptorg/promptbook/discussions/184",
7689
7819
  pipelineInterface: {
7690
7820
  inputParameters: [
7691
- /* @@@ */
7821
+ /* @@@ */
7822
+ {
7823
+ name: 'nonce',
7824
+ description: 'Just to prevent GENERATOR to be set as implicit formfactor',
7825
+ isInput: true,
7826
+ isOutput: false,
7827
+ },
7692
7828
  ],
7693
7829
  outputParameters: [
7694
7830
  /* @@@ */
@@ -7734,7 +7870,13 @@
7734
7870
  documentationUrl: "https://github.com/webgptorg/promptbook/discussions/177",
7735
7871
  pipelineInterface: {
7736
7872
  inputParameters: [
7737
- /* @@@ */
7873
+ /* @@@ */
7874
+ {
7875
+ name: 'nonce',
7876
+ description: 'Just to prevent EXPERIMENTAL_MATCHER to be set as implicit formfactor',
7877
+ isInput: true,
7878
+ isOutput: false,
7879
+ },
7738
7880
  ],
7739
7881
  outputParameters: [
7740
7882
  /* @@@ */
@@ -7883,6 +8025,9 @@
7883
8025
  * Note: `$` is used to indicate that this function mutates given `pipelineJson`
7884
8026
  */
7885
8027
  $applyToPipelineJson: function (command, $pipelineJson) {
8028
+ if ($pipelineJson.formfactorName !== undefined && $pipelineJson.formfactorName !== command.formfactorName) {
8029
+ throw new ParseError(spaceTrim__default["default"]("\n Redefinition of `FORMFACTOR` in the pipeline head\n\n You have used:\n 1) FORMFACTOR `".concat($pipelineJson.formfactorName, "`\n 2) FORMFACTOR `").concat(command.formfactorName, "`\n ")));
8030
+ }
7886
8031
  $pipelineJson.formfactorName = command.formfactorName;
7887
8032
  },
7888
8033
  /**
@@ -8070,7 +8215,7 @@
8070
8215
  // <- TODO: [🚎][💩] Some better way how to get warnings from pipeline parsing / logic
8071
8216
  }
8072
8217
  else {
8073
- throw new ParseError(spaceTrim__default["default"]("\n Redefinition of MODEL `".concat(command.key, "` in the pipeline head\n\n You have used:\n - MODEL ").concat(command.key, " ").concat($pipelineJson.defaultModelRequirements[command.key], "\n - MODEL ").concat(command.key, " ").concat(command.value, "\n ")));
8218
+ throw new ParseError(spaceTrim__default["default"]("\n Redefinition of `MODEL ".concat(command.key, "` in the pipeline head\n\n You have used:\n 1) `MODEL ").concat(command.key, " ").concat($pipelineJson.defaultModelRequirements[command.key], "`\n 2) `MODEL ").concat(command.key, " ").concat(command.value, "`\n ")));
8074
8219
  }
8075
8220
  }
8076
8221
  $pipelineJson.defaultModelRequirements[command.key] = command.value;
@@ -9139,20 +9284,15 @@
9139
9284
  * @public exported from `@promptbook/core`
9140
9285
  */
9141
9286
  function pipelineStringToJsonSync(pipelineString) {
9142
- var e_1, _a, e_2, _b, e_3, _c, e_4, _d, e_5, _e;
9287
+ var e_1, _a, e_2, _b, e_3, _c, e_4, _d, e_5, _e, e_6, _f;
9143
9288
  var $pipelineJson = {
9144
- title: undefined /* <- Note: [🍙] Putting here placeholder to keep `title` on top at final JSON */,
9145
- pipelineUrl: undefined /* <- Note: Putting here placeholder to keep `pipelineUrl` on top at final JSON */,
9146
- bookVersion: undefined /* <- Note: By default no explicit version */,
9147
- description: undefined /* <- Note: [🍙] Putting here placeholder to keep `description` on top at final JSON */,
9148
- formfactorName: 'GENERIC',
9289
+ title: DEFAULT_TITLE,
9149
9290
  parameters: [],
9150
9291
  tasks: [],
9151
9292
  knowledgeSources: [],
9152
9293
  knowledgePieces: [],
9153
9294
  personas: [],
9154
9295
  preparations: [],
9155
- // <- TODO: [🍙] Some standard order of properties
9156
9296
  };
9157
9297
  function getPipelineIdentification() {
9158
9298
  // Note: This is a 😐 implementation of [🚞]
@@ -9168,7 +9308,7 @@
9168
9308
  // =============================================================
9169
9309
  // Note: 1️⃣ Parsing of the markdown into object
9170
9310
  if (pipelineString.startsWith('#!')) {
9171
- var _f = __read(pipelineString.split('\n')), shebangLine_1 = _f[0], restLines = _f.slice(1);
9311
+ var _g = __read(pipelineString.split('\n')), shebangLine_1 = _g[0], restLines = _g.slice(1);
9172
9312
  if (!(shebangLine_1 || '').includes('ptbk')) {
9173
9313
  throw new ParseError(spaceTrim.spaceTrim(function (block) { return "\n It seems that you try to parse a book file which has non-standard shebang line for book files:\n Shebang line must contain 'ptbk'\n\n You have:\n ".concat(block(shebangLine_1 || '(empty line)'), "\n\n It should look like this:\n #!/usr/bin/env ptbk\n\n ").concat(block(getPipelineIdentification()), "\n "); }));
9174
9314
  }
@@ -9178,7 +9318,7 @@
9178
9318
  pipelineString = flattenMarkdown(pipelineString) /* <- Note: [🥞] */;
9179
9319
  pipelineString = pipelineString.replaceAll(/`\{(?<parameterName>[a-z0-9_]+)\}`/gi, '{$<parameterName>}');
9180
9320
  pipelineString = pipelineString.replaceAll(/`->\s+\{(?<parameterName>[a-z0-9_]+)\}`/gi, '-> {$<parameterName>}');
9181
- var _g = __read(splitMarkdownIntoSections(pipelineString).map(parseMarkdownSection)), pipelineHead = _g[0], pipelineSections = _g.slice(1); /* <- Note: [🥞] */
9321
+ var _h = __read(splitMarkdownIntoSections(pipelineString).map(parseMarkdownSection)), pipelineHead = _h[0], pipelineSections = _h.slice(1); /* <- Note: [🥞] */
9182
9322
  if (pipelineHead === undefined) {
9183
9323
  throw new UnexpectedError(spaceTrim.spaceTrim(function (block) { return "\n Pipeline head is not defined\n\n ".concat(block(getPipelineIdentification()), "\n\n This should never happen, because the pipeline already flattened\n "); }));
9184
9324
  }
@@ -9300,10 +9440,10 @@
9300
9440
  return nameWithSuffix;
9301
9441
  };
9302
9442
  var _loop_2 = function (section) {
9303
- var e_6, _m, e_7, _o;
9443
+ var e_7, _o, e_8, _p;
9304
9444
  // TODO: Parse section's description (the content out of the codeblock and lists)
9305
9445
  var listItems_2 = extractAllListItemsFromMarkdown(section.content);
9306
- var _p = extractOneBlockFromMarkdown(section.content), language = _p.language, content = _p.content;
9446
+ var _q = extractOneBlockFromMarkdown(section.content), language = _q.language, content = _q.content;
9307
9447
  // TODO: [🎾][1] DRY description
9308
9448
  var description_1 = section.content;
9309
9449
  // Note: Remove codeblocks - TODO: [🎾]
@@ -9367,17 +9507,17 @@
9367
9507
  };
9368
9508
  try {
9369
9509
  // TODO [♓️] List commands and before apply order them to achieve order-agnostic commands
9370
- for (var commands_1 = (e_6 = void 0, __values(commands)), commands_1_1 = commands_1.next(); !commands_1_1.done; commands_1_1 = commands_1.next()) {
9371
- var _q = commands_1_1.value, listItem = _q.listItem, command = _q.command;
9510
+ for (var commands_1 = (e_7 = void 0, __values(commands)), commands_1_1 = commands_1.next(); !commands_1_1.done; commands_1_1 = commands_1.next()) {
9511
+ var _r = commands_1_1.value, listItem = _r.listItem, command = _r.command;
9372
9512
  _loop_4(listItem, command);
9373
9513
  }
9374
9514
  }
9375
- catch (e_6_1) { e_6 = { error: e_6_1 }; }
9515
+ catch (e_7_1) { e_7 = { error: e_7_1 }; }
9376
9516
  finally {
9377
9517
  try {
9378
- if (commands_1_1 && !commands_1_1.done && (_m = commands_1.return)) _m.call(commands_1);
9518
+ if (commands_1_1 && !commands_1_1.done && (_o = commands_1.return)) _o.call(commands_1);
9379
9519
  }
9380
- finally { if (e_6) throw e_6.error; }
9520
+ finally { if (e_7) throw e_7.error; }
9381
9521
  }
9382
9522
  // TODO: [🍧] Should be done in SECTION command
9383
9523
  if ($taskJson.taskType === 'SCRIPT_TASK') {
@@ -9391,8 +9531,8 @@
9391
9531
  }
9392
9532
  $taskJson.dependentParameterNames = Array.from(extractParameterNamesFromTask($taskJson));
9393
9533
  try {
9394
- for (var _r = (e_7 = void 0, __values($taskJson.dependentParameterNames)), _s = _r.next(); !_s.done; _s = _r.next()) {
9395
- var parameterName = _s.value;
9534
+ for (var _s = (e_8 = void 0, __values($taskJson.dependentParameterNames)), _t = _s.next(); !_t.done; _t = _s.next()) {
9535
+ var parameterName = _t.value;
9396
9536
  // TODO: [🧠] This definition should be made first in the task
9397
9537
  defineParam({
9398
9538
  parameterName: parameterName,
@@ -9403,12 +9543,12 @@
9403
9543
  });
9404
9544
  }
9405
9545
  }
9406
- catch (e_7_1) { e_7 = { error: e_7_1 }; }
9546
+ catch (e_8_1) { e_8 = { error: e_8_1 }; }
9407
9547
  finally {
9408
9548
  try {
9409
- if (_s && !_s.done && (_o = _r.return)) _o.call(_r);
9549
+ if (_t && !_t.done && (_p = _s.return)) _p.call(_s);
9410
9550
  }
9411
- finally { if (e_7) throw e_7.error; }
9551
+ finally { if (e_8) throw e_8.error; }
9412
9552
  }
9413
9553
  /*
9414
9554
  // TODO: [🍧] This should be checked in `MODEL` command + better error message
@@ -9457,18 +9597,22 @@
9457
9597
  var isThisParameterResulting = $pipelineJson.tasks.some(function (task) { return task.resultingParameterName === parameter.name; });
9458
9598
  if (!isThisParameterResulting) {
9459
9599
  parameter.isInput = true;
9600
+ // <- TODO: [💔] Why this is making typescript error in vscode but not in cli
9601
+ // > Type 'true' is not assignable to type 'false'.ts(2322)
9602
+ // > (property) isInput: false
9603
+ // > The parameter is input of the pipeline The parameter is NOT input of the pipeline
9460
9604
  }
9461
9605
  };
9462
9606
  try {
9463
- for (var _h = __values($pipelineJson.parameters), _j = _h.next(); !_j.done; _j = _h.next()) {
9464
- var parameter = _j.value;
9607
+ for (var _j = __values($pipelineJson.parameters), _k = _j.next(); !_k.done; _k = _j.next()) {
9608
+ var parameter = _k.value;
9465
9609
  _loop_3(parameter);
9466
9610
  }
9467
9611
  }
9468
9612
  catch (e_4_1) { e_4 = { error: e_4_1 }; }
9469
9613
  finally {
9470
9614
  try {
9471
- if (_j && !_j.done && (_d = _h.return)) _d.call(_h);
9615
+ if (_k && !_k.done && (_d = _j.return)) _d.call(_j);
9472
9616
  }
9473
9617
  finally { if (e_4) throw e_4.error; }
9474
9618
  }
@@ -9477,17 +9621,18 @@
9477
9621
  // Note: 7️⃣ Mark all non-INPUT parameters as OUTPUT if any OUTPUT is not set
9478
9622
  if ($pipelineJson.parameters.every(function (parameter) { return !parameter.isOutput; })) {
9479
9623
  try {
9480
- for (var _k = __values($pipelineJson.parameters), _l = _k.next(); !_l.done; _l = _k.next()) {
9481
- var parameter = _l.value;
9624
+ for (var _l = __values($pipelineJson.parameters), _m = _l.next(); !_m.done; _m = _l.next()) {
9625
+ var parameter = _m.value;
9482
9626
  if (!parameter.isInput) {
9483
9627
  parameter.isOutput = true;
9628
+ // <- TODO: [💔]
9484
9629
  }
9485
9630
  }
9486
9631
  }
9487
9632
  catch (e_5_1) { e_5 = { error: e_5_1 }; }
9488
9633
  finally {
9489
9634
  try {
9490
- if (_l && !_l.done && (_e = _k.return)) _e.call(_k);
9635
+ if (_m && !_m.done && (_e = _l.return)) _e.call(_l);
9491
9636
  }
9492
9637
  finally { if (e_5) throw e_5.error; }
9493
9638
  }
@@ -9495,7 +9640,7 @@
9495
9640
  // =============================================================
9496
9641
  // Note: 8️⃣ Cleanup of undefined values
9497
9642
  $pipelineJson.tasks.forEach(function (tasks) {
9498
- var e_8, _a;
9643
+ var e_9, _a;
9499
9644
  try {
9500
9645
  for (var _b = __values(Object.entries(tasks)), _c = _b.next(); !_c.done; _c = _b.next()) {
9501
9646
  var _d = __read(_c.value, 2), key = _d[0], value = _d[1];
@@ -9504,16 +9649,16 @@
9504
9649
  }
9505
9650
  }
9506
9651
  }
9507
- catch (e_8_1) { e_8 = { error: e_8_1 }; }
9652
+ catch (e_9_1) { e_9 = { error: e_9_1 }; }
9508
9653
  finally {
9509
9654
  try {
9510
9655
  if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
9511
9656
  }
9512
- finally { if (e_8) throw e_8.error; }
9657
+ finally { if (e_9) throw e_9.error; }
9513
9658
  }
9514
9659
  });
9515
9660
  $pipelineJson.parameters.forEach(function (parameter) {
9516
- var e_9, _a;
9661
+ var e_10, _a;
9517
9662
  try {
9518
9663
  for (var _b = __values(Object.entries(parameter)), _c = _b.next(); !_c.done; _c = _b.next()) {
9519
9664
  var _d = __read(_c.value, 2), key = _d[0], value = _d[1];
@@ -9522,17 +9667,61 @@
9522
9667
  }
9523
9668
  }
9524
9669
  }
9525
- catch (e_9_1) { e_9 = { error: e_9_1 }; }
9670
+ catch (e_10_1) { e_10 = { error: e_10_1 }; }
9526
9671
  finally {
9527
9672
  try {
9528
9673
  if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
9529
9674
  }
9530
- finally { if (e_9) throw e_9.error; }
9675
+ finally { if (e_10) throw e_10.error; }
9531
9676
  }
9532
9677
  });
9678
+ try {
9679
+ // =============================================================
9680
+ // Note: 9️⃣ Implicit and default formfactor
9681
+ for (var FORMFACTOR_DEFINITIONS_1 = __values(FORMFACTOR_DEFINITIONS), FORMFACTOR_DEFINITIONS_1_1 = FORMFACTOR_DEFINITIONS_1.next(); !FORMFACTOR_DEFINITIONS_1_1.done; FORMFACTOR_DEFINITIONS_1_1 = FORMFACTOR_DEFINITIONS_1.next()) {
9682
+ var formfactorDefinition = FORMFACTOR_DEFINITIONS_1_1.value;
9683
+ // <- Note: [♓️][💩] This is the order of the formfactors, make some explicit priority
9684
+ var name_2 = formfactorDefinition.name, pipelineInterface = formfactorDefinition.pipelineInterface;
9685
+ // Note: Skip GENERIC formfactor, it will be used as a fallback if no other formfactor is compatible
9686
+ if (name_2 === 'GENERIC') {
9687
+ continue;
9688
+ }
9689
+ var isCompatible = isPipelineImplementingInterface({
9690
+ pipeline: __assign({ formfactorName: name_2 }, $pipelineJson),
9691
+ pipelineInterface: pipelineInterface,
9692
+ });
9693
+ /*/
9694
+ console.log({
9695
+ subject: `${$pipelineJson.title} implements ${name}`,
9696
+ pipelineTitle: $pipelineJson.title,
9697
+ formfactorName: name,
9698
+ isCompatible,
9699
+ formfactorInterface: pipelineInterface,
9700
+ pipelineInterface: getPipelineInterface($pipelineJson as PipelineJson),
9701
+ });
9702
+ /**/
9703
+ if (isCompatible) {
9704
+ $pipelineJson.formfactorName = name_2;
9705
+ break;
9706
+ }
9707
+ }
9708
+ }
9709
+ catch (e_6_1) { e_6 = { error: e_6_1 }; }
9710
+ finally {
9711
+ try {
9712
+ if (FORMFACTOR_DEFINITIONS_1_1 && !FORMFACTOR_DEFINITIONS_1_1.done && (_f = FORMFACTOR_DEFINITIONS_1.return)) _f.call(FORMFACTOR_DEFINITIONS_1);
9713
+ }
9714
+ finally { if (e_6) throw e_6.error; }
9715
+ }
9716
+ // Note: [🔆] If formfactor is still not set, set it to 'GENERIC'
9717
+ if ($pipelineJson.formfactorName === undefined) {
9718
+ $pipelineJson.formfactorName = 'GENERIC';
9719
+ }
9533
9720
  // =============================================================
9534
9721
  // TODO: [🍙] Maybe do reorder of `$pipelineJson` here
9535
- return $asDeeplyFrozenSerializableJson('pipelineJson', $pipelineJson);
9722
+ return $asDeeplyFrozenSerializableJson('pipelineJson', __assign({ title: DEFAULT_TITLE, pipelineUrl: undefined, bookVersion: undefined, description: undefined, formfactorName: 'GENERIC',
9723
+ // <- Note: [🔆] Setting `formfactorName` is redundant to satisfy the typescript
9724
+ parameters: [], tasks: [], knowledgeSources: [], knowledgePieces: [], personas: [], preparations: [] }, $pipelineJson));
9536
9725
  }
9537
9726
  /**
9538
9727
  * TODO: [main] !!!! Warn if used only sync version
@@ -10724,7 +10913,7 @@
10724
10913
  return [3 /*break*/, 7];
10725
10914
  case 6:
10726
10915
  if (isVerbose) {
10727
- console.info(colors__default["default"].gray("Skipped file ".concat(fileName.split('\\').join('/'), " \u2013\u2060\u2060\u2060\u2060\u2060\u2060\u2060\u2060\u2060\u2060\u2060\u2060\u2060\u2060\u2060\u2060 Not a pipeline")));
10916
+ console.info(colors__default["default"].gray("Skipped file ".concat(fileName.split('\\').join('/'), " \u2013\u2060\u2060\u2060\u2060\u2060\u2060\u2060\u2060\u2060\u2060\u2060\u2060\u2060\u2060\u2060\u2060 Not a book")));
10728
10917
  }
10729
10918
  _e.label = 7;
10730
10919
  case 7:
@@ -10771,7 +10960,7 @@
10771
10960
  if (!(error_1 instanceof Error)) {
10772
10961
  throw error_1;
10773
10962
  }
10774
- wrappedErrorMessage = spaceTrim__default["default"](function (block) { return "\n ".concat(error_1.name, " in pipeline ").concat(fileName.split('\\').join('/'), "\u2060:\n\n ").concat(block(error_1.message), "\n\n "); });
10963
+ wrappedErrorMessage = spaceTrim__default["default"](function (block) { return "\n ".concat(error_1.name, " in pipeline ").concat(fileName.split('\\').join('/'), "\u2060:\n\n Original error message:\n ").concat(block(error_1.message), "\n\n Original stack trace:\n ").concat(block(error_1.stack || ''), "\n\n ---\n\n "); }) + '\n';
10775
10964
  if (isCrashedOnError) {
10776
10965
  throw new CollectionError(wrappedErrorMessage);
10777
10966
  }