@promptbook/components 0.114.0-11 → 0.114.0-12

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.
Files changed (35) hide show
  1. package/esm/index.es.js +180 -62
  2. package/esm/index.es.js.map +1 -1
  3. package/esm/src/book-2.0/agent-source/AgentSourceParseResult.d.ts +5 -0
  4. package/esm/src/book-2.0/agent-source/ParsedUnknownCommitment.d.ts +26 -0
  5. package/esm/src/book-2.0/agent-source/createAgentModelRequirementsWithCommitments.unknown.test.d.ts +1 -0
  6. package/esm/src/book-2.0/agent-source/getBookCommitmentLineType.d.ts +19 -0
  7. package/esm/src/book-2.0/agent-source/parseAgentSourceWithCommitments.unknown.test.d.ts +1 -0
  8. package/esm/src/book-components/BookEditor/createUnknownCommitmentDiagnostics.d.ts +28 -0
  9. package/esm/src/book-components/BookEditor/createUnknownCommitmentDiagnostics.test.d.ts +1 -0
  10. package/esm/src/cli/cli-commands/common/harness/$checkHarnessInstallation.d.ts +3 -3
  11. package/esm/src/cli/cli-commands/common/harness/$checkHarnessInstallation.test.d.ts +1 -0
  12. package/esm/src/cli/cli-commands/common/harness/$ensureHarnessInstallations.d.ts +3 -3
  13. package/esm/src/cli/cli-commands/common/harness/HarnessInstallationStatus.d.ts +3 -2
  14. package/esm/src/cli/cli-commands/common/harnessUpdateCliOptions.d.ts +29 -0
  15. package/esm/src/cli/cli-commands/common/harnessUpdateCliOptions.test.d.ts +1 -0
  16. package/esm/src/executables/platforms/locateAppOnWindows.d.ts +1 -1
  17. package/esm/src/executables/platforms/locateAppOnWindows.test.d.ts +1 -0
  18. package/package.json +1 -1
  19. package/umd/index.umd.js +180 -62
  20. package/umd/index.umd.js.map +1 -1
  21. package/umd/src/book-2.0/agent-source/AgentSourceParseResult.d.ts +5 -0
  22. package/umd/src/book-2.0/agent-source/ParsedUnknownCommitment.d.ts +26 -0
  23. package/umd/src/book-2.0/agent-source/createAgentModelRequirementsWithCommitments.unknown.test.d.ts +1 -0
  24. package/umd/src/book-2.0/agent-source/getBookCommitmentLineType.d.ts +19 -0
  25. package/umd/src/book-2.0/agent-source/parseAgentSourceWithCommitments.unknown.test.d.ts +1 -0
  26. package/umd/src/book-components/BookEditor/createUnknownCommitmentDiagnostics.d.ts +28 -0
  27. package/umd/src/book-components/BookEditor/createUnknownCommitmentDiagnostics.test.d.ts +1 -0
  28. package/umd/src/cli/cli-commands/common/harness/$checkHarnessInstallation.d.ts +3 -3
  29. package/umd/src/cli/cli-commands/common/harness/$checkHarnessInstallation.test.d.ts +1 -0
  30. package/umd/src/cli/cli-commands/common/harness/$ensureHarnessInstallations.d.ts +3 -3
  31. package/umd/src/cli/cli-commands/common/harness/HarnessInstallationStatus.d.ts +3 -2
  32. package/umd/src/cli/cli-commands/common/harnessUpdateCliOptions.d.ts +29 -0
  33. package/umd/src/cli/cli-commands/common/harnessUpdateCliOptions.test.d.ts +1 -0
  34. package/umd/src/executables/platforms/locateAppOnWindows.d.ts +1 -1
  35. package/umd/src/executables/platforms/locateAppOnWindows.test.d.ts +1 -0
package/esm/index.es.js CHANGED
@@ -39,7 +39,7 @@ const BOOK_LANGUAGE_VERSION = '2.0.0';
39
39
  * @generated
40
40
  * @see https://github.com/webgptorg/promptbook
41
41
  */
42
- const PROMPTBOOK_ENGINE_VERSION = '0.114.0-11';
42
+ const PROMPTBOOK_ENGINE_VERSION = '0.114.0-12';
43
43
  /**
44
44
  * TODO: string_promptbook_version should be constrained to the all versions of Promptbook engine
45
45
  * Note: [💞] Ignore a discrepancy between file name and entity name
@@ -18322,6 +18322,42 @@ const COMMITMENT_REGISTRY = [
18322
18322
  // TODO: [🧠] Maybe create through standardized $register
18323
18323
  // Note: [💞] Ignore a discrepancy between file name and entity name
18324
18324
 
18325
+ /**
18326
+ * Pattern shared by Book parsing and editor highlighting for a commitment-like line.
18327
+ *
18328
+ * A Book commitment keyword consists of one or more all-uppercase words with at least
18329
+ * two characters each. This deliberately mirrors the Book editor syntax rule so an
18330
+ * unknown keyword starts a new source block everywhere it is interpreted.
18331
+ *
18332
+ * @private internal constant of `getBookCommitmentLineType`
18333
+ */
18334
+ const BOOK_COMMITMENT_LINE_TYPE_REGEX = /^\s*(?<type>[A-Z][A-Z0-9]+(?:\s+[A-Z][A-Z0-9]+)*)(?=\s|$)/;
18335
+ /**
18336
+ * Creates the regex used to recognize the uppercase commitment type at the beginning of a Book line.
18337
+ *
18338
+ * A fresh regular expression keeps Monaco tokenizer state isolated from parser calls.
18339
+ *
18340
+ * @returns Regular expression matching one Book commitment-like line.
18341
+ *
18342
+ * @private internal utility of Book parsing and `<BookEditor/>`
18343
+ */
18344
+ function createBookCommitmentLineTypeRegex() {
18345
+ return new RegExp(BOOK_COMMITMENT_LINE_TYPE_REGEX.source);
18346
+ }
18347
+ /**
18348
+ * Extracts the uppercase commitment type from a Book line, including types not registered by Promptbook.
18349
+ *
18350
+ * @param line - One raw Book source line.
18351
+ * @returns Matched commitment type or `null` when the line does not begin with commitment syntax.
18352
+ *
18353
+ * @private internal utility of Book parsing and `<BookEditor/>`
18354
+ */
18355
+ function getBookCommitmentLineType(line) {
18356
+ var _a;
18357
+ const match = BOOK_COMMITMENT_LINE_TYPE_REGEX.exec(line);
18358
+ return ((_a = match === null || match === void 0 ? void 0 : match.groups) === null || _a === void 0 ? void 0 : _a.type) || null;
18359
+ }
18360
+
18325
18361
  /**
18326
18362
  * Consumes the agent-name prelude from raw source.
18327
18363
  *
@@ -18379,13 +18415,15 @@ function parseAgentSourceWithCommitments(agentSource) {
18379
18415
  return {
18380
18416
  agentName: null,
18381
18417
  commitments: [],
18418
+ unknownCommitments: [],
18382
18419
  nonCommitmentLines: [],
18383
18420
  };
18384
18421
  }
18385
18422
  const { lines, agentName, agentNameLineIndex, agentNameLineNumber } = parseAgentSourcePrelude(agentSource);
18386
18423
  const commitments = [];
18424
+ const unknownCommitments = [];
18387
18425
  const nonCommitmentLines = agentNameLineIndex >= 0 ? [lines[agentNameLineIndex]] : [];
18388
- // Parse commitments with multiline support
18426
+ // Parse commitments with multiline support.
18389
18427
  let currentCommitment = null;
18390
18428
  // Process lines starting from after the agent name line
18391
18429
  const startIndex = agentNameLineIndex >= 0 ? agentNameLineIndex + 1 : 0;
@@ -18399,25 +18437,11 @@ function parseAgentSourceWithCommitments(agentSource) {
18399
18437
  // Check if this line starts or ends a code block
18400
18438
  if (trimmedLine.startsWith('```')) {
18401
18439
  isInsideCodeBlock = !isInsideCodeBlock;
18402
- if (currentCommitment) {
18403
- // If we are inside a commitment, the code block is part of it
18404
- currentCommitment.contentLines.push(line);
18405
- }
18406
- else {
18407
- // If we are not inside a commitment, the code block is non-commitment
18408
- nonCommitmentLines.push(line);
18409
- }
18440
+ appendLineToCurrentCommitmentOrNonCommitmentLines(currentCommitment, line, nonCommitmentLines);
18410
18441
  continue;
18411
18442
  }
18412
18443
  if (isInsideCodeBlock) {
18413
- if (currentCommitment) {
18414
- // If we are inside a commitment and a code block, the line is part of the commitment
18415
- currentCommitment.contentLines.push(line);
18416
- }
18417
- else {
18418
- // If we are inside a code block but not a commitment, the line is non-commitment
18419
- nonCommitmentLines.push(line);
18420
- }
18444
+ appendLineToCurrentCommitmentOrNonCommitmentLines(currentCommitment, line, nonCommitmentLines);
18421
18445
  continue;
18422
18446
  }
18423
18447
  // Check if this line starts a new commitment
@@ -18426,22 +18450,14 @@ function parseAgentSourceWithCommitments(agentSource) {
18426
18450
  const typeRegex = definition.createTypeRegex();
18427
18451
  const match = typeRegex.exec(line.trim());
18428
18452
  if (match && ((_a = match.groups) === null || _a === void 0 ? void 0 : _a.type)) {
18429
- // Save the previous commitment if it exists
18430
- if (currentCommitment) {
18431
- const fullContent = currentCommitment.contentLines.join('\n');
18432
- commitments.push({
18433
- type: currentCommitment.type,
18434
- content: spaceTrim$1(fullContent),
18435
- originalLine: currentCommitment.originalStartLine,
18436
- lineNumber: currentCommitment.startLineNumber,
18437
- });
18438
- }
18453
+ appendCurrentCommitment(currentCommitment, commitments, unknownCommitments);
18439
18454
  // Extract the initial content from the commitment line
18440
18455
  const fullRegex = definition.createRegex();
18441
18456
  const fullMatch = fullRegex.exec(line.trim());
18442
18457
  const initialContent = ((_b = fullMatch === null || fullMatch === void 0 ? void 0 : fullMatch.groups) === null || _b === void 0 ? void 0 : _b.contents) || '';
18443
18458
  // Start a new commitment
18444
18459
  currentCommitment = {
18460
+ kind: 'known',
18445
18461
  type: definition.type,
18446
18462
  startLineNumber: i + 1,
18447
18463
  originalStartLine: line,
@@ -18451,52 +18467,90 @@ function parseAgentSourceWithCommitments(agentSource) {
18451
18467
  break;
18452
18468
  }
18453
18469
  }
18470
+ if (foundNewCommitment) {
18471
+ continue;
18472
+ }
18473
+ const unknownCommitmentType = getBookCommitmentLineType(line);
18474
+ if (unknownCommitmentType) {
18475
+ appendCurrentCommitment(currentCommitment, commitments, unknownCommitments);
18476
+ currentCommitment = {
18477
+ kind: 'unknown',
18478
+ type: unknownCommitmentType,
18479
+ startLineNumber: i + 1,
18480
+ originalStartLine: line,
18481
+ sourceLines: [line],
18482
+ };
18483
+ continue;
18484
+ }
18454
18485
  // Check if this is a horizontal line (ends any current commitment)
18455
18486
  const isHorizontalLine = HORIZONTAL_LINE_PATTERN$2.test(line);
18456
18487
  if (isHorizontalLine) {
18457
- // Save the current commitment if it exists
18458
- if (currentCommitment) {
18459
- const fullContent = currentCommitment.contentLines.join('\n');
18460
- commitments.push({
18461
- type: currentCommitment.type,
18462
- content: spaceTrim$1(fullContent),
18463
- originalLine: currentCommitment.originalStartLine,
18464
- lineNumber: currentCommitment.startLineNumber,
18465
- });
18466
- currentCommitment = null;
18467
- }
18488
+ appendCurrentCommitment(currentCommitment, commitments, unknownCommitments);
18489
+ currentCommitment = null;
18468
18490
  // Add horizontal line to non-commitment lines
18469
18491
  nonCommitmentLines.push(line);
18470
18492
  continue;
18471
18493
  }
18472
- if (!foundNewCommitment) {
18473
- if (currentCommitment) {
18474
- // This line belongs to the current commitment
18475
- currentCommitment.contentLines.push(line);
18476
- }
18477
- else {
18478
- // This line is not part of any commitment
18479
- nonCommitmentLines.push(line);
18480
- }
18481
- }
18482
- }
18483
- // Don't forget to save the last commitment if it exists
18484
- if (currentCommitment) {
18485
- const fullContent = currentCommitment.contentLines.join('\n');
18486
- commitments.push({
18487
- type: currentCommitment.type,
18488
- content: spaceTrim$1(fullContent),
18489
- originalLine: currentCommitment.originalStartLine,
18490
- lineNumber: currentCommitment.startLineNumber,
18491
- });
18494
+ appendLineToCurrentCommitmentOrNonCommitmentLines(currentCommitment, line, nonCommitmentLines);
18492
18495
  }
18496
+ appendCurrentCommitment(currentCommitment, commitments, unknownCommitments);
18493
18497
  return {
18494
18498
  agentName,
18495
18499
  agentNameLineNumber,
18496
18500
  commitments,
18501
+ unknownCommitments,
18497
18502
  nonCommitmentLines,
18498
18503
  };
18499
18504
  }
18505
+ /**
18506
+ * Stores the current known or unknown commitment in its appropriate parsed collection.
18507
+ *
18508
+ * @param currentCommitment - Commitment-like block collected so far.
18509
+ * @param commitments - Parsed registered commitments to append to.
18510
+ * @param unknownCommitments - Parsed unregistered commitments to append to.
18511
+ *
18512
+ * @private internal utility of `parseAgentSourceWithCommitments`
18513
+ */
18514
+ function appendCurrentCommitment(currentCommitment, commitments, unknownCommitments) {
18515
+ if (!currentCommitment) {
18516
+ return;
18517
+ }
18518
+ if (currentCommitment.kind === 'unknown') {
18519
+ unknownCommitments.push({
18520
+ type: currentCommitment.type,
18521
+ originalLine: currentCommitment.originalStartLine,
18522
+ lineNumber: currentCommitment.startLineNumber,
18523
+ source: spaceTrim$1(currentCommitment.sourceLines.join('\n')),
18524
+ });
18525
+ return;
18526
+ }
18527
+ commitments.push({
18528
+ type: currentCommitment.type,
18529
+ content: spaceTrim$1(currentCommitment.contentLines.join('\n')),
18530
+ originalLine: currentCommitment.originalStartLine,
18531
+ lineNumber: currentCommitment.startLineNumber,
18532
+ });
18533
+ }
18534
+ /**
18535
+ * Adds one source line to the active commitment-like block, or to plain source content when none is active.
18536
+ *
18537
+ * @param currentCommitment - Commitment-like block currently being collected.
18538
+ * @param line - Source line to append.
18539
+ * @param nonCommitmentLines - Plain source lines to append to when no block is active.
18540
+ *
18541
+ * @private internal utility of `parseAgentSourceWithCommitments`
18542
+ */
18543
+ function appendLineToCurrentCommitmentOrNonCommitmentLines(currentCommitment, line, nonCommitmentLines) {
18544
+ if (!currentCommitment) {
18545
+ nonCommitmentLines.push(line);
18546
+ return;
18547
+ }
18548
+ if (currentCommitment.kind === 'unknown') {
18549
+ currentCommitment.sourceLines.push(line);
18550
+ return;
18551
+ }
18552
+ currentCommitment.contentLines.push(line);
18553
+ }
18500
18554
 
18501
18555
  /**
18502
18556
  * Parses parameters from text using both supported notations:
@@ -20001,6 +20055,35 @@ function createDeprecatedCommitmentDiagnostics(_agentSource) {
20001
20055
  return [];
20002
20056
  }
20003
20057
 
20058
+ /**
20059
+ * Creates Book editor diagnostics for uppercase commitments not registered by Promptbook.
20060
+ *
20061
+ * Unknown commitment blocks remain valid extra context in the generated system message,
20062
+ * but the editor marks their keywords so authors can spot likely typos immediately.
20063
+ *
20064
+ * @param agentSource - Current editor content.
20065
+ * @returns Error markers for all unknown commitment keywords.
20066
+ *
20067
+ * @private internal utility of `BookEditorMonaco`
20068
+ */
20069
+ function createUnknownCommitmentDiagnostics(agentSource) {
20070
+ if (!(agentSource === null || agentSource === void 0 ? void 0 : agentSource.trim())) {
20071
+ return [];
20072
+ }
20073
+ return parseAgentSourceWithCommitments(agentSource).unknownCommitments.map((commitment) => {
20074
+ const startColumn = commitment.originalLine.indexOf(commitment.type) + 1;
20075
+ return {
20076
+ startLineNumber: commitment.lineNumber,
20077
+ startColumn,
20078
+ endLineNumber: commitment.lineNumber,
20079
+ endColumn: startColumn + commitment.type.length,
20080
+ message: `Unknown commitment \`${commitment.type}\` is added to the system message as extra context.`,
20081
+ source: 'Promptbook',
20082
+ severity: 'error',
20083
+ };
20084
+ });
20085
+ }
20086
+
20004
20087
  /**
20005
20088
  * Adds visual decorations for separators and code blocks inside `BookEditorMonaco`.
20006
20089
  *
@@ -20447,7 +20530,7 @@ const AGENT_REFERENCE_COMMITMENT_TYPES = ['FROM', 'IMPORT', 'IMPORTS', 'TEAM'];
20447
20530
  *
20448
20531
  * @private function of BookEditorMonaco
20449
20532
  */
20450
- const DYNAMIC_COMMITMENT_REGEX = /^\s*[A-Z][A-Z0-9]+(?:\s+[A-Z][A-Z0-9]+)*(?=\s|$)/;
20533
+ const DYNAMIC_COMMITMENT_REGEX = createBookCommitmentLineTypeRegex();
20451
20534
  /**
20452
20535
  * Regex pattern to match horizontal lines.
20453
20536
  *
@@ -22150,7 +22233,11 @@ function BookEditorMonaco(props) {
22150
22233
  editor,
22151
22234
  handleFiles,
22152
22235
  });
22153
- const combinedDiagnostics = [...(diagnostics || []), ...createDeprecatedCommitmentDiagnostics()];
22236
+ const combinedDiagnostics = [
22237
+ ...(diagnostics || []),
22238
+ ...createDeprecatedCommitmentDiagnostics(),
22239
+ ...createUnknownCommitmentDiagnostics(value),
22240
+ ];
22154
22241
  const isActionBarVisible = isBookEditorMonacoActionbarVisible({
22155
22242
  hoistedMenuItems,
22156
22243
  isUploadButtonShown,
@@ -49299,7 +49386,8 @@ async function augmentAgentModelRequirementsFromSource(requirements, parseResult
49299
49386
  requirements = await importReferencedFiles(requirements);
49300
49387
  requirements = appendMcpServers(requirements, agentSource);
49301
49388
  requirements = appendNonCommitmentContent(requirements, parseResult);
49302
- return appendExampleInteractions(requirements, parseResult);
49389
+ requirements = appendExampleInteractions(requirements, parseResult);
49390
+ return appendUnknownCommitmentContent(requirements, parseResult);
49303
49391
  }
49304
49392
  /**
49305
49393
  * Imports text files referenced by IMPORT commitments and appends their transformed content to the system message.
@@ -49421,6 +49509,36 @@ function appendNonCommitmentContent(requirements, parseResult) {
49421
49509
  }
49422
49510
  return appendSystemMessageSection(requirements, nonCommitmentContent);
49423
49511
  }
49512
+ /**
49513
+ * Appends unknown commitment blocks as final extra context without applying commitment side effects.
49514
+ *
49515
+ * @param requirements - Current requirements snapshot.
49516
+ * @param parseResult - Parsed source including unknown commitment blocks.
49517
+ * @returns Requirements with unknown commitment context appended at the end of the system message.
49518
+ *
49519
+ * @private internal utility of `augmentAgentModelRequirementsFromSource`
49520
+ */
49521
+ function appendUnknownCommitmentContent(requirements, parseResult) {
49522
+ const unknownCommitmentContent = getUnknownCommitmentContent(parseResult);
49523
+ if (!unknownCommitmentContent) {
49524
+ return requirements;
49525
+ }
49526
+ return appendSystemMessageSection(requirements, unknownCommitmentContent);
49527
+ }
49528
+ /**
49529
+ * Joins unknown commitment blocks into their final extra-context representation.
49530
+ *
49531
+ * @param parseResult - Parsed source including unknown commitment blocks.
49532
+ * @returns Unknown commitment source blocks in their original order.
49533
+ *
49534
+ * @private internal utility of `appendUnknownCommitmentContent`
49535
+ */
49536
+ function getUnknownCommitmentContent(parseResult) {
49537
+ return parseResult.unknownCommitments
49538
+ .map((commitment) => commitment.source)
49539
+ .filter(Boolean)
49540
+ .join('\n\n');
49541
+ }
49424
49542
  /**
49425
49543
  * Collects plain-text lines that were not parsed as commitments and should still become part of the final system message.
49426
49544
  *