@promptbook/cli 0.77.0 → 0.77.1

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.
@@ -35,7 +35,7 @@ import { validatePipeline } from '../conversion/validation/validatePipeline';
35
35
  import { CallbackInterfaceTools } from '../dialogs/callback/CallbackInterfaceTools';
36
36
  import type { CallbackInterfaceToolsOptions } from '../dialogs/callback/CallbackInterfaceToolsOptions';
37
37
  import { BoilerplateError } from '../errors/0-BoilerplateError';
38
- import { ERRORS } from '../errors/0-index';
38
+ import { PROMPTBOOK_ERRORS } from '../errors/0-index';
39
39
  import { AbstractFormatError } from '../errors/AbstractFormatError';
40
40
  import { CollectionError } from '../errors/CollectionError';
41
41
  import { EnvironmentMismatchError } from '../errors/EnvironmentMismatchError';
@@ -150,7 +150,7 @@ export { validatePipeline };
150
150
  export { CallbackInterfaceTools };
151
151
  export type { CallbackInterfaceToolsOptions };
152
152
  export { BoilerplateError };
153
- export { ERRORS };
153
+ export { PROMPTBOOK_ERRORS };
154
154
  export { AbstractFormatError };
155
155
  export { CollectionError };
156
156
  export { EnvironmentMismatchError };
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env ts-node
2
2
  /**
3
- * Note: [🔺] Purpose of this file is to test the CLI in development environment
3
+ * Note: [🔺] Purpose of this file is to test and use the current CLI in development environment
4
4
  */
5
5
  import '../../_packages/cli.index.ts';
@@ -18,7 +18,52 @@ import { UnexpectedError } from './UnexpectedError';
18
18
  *
19
19
  * @public exported from `@promptbook/core`
20
20
  */
21
- export declare const ERRORS: {
21
+ export declare const PROMPTBOOK_ERRORS: {
22
+ readonly AbstractFormatError: typeof AbstractFormatError;
23
+ readonly CsvFormatError: typeof CsvFormatError;
24
+ readonly CollectionError: typeof CollectionError;
25
+ readonly EnvironmentMismatchError: typeof EnvironmentMismatchError;
26
+ readonly ExpectError: typeof ExpectError;
27
+ readonly KnowledgeScrapeError: typeof KnowledgeScrapeError;
28
+ readonly LimitReachedError: typeof LimitReachedError;
29
+ readonly MissingToolsError: typeof MissingToolsError;
30
+ readonly NotFoundError: typeof NotFoundError;
31
+ readonly NotYetImplementedError: typeof NotYetImplementedError;
32
+ readonly ParseError: typeof ParseError;
33
+ readonly PipelineExecutionError: typeof PipelineExecutionError;
34
+ readonly PipelineLogicError: typeof PipelineLogicError;
35
+ readonly PipelineUrlError: typeof PipelineUrlError;
36
+ readonly UnexpectedError: typeof UnexpectedError;
37
+ };
38
+ /**
39
+ * Index of all javascript errors
40
+ *
41
+ * @private for internal usage
42
+ */
43
+ export declare const COMMON_JAVASCRIPT_ERRORS: {
44
+ readonly Error: ErrorConstructor;
45
+ readonly EvalError: EvalErrorConstructor;
46
+ readonly RangeError: RangeErrorConstructor;
47
+ readonly ReferenceError: ReferenceErrorConstructor;
48
+ readonly SyntaxError: SyntaxErrorConstructor;
49
+ readonly TypeError: TypeErrorConstructor;
50
+ readonly URIError: URIErrorConstructor;
51
+ readonly AggregateError: AggregateErrorConstructor;
52
+ };
53
+ /**
54
+ * Index of all errors
55
+ *
56
+ * @private for internal usage
57
+ */
58
+ export declare const ALL_ERRORS: {
59
+ readonly Error: ErrorConstructor;
60
+ readonly EvalError: EvalErrorConstructor;
61
+ readonly RangeError: RangeErrorConstructor;
62
+ readonly ReferenceError: ReferenceErrorConstructor;
63
+ readonly SyntaxError: SyntaxErrorConstructor;
64
+ readonly TypeError: TypeErrorConstructor;
65
+ readonly URIError: URIErrorConstructor;
66
+ readonly AggregateError: AggregateErrorConstructor;
22
67
  readonly AbstractFormatError: typeof AbstractFormatError;
23
68
  readonly CsvFormatError: typeof CsvFormatError;
24
69
  readonly CollectionError: typeof CollectionError;
@@ -1,4 +1,4 @@
1
- import type { ERRORS } from '../0-index';
1
+ import type { ALL_ERRORS } from '../0-index';
2
2
  /**
3
3
  * Represents a serialized error or custom Promptbook error
4
4
  *
@@ -8,7 +8,7 @@ export type ErrorJson = {
8
8
  /**
9
9
  * The type of the error
10
10
  */
11
- readonly name: keyof typeof ERRORS | 'Error';
11
+ readonly name: keyof typeof ALL_ERRORS;
12
12
  /**
13
13
  * The message of the error
14
14
  */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@promptbook/cli",
3
- "version": "0.77.0",
3
+ "version": "0.77.1",
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.77.0-6';
52
+ var PROMPTBOOK_ENGINE_VERSION = '0.77.0';
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
@@ -3635,7 +3635,7 @@
3635
3635
  *
3636
3636
  * @public exported from `@promptbook/core`
3637
3637
  */
3638
- var ERRORS = {
3638
+ var PROMPTBOOK_ERRORS = {
3639
3639
  AbstractFormatError: AbstractFormatError,
3640
3640
  CsvFormatError: CsvFormatError,
3641
3641
  CollectionError: CollectionError,
@@ -3653,6 +3653,35 @@
3653
3653
  UnexpectedError: UnexpectedError,
3654
3654
  // TODO: [🪑]> VersionMismatchError,
3655
3655
  };
3656
+ /**
3657
+ * Index of all javascript errors
3658
+ *
3659
+ * @private for internal usage
3660
+ */
3661
+ var COMMON_JAVASCRIPT_ERRORS = {
3662
+ Error: Error,
3663
+ EvalError: EvalError,
3664
+ RangeError: RangeError,
3665
+ ReferenceError: ReferenceError,
3666
+ SyntaxError: SyntaxError,
3667
+ TypeError: TypeError,
3668
+ URIError: URIError,
3669
+ AggregateError: AggregateError,
3670
+ /*
3671
+ Note: Not widely supported
3672
+ > InternalError,
3673
+ > ModuleError,
3674
+ > HeapError,
3675
+ > WebAssemblyCompileError,
3676
+ > WebAssemblyRuntimeError,
3677
+ */
3678
+ };
3679
+ /**
3680
+ * Index of all errors
3681
+ *
3682
+ * @private for internal usage
3683
+ */
3684
+ var ALL_ERRORS = __assign(__assign({}, PROMPTBOOK_ERRORS), COMMON_JAVASCRIPT_ERRORS);
3656
3685
  /**
3657
3686
  * Note: [💞] Ignore a discrepancy between file name and entity name
3658
3687
  */
@@ -3663,11 +3692,11 @@
3663
3692
  * @public exported from `@promptbook/utils`
3664
3693
  */
3665
3694
  function deserializeError(error) {
3666
- if (error.name === 'Error') {
3667
- return new Error(error.message);
3695
+ var ErrorClass = ALL_ERRORS[error.name];
3696
+ if (ErrorClass === undefined) {
3697
+ return new Error("".concat(error.name, ": ").concat(error.message));
3668
3698
  }
3669
- var CustomError = ERRORS[error.name];
3670
- return new CustomError(error.message);
3699
+ return new ErrorClass(error.message);
3671
3700
  }
3672
3701
 
3673
3702
  /**
@@ -3741,8 +3770,8 @@
3741
3770
  */
3742
3771
  function serializeError(error) {
3743
3772
  var name = error.name, message = error.message, stack = error.stack;
3744
- if (!__spreadArray(['Error'], __read(Object.keys(ERRORS)), false).includes(name)) {
3745
- throw new UnexpectedError(spaceTrim__default["default"](function (block) { return "\n \n Cannot serialize error with name \"".concat(name, "\"\n\n ").concat(block(stack || message), "\n \n "); }));
3773
+ if (!Object.keys(ALL_ERRORS).includes(name)) {
3774
+ console.error(spaceTrim__default["default"](function (block) { return "\n \n Cannot serialize error with name \"".concat(name, "\"\n\n ").concat(block(stack || message), "\n \n "); }));
3746
3775
  }
3747
3776
  return {
3748
3777
  name: name,
@@ -9055,7 +9084,7 @@
9055
9084
  * @public exported from `@promptbook/core`
9056
9085
  */
9057
9086
  function pipelineStringToJsonSync(pipelineString) {
9058
- var e_1, _a, e_2, _b, e_3, _c, e_4, _d;
9087
+ var e_1, _a, e_2, _b, e_3, _c, e_4, _d, e_5, _e;
9059
9088
  var $pipelineJson = {
9060
9089
  title: undefined /* <- Note: [🍙] Putting here placeholder to keep `title` on top at final JSON */,
9061
9090
  pipelineUrl: undefined /* <- Note: Putting here placeholder to keep `pipelineUrl` on top at final JSON */,
@@ -9084,7 +9113,7 @@
9084
9113
  // =============================================================
9085
9114
  // Note: 1️⃣ Parsing of the markdown into object
9086
9115
  if (pipelineString.startsWith('#!')) {
9087
- var _e = __read(pipelineString.split('\n')), shebangLine_1 = _e[0], restLines = _e.slice(1);
9116
+ var _f = __read(pipelineString.split('\n')), shebangLine_1 = _f[0], restLines = _f.slice(1);
9088
9117
  if (!(shebangLine_1 || '').includes('ptbk')) {
9089
9118
  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 "); }));
9090
9119
  }
@@ -9094,7 +9123,7 @@
9094
9123
  pipelineString = flattenMarkdown(pipelineString) /* <- Note: [🥞] */;
9095
9124
  pipelineString = pipelineString.replaceAll(/`\{(?<parameterName>[a-z0-9_]+)\}`/gi, '{$<parameterName>}');
9096
9125
  pipelineString = pipelineString.replaceAll(/`->\s+\{(?<parameterName>[a-z0-9_]+)\}`/gi, '-> {$<parameterName>}');
9097
- var _f = __read(splitMarkdownIntoSections(pipelineString).map(parseMarkdownSection)), pipelineHead = _f[0], pipelineSections = _f.slice(1); /* <- Note: [🥞] */
9126
+ var _g = __read(splitMarkdownIntoSections(pipelineString).map(parseMarkdownSection)), pipelineHead = _g[0], pipelineSections = _g.slice(1); /* <- Note: [🥞] */
9098
9127
  if (pipelineHead === undefined) {
9099
9128
  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 "); }));
9100
9129
  }
@@ -9185,11 +9214,41 @@
9185
9214
  }
9186
9215
  finally { if (e_1) throw e_1.error; }
9187
9216
  }
9217
+ // =============================================================
9218
+ // Note: 4️⃣ Prepare unique section names with indexes when needed
9219
+ var sectionCounts = {};
9220
+ try {
9221
+ for (var pipelineSections_1 = __values(pipelineSections), pipelineSections_1_1 = pipelineSections_1.next(); !pipelineSections_1_1.done; pipelineSections_1_1 = pipelineSections_1.next()) {
9222
+ var section = pipelineSections_1_1.value;
9223
+ var name_1 = titleToName(section.title);
9224
+ if (sectionCounts[name_1] === undefined) {
9225
+ sectionCounts[name_1] = { count: 0, currentIndex: 0 };
9226
+ }
9227
+ sectionCounts[name_1].count++;
9228
+ }
9229
+ }
9230
+ catch (e_2_1) { e_2 = { error: e_2_1 }; }
9231
+ finally {
9232
+ try {
9233
+ if (pipelineSections_1_1 && !pipelineSections_1_1.done && (_b = pipelineSections_1.return)) _b.call(pipelineSections_1);
9234
+ }
9235
+ finally { if (e_2) throw e_2.error; }
9236
+ }
9237
+ var getUniqueSectionName = function (title) {
9238
+ var name = titleToName(title);
9239
+ var count = sectionCounts[name];
9240
+ if (count.count === 1) {
9241
+ return name;
9242
+ }
9243
+ var nameWithSuffix = "".concat(name, "-").concat(count.currentIndex);
9244
+ count.currentIndex++;
9245
+ return nameWithSuffix;
9246
+ };
9188
9247
  var _loop_2 = function (section) {
9189
- var e_5, _l, e_6, _m;
9248
+ var e_6, _m, e_7, _o;
9190
9249
  // TODO: Parse section's description (the content out of the codeblock and lists)
9191
9250
  var listItems_2 = extractAllListItemsFromMarkdown(section.content);
9192
- var _o = extractOneBlockFromMarkdown(section.content), language = _o.language, content = _o.content;
9251
+ var _p = extractOneBlockFromMarkdown(section.content), language = _p.language, content = _p.content;
9193
9252
  // TODO: [🎾][1] DRY description
9194
9253
  var description_1 = section.content;
9195
9254
  // Note: Remove codeblocks - TODO: [🎾]
@@ -9205,7 +9264,7 @@
9205
9264
  isSectionTypeSet: false,
9206
9265
  isTask: true,
9207
9266
  taskType: undefined /* <- Note: [🍙] Putting here placeholder to keep `taskType` on top at final JSON */,
9208
- name: titleToName(section.title),
9267
+ name: getUniqueSectionName(section.title),
9209
9268
  title: section.title,
9210
9269
  description: description_1,
9211
9270
  content: content,
@@ -9253,17 +9312,17 @@
9253
9312
  };
9254
9313
  try {
9255
9314
  // TODO [♓️] List commands and before apply order them to achieve order-agnostic commands
9256
- for (var commands_1 = (e_5 = void 0, __values(commands)), commands_1_1 = commands_1.next(); !commands_1_1.done; commands_1_1 = commands_1.next()) {
9257
- var _p = commands_1_1.value, listItem = _p.listItem, command = _p.command;
9315
+ 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()) {
9316
+ var _q = commands_1_1.value, listItem = _q.listItem, command = _q.command;
9258
9317
  _loop_4(listItem, command);
9259
9318
  }
9260
9319
  }
9261
- catch (e_5_1) { e_5 = { error: e_5_1 }; }
9320
+ catch (e_6_1) { e_6 = { error: e_6_1 }; }
9262
9321
  finally {
9263
9322
  try {
9264
- if (commands_1_1 && !commands_1_1.done && (_l = commands_1.return)) _l.call(commands_1);
9323
+ if (commands_1_1 && !commands_1_1.done && (_m = commands_1.return)) _m.call(commands_1);
9265
9324
  }
9266
- finally { if (e_5) throw e_5.error; }
9325
+ finally { if (e_6) throw e_6.error; }
9267
9326
  }
9268
9327
  // TODO: [🍧] Should be done in SECTION command
9269
9328
  if ($taskJson.taskType === 'SCRIPT_TASK') {
@@ -9277,8 +9336,8 @@
9277
9336
  }
9278
9337
  $taskJson.dependentParameterNames = Array.from(extractParameterNamesFromTask($taskJson));
9279
9338
  try {
9280
- for (var _q = (e_6 = void 0, __values($taskJson.dependentParameterNames)), _r = _q.next(); !_r.done; _r = _q.next()) {
9281
- var parameterName = _r.value;
9339
+ for (var _r = (e_7 = void 0, __values($taskJson.dependentParameterNames)), _s = _r.next(); !_s.done; _s = _r.next()) {
9340
+ var parameterName = _s.value;
9282
9341
  // TODO: [🧠] This definition should be made first in the task
9283
9342
  defineParam({
9284
9343
  parameterName: parameterName,
@@ -9289,12 +9348,12 @@
9289
9348
  });
9290
9349
  }
9291
9350
  }
9292
- catch (e_6_1) { e_6 = { error: e_6_1 }; }
9351
+ catch (e_7_1) { e_7 = { error: e_7_1 }; }
9293
9352
  finally {
9294
9353
  try {
9295
- if (_r && !_r.done && (_m = _q.return)) _m.call(_q);
9354
+ if (_s && !_s.done && (_o = _r.return)) _o.call(_r);
9296
9355
  }
9297
- finally { if (e_6) throw e_6.error; }
9356
+ finally { if (e_7) throw e_7.error; }
9298
9357
  }
9299
9358
  /*
9300
9359
  // TODO: [🍧] This should be checked in `MODEL` command + better error message
@@ -9323,21 +9382,21 @@
9323
9382
  };
9324
9383
  try {
9325
9384
  // =============================================================
9326
- // Note: 4️⃣ Process each section of the pipeline
9327
- for (var pipelineSections_1 = __values(pipelineSections), pipelineSections_1_1 = pipelineSections_1.next(); !pipelineSections_1_1.done; pipelineSections_1_1 = pipelineSections_1.next()) {
9328
- var section = pipelineSections_1_1.value;
9385
+ // Note: 5️⃣ Process each section of the pipeline
9386
+ for (var pipelineSections_2 = __values(pipelineSections), pipelineSections_2_1 = pipelineSections_2.next(); !pipelineSections_2_1.done; pipelineSections_2_1 = pipelineSections_2.next()) {
9387
+ var section = pipelineSections_2_1.value;
9329
9388
  _loop_2(section);
9330
9389
  }
9331
9390
  }
9332
- catch (e_2_1) { e_2 = { error: e_2_1 }; }
9391
+ catch (e_3_1) { e_3 = { error: e_3_1 }; }
9333
9392
  finally {
9334
9393
  try {
9335
- if (pipelineSections_1_1 && !pipelineSections_1_1.done && (_b = pipelineSections_1.return)) _b.call(pipelineSections_1);
9394
+ if (pipelineSections_2_1 && !pipelineSections_2_1.done && (_c = pipelineSections_2.return)) _c.call(pipelineSections_2);
9336
9395
  }
9337
- finally { if (e_2) throw e_2.error; }
9396
+ finally { if (e_3) throw e_3.error; }
9338
9397
  }
9339
9398
  // =============================================================
9340
- // Note: 5️⃣ Mark parameters as INPUT if not explicitly set
9399
+ // Note: 6️⃣ Mark parameters as INPUT if not explicitly set
9341
9400
  if ($pipelineJson.parameters.every(function (parameter) { return !parameter.isInput; })) {
9342
9401
  var _loop_3 = function (parameter) {
9343
9402
  var isThisParameterResulting = $pipelineJson.tasks.some(function (task) { return task.resultingParameterName === parameter.name; });
@@ -9346,42 +9405,42 @@
9346
9405
  }
9347
9406
  };
9348
9407
  try {
9349
- for (var _g = __values($pipelineJson.parameters), _h = _g.next(); !_h.done; _h = _g.next()) {
9350
- var parameter = _h.value;
9408
+ for (var _h = __values($pipelineJson.parameters), _j = _h.next(); !_j.done; _j = _h.next()) {
9409
+ var parameter = _j.value;
9351
9410
  _loop_3(parameter);
9352
9411
  }
9353
9412
  }
9354
- catch (e_3_1) { e_3 = { error: e_3_1 }; }
9413
+ catch (e_4_1) { e_4 = { error: e_4_1 }; }
9355
9414
  finally {
9356
9415
  try {
9357
- if (_h && !_h.done && (_c = _g.return)) _c.call(_g);
9416
+ if (_j && !_j.done && (_d = _h.return)) _d.call(_h);
9358
9417
  }
9359
- finally { if (e_3) throw e_3.error; }
9418
+ finally { if (e_4) throw e_4.error; }
9360
9419
  }
9361
9420
  }
9362
9421
  // =============================================================
9363
- // Note: 6️⃣ Mark all non-INPUT parameters as OUTPUT if any OUTPUT is not set
9422
+ // Note: 7️⃣ Mark all non-INPUT parameters as OUTPUT if any OUTPUT is not set
9364
9423
  if ($pipelineJson.parameters.every(function (parameter) { return !parameter.isOutput; })) {
9365
9424
  try {
9366
- for (var _j = __values($pipelineJson.parameters), _k = _j.next(); !_k.done; _k = _j.next()) {
9367
- var parameter = _k.value;
9425
+ for (var _k = __values($pipelineJson.parameters), _l = _k.next(); !_l.done; _l = _k.next()) {
9426
+ var parameter = _l.value;
9368
9427
  if (!parameter.isInput) {
9369
9428
  parameter.isOutput = true;
9370
9429
  }
9371
9430
  }
9372
9431
  }
9373
- catch (e_4_1) { e_4 = { error: e_4_1 }; }
9432
+ catch (e_5_1) { e_5 = { error: e_5_1 }; }
9374
9433
  finally {
9375
9434
  try {
9376
- if (_k && !_k.done && (_d = _j.return)) _d.call(_j);
9435
+ if (_l && !_l.done && (_e = _k.return)) _e.call(_k);
9377
9436
  }
9378
- finally { if (e_4) throw e_4.error; }
9437
+ finally { if (e_5) throw e_5.error; }
9379
9438
  }
9380
9439
  }
9381
9440
  // =============================================================
9382
- // Note: 7️⃣ Cleanup of undefined values
9441
+ // Note: 8️⃣ Cleanup of undefined values
9383
9442
  $pipelineJson.tasks.forEach(function (tasks) {
9384
- var e_7, _a;
9443
+ var e_8, _a;
9385
9444
  try {
9386
9445
  for (var _b = __values(Object.entries(tasks)), _c = _b.next(); !_c.done; _c = _b.next()) {
9387
9446
  var _d = __read(_c.value, 2), key = _d[0], value = _d[1];
@@ -9390,16 +9449,16 @@
9390
9449
  }
9391
9450
  }
9392
9451
  }
9393
- catch (e_7_1) { e_7 = { error: e_7_1 }; }
9452
+ catch (e_8_1) { e_8 = { error: e_8_1 }; }
9394
9453
  finally {
9395
9454
  try {
9396
9455
  if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
9397
9456
  }
9398
- finally { if (e_7) throw e_7.error; }
9457
+ finally { if (e_8) throw e_8.error; }
9399
9458
  }
9400
9459
  });
9401
9460
  $pipelineJson.parameters.forEach(function (parameter) {
9402
- var e_8, _a;
9461
+ var e_9, _a;
9403
9462
  try {
9404
9463
  for (var _b = __values(Object.entries(parameter)), _c = _b.next(); !_c.done; _c = _b.next()) {
9405
9464
  var _d = __read(_c.value, 2), key = _d[0], value = _d[1];
@@ -9408,12 +9467,12 @@
9408
9467
  }
9409
9468
  }
9410
9469
  }
9411
- catch (e_8_1) { e_8 = { error: e_8_1 }; }
9470
+ catch (e_9_1) { e_9 = { error: e_9_1 }; }
9412
9471
  finally {
9413
9472
  try {
9414
9473
  if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
9415
9474
  }
9416
- finally { if (e_8) throw e_8.error; }
9475
+ finally { if (e_9) throw e_9.error; }
9417
9476
  }
9418
9477
  });
9419
9478
  // =============================================================
@@ -10993,18 +11052,19 @@
10993
11052
  var warningLine = "<!-- ".concat(GENERATOR_WARNING, " -->");
10994
11053
  var sectionRegex = new RegExp("<!--".concat(sectionName, "-->([\\s\\S]*?)<!--/").concat(sectionName, "-->"), 'g');
10995
11054
  var sectionMatch = content.match(sectionRegex);
11055
+ var contentToInsert = spaceTrim.spaceTrim(function (block) { return "\n <!--".concat(sectionName, "-->\n ").concat(block(warningLine), "\n ").concat(block(sectionContent), "\n <!--/").concat(sectionName, "-->\n "); });
10996
11056
  if (sectionMatch) {
10997
- return content.replace(sectionRegex, spaceTrim.spaceTrim(function (block) { return "\n <!--".concat(sectionName, "-->\n ").concat(block(warningLine), "\n ").concat(block(sectionContent), "\n <!--/").concat(sectionName, "-->\n "); }));
11057
+ return content.replace(sectionRegex, contentToInsert);
10998
11058
  }
11059
+ // Note: Following is the case when the section is not found in the file so we add it there
10999
11060
  var placeForSection = removeContentComments(content).match(/^##.*$/im);
11000
- if (!placeForSection) {
11001
- throw new ParseError(
11002
- // <- [🧠] Maybe something better tha `ParseError`
11003
- "No place where to put the section <!--".concat(sectionName, "-->"));
11004
- // <- [🚞]
11061
+ if (placeForSection !== null) {
11062
+ var _a = __read(placeForSection, 1), heading_1 = _a[0];
11063
+ return content.replace(heading_1, spaceTrim.spaceTrim(function (block) { return "\n ".concat(block(contentToInsert), "\n \n ").concat(block(heading_1), "\n "); }));
11005
11064
  }
11006
- var _a = __read(placeForSection, 1), heading = _a[0];
11007
- return content.replace(heading, "<!--".concat(sectionName, "-->\n").concat(warningLine, "\n").concat(sectionContent, "\n<!--/").concat(sectionName, "-->\n\n").concat(heading));
11065
+ console.warn("No place where to put the section <!--".concat(sectionName, "-->, using the end of the file"));
11066
+ // <- TODO: [🚎] Some better way how to get warnings from pipeline parsing / logic
11067
+ return spaceTrim.spaceTrim(function (block) { return "\n ".concat(block(content), "\n \n ").concat(block(contentToInsert), "\n "); });
11008
11068
  }
11009
11069
  /**
11010
11070
  * TODO: [🏛] This can be part of markdown builder
@@ -11032,7 +11092,7 @@
11032
11092
  if (!task) {
11033
11093
  throw new Error("Could not find task for {".concat(parameterName, "}"));
11034
11094
  }
11035
- return normalizeTo_camelCase('task-' + titleToName(task.title));
11095
+ return task.name || normalizeTo_camelCase('task-' + titleToName(task.title));
11036
11096
  };
11037
11097
  var promptbookMermaid = spaceTrim.spaceTrim(function (block) { return "\n\n %% \uD83D\uDD2E Tip: Open this on GitHub or in the VSCode website to see the Mermaid graph visually\n\n flowchart LR\n subgraph \"".concat(pipelineJson.title, "\"\n\n direction TB\n\n input((Input)):::input\n ").concat(block(pipelineJson.tasks
11038
11098
  .flatMap(function (_a) {
@@ -11095,7 +11155,7 @@
11095
11155
  return { href: "#".concat(task.name), title: task.title };
11096
11156
  },
11097
11157
  });
11098
- promptbookMermaidBlock = spaceTrim.spaceTrim(function (block) { return "\n ```mermaid\n ".concat(block(promptbookMermaid_1), "\n ```\n "); });
11158
+ promptbookMermaidBlock = spaceTrim.spaceTrim(function (block) { return "\n ```mermaid\n ".concat(block(promptbookMermaid_1), "\n ```\n "); });
11099
11159
  pipelineString = addAutoGeneratedSection(pipelineString, {
11100
11160
  sectionName: 'Graph',
11101
11161
  sectionContent: promptbookMermaidBlock,