@promptbook/core 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 +133 -60
  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 +133 -60
  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
@@ -26,7 +26,7 @@ const BOOK_LANGUAGE_VERSION = '2.0.0';
26
26
  * @generated
27
27
  * @see https://github.com/webgptorg/promptbook
28
28
  */
29
- const PROMPTBOOK_ENGINE_VERSION = '0.114.0-11';
29
+ const PROMPTBOOK_ENGINE_VERSION = '0.114.0-12';
30
30
  /**
31
31
  * TODO: string_promptbook_version should be constrained to the all versions of Promptbook engine
32
32
  * Note: [💞] Ignore a discrepancy between file name and entity name
@@ -24334,6 +24334,30 @@ function applyCommitmentDefinitionSafely(requirements, commitment, commitmentCon
24334
24334
  }
24335
24335
  }
24336
24336
 
24337
+ /**
24338
+ * Pattern shared by Book parsing and editor highlighting for a commitment-like line.
24339
+ *
24340
+ * A Book commitment keyword consists of one or more all-uppercase words with at least
24341
+ * two characters each. This deliberately mirrors the Book editor syntax rule so an
24342
+ * unknown keyword starts a new source block everywhere it is interpreted.
24343
+ *
24344
+ * @private internal constant of `getBookCommitmentLineType`
24345
+ */
24346
+ const BOOK_COMMITMENT_LINE_TYPE_REGEX = /^\s*(?<type>[A-Z][A-Z0-9]+(?:\s+[A-Z][A-Z0-9]+)*)(?=\s|$)/;
24347
+ /**
24348
+ * Extracts the uppercase commitment type from a Book line, including types not registered by Promptbook.
24349
+ *
24350
+ * @param line - One raw Book source line.
24351
+ * @returns Matched commitment type or `null` when the line does not begin with commitment syntax.
24352
+ *
24353
+ * @private internal utility of Book parsing and `<BookEditor/>`
24354
+ */
24355
+ function getBookCommitmentLineType(line) {
24356
+ var _a;
24357
+ const match = BOOK_COMMITMENT_LINE_TYPE_REGEX.exec(line);
24358
+ return ((_a = match === null || match === void 0 ? void 0 : match.groups) === null || _a === void 0 ? void 0 : _a.type) || null;
24359
+ }
24360
+
24337
24361
  /**
24338
24362
  * Consumes the agent-name prelude from raw source.
24339
24363
  *
@@ -24391,13 +24415,15 @@ function parseAgentSourceWithCommitments(agentSource) {
24391
24415
  return {
24392
24416
  agentName: null,
24393
24417
  commitments: [],
24418
+ unknownCommitments: [],
24394
24419
  nonCommitmentLines: [],
24395
24420
  };
24396
24421
  }
24397
24422
  const { lines, agentName, agentNameLineIndex, agentNameLineNumber } = parseAgentSourcePrelude(agentSource);
24398
24423
  const commitments = [];
24424
+ const unknownCommitments = [];
24399
24425
  const nonCommitmentLines = agentNameLineIndex >= 0 ? [lines[agentNameLineIndex]] : [];
24400
- // Parse commitments with multiline support
24426
+ // Parse commitments with multiline support.
24401
24427
  let currentCommitment = null;
24402
24428
  // Process lines starting from after the agent name line
24403
24429
  const startIndex = agentNameLineIndex >= 0 ? agentNameLineIndex + 1 : 0;
@@ -24411,25 +24437,11 @@ function parseAgentSourceWithCommitments(agentSource) {
24411
24437
  // Check if this line starts or ends a code block
24412
24438
  if (trimmedLine.startsWith('```')) {
24413
24439
  isInsideCodeBlock = !isInsideCodeBlock;
24414
- if (currentCommitment) {
24415
- // If we are inside a commitment, the code block is part of it
24416
- currentCommitment.contentLines.push(line);
24417
- }
24418
- else {
24419
- // If we are not inside a commitment, the code block is non-commitment
24420
- nonCommitmentLines.push(line);
24421
- }
24440
+ appendLineToCurrentCommitmentOrNonCommitmentLines(currentCommitment, line, nonCommitmentLines);
24422
24441
  continue;
24423
24442
  }
24424
24443
  if (isInsideCodeBlock) {
24425
- if (currentCommitment) {
24426
- // If we are inside a commitment and a code block, the line is part of the commitment
24427
- currentCommitment.contentLines.push(line);
24428
- }
24429
- else {
24430
- // If we are inside a code block but not a commitment, the line is non-commitment
24431
- nonCommitmentLines.push(line);
24432
- }
24444
+ appendLineToCurrentCommitmentOrNonCommitmentLines(currentCommitment, line, nonCommitmentLines);
24433
24445
  continue;
24434
24446
  }
24435
24447
  // Check if this line starts a new commitment
@@ -24438,22 +24450,14 @@ function parseAgentSourceWithCommitments(agentSource) {
24438
24450
  const typeRegex = definition.createTypeRegex();
24439
24451
  const match = typeRegex.exec(line.trim());
24440
24452
  if (match && ((_a = match.groups) === null || _a === void 0 ? void 0 : _a.type)) {
24441
- // Save the previous commitment if it exists
24442
- if (currentCommitment) {
24443
- const fullContent = currentCommitment.contentLines.join('\n');
24444
- commitments.push({
24445
- type: currentCommitment.type,
24446
- content: spaceTrim$1(fullContent),
24447
- originalLine: currentCommitment.originalStartLine,
24448
- lineNumber: currentCommitment.startLineNumber,
24449
- });
24450
- }
24453
+ appendCurrentCommitment(currentCommitment, commitments, unknownCommitments);
24451
24454
  // Extract the initial content from the commitment line
24452
24455
  const fullRegex = definition.createRegex();
24453
24456
  const fullMatch = fullRegex.exec(line.trim());
24454
24457
  const initialContent = ((_b = fullMatch === null || fullMatch === void 0 ? void 0 : fullMatch.groups) === null || _b === void 0 ? void 0 : _b.contents) || '';
24455
24458
  // Start a new commitment
24456
24459
  currentCommitment = {
24460
+ kind: 'known',
24457
24461
  type: definition.type,
24458
24462
  startLineNumber: i + 1,
24459
24463
  originalStartLine: line,
@@ -24463,52 +24467,90 @@ function parseAgentSourceWithCommitments(agentSource) {
24463
24467
  break;
24464
24468
  }
24465
24469
  }
24470
+ if (foundNewCommitment) {
24471
+ continue;
24472
+ }
24473
+ const unknownCommitmentType = getBookCommitmentLineType(line);
24474
+ if (unknownCommitmentType) {
24475
+ appendCurrentCommitment(currentCommitment, commitments, unknownCommitments);
24476
+ currentCommitment = {
24477
+ kind: 'unknown',
24478
+ type: unknownCommitmentType,
24479
+ startLineNumber: i + 1,
24480
+ originalStartLine: line,
24481
+ sourceLines: [line],
24482
+ };
24483
+ continue;
24484
+ }
24466
24485
  // Check if this is a horizontal line (ends any current commitment)
24467
24486
  const isHorizontalLine = HORIZONTAL_LINE_PATTERN$1.test(line);
24468
24487
  if (isHorizontalLine) {
24469
- // Save the current commitment if it exists
24470
- if (currentCommitment) {
24471
- const fullContent = currentCommitment.contentLines.join('\n');
24472
- commitments.push({
24473
- type: currentCommitment.type,
24474
- content: spaceTrim$1(fullContent),
24475
- originalLine: currentCommitment.originalStartLine,
24476
- lineNumber: currentCommitment.startLineNumber,
24477
- });
24478
- currentCommitment = null;
24479
- }
24488
+ appendCurrentCommitment(currentCommitment, commitments, unknownCommitments);
24489
+ currentCommitment = null;
24480
24490
  // Add horizontal line to non-commitment lines
24481
24491
  nonCommitmentLines.push(line);
24482
24492
  continue;
24483
24493
  }
24484
- if (!foundNewCommitment) {
24485
- if (currentCommitment) {
24486
- // This line belongs to the current commitment
24487
- currentCommitment.contentLines.push(line);
24488
- }
24489
- else {
24490
- // This line is not part of any commitment
24491
- nonCommitmentLines.push(line);
24492
- }
24493
- }
24494
- }
24495
- // Don't forget to save the last commitment if it exists
24496
- if (currentCommitment) {
24497
- const fullContent = currentCommitment.contentLines.join('\n');
24498
- commitments.push({
24499
- type: currentCommitment.type,
24500
- content: spaceTrim$1(fullContent),
24501
- originalLine: currentCommitment.originalStartLine,
24502
- lineNumber: currentCommitment.startLineNumber,
24503
- });
24494
+ appendLineToCurrentCommitmentOrNonCommitmentLines(currentCommitment, line, nonCommitmentLines);
24504
24495
  }
24496
+ appendCurrentCommitment(currentCommitment, commitments, unknownCommitments);
24505
24497
  return {
24506
24498
  agentName,
24507
24499
  agentNameLineNumber,
24508
24500
  commitments,
24501
+ unknownCommitments,
24509
24502
  nonCommitmentLines,
24510
24503
  };
24511
24504
  }
24505
+ /**
24506
+ * Stores the current known or unknown commitment in its appropriate parsed collection.
24507
+ *
24508
+ * @param currentCommitment - Commitment-like block collected so far.
24509
+ * @param commitments - Parsed registered commitments to append to.
24510
+ * @param unknownCommitments - Parsed unregistered commitments to append to.
24511
+ *
24512
+ * @private internal utility of `parseAgentSourceWithCommitments`
24513
+ */
24514
+ function appendCurrentCommitment(currentCommitment, commitments, unknownCommitments) {
24515
+ if (!currentCommitment) {
24516
+ return;
24517
+ }
24518
+ if (currentCommitment.kind === 'unknown') {
24519
+ unknownCommitments.push({
24520
+ type: currentCommitment.type,
24521
+ originalLine: currentCommitment.originalStartLine,
24522
+ lineNumber: currentCommitment.startLineNumber,
24523
+ source: spaceTrim$1(currentCommitment.sourceLines.join('\n')),
24524
+ });
24525
+ return;
24526
+ }
24527
+ commitments.push({
24528
+ type: currentCommitment.type,
24529
+ content: spaceTrim$1(currentCommitment.contentLines.join('\n')),
24530
+ originalLine: currentCommitment.originalStartLine,
24531
+ lineNumber: currentCommitment.startLineNumber,
24532
+ });
24533
+ }
24534
+ /**
24535
+ * Adds one source line to the active commitment-like block, or to plain source content when none is active.
24536
+ *
24537
+ * @param currentCommitment - Commitment-like block currently being collected.
24538
+ * @param line - Source line to append.
24539
+ * @param nonCommitmentLines - Plain source lines to append to when no block is active.
24540
+ *
24541
+ * @private internal utility of `parseAgentSourceWithCommitments`
24542
+ */
24543
+ function appendLineToCurrentCommitmentOrNonCommitmentLines(currentCommitment, line, nonCommitmentLines) {
24544
+ if (!currentCommitment) {
24545
+ nonCommitmentLines.push(line);
24546
+ return;
24547
+ }
24548
+ if (currentCommitment.kind === 'unknown') {
24549
+ currentCommitment.sourceLines.push(line);
24550
+ return;
24551
+ }
24552
+ currentCommitment.contentLines.push(line);
24553
+ }
24512
24554
 
24513
24555
  /**
24514
24556
  * Plugin for importing agent books *(`.book` files)*
@@ -24646,7 +24688,8 @@ async function augmentAgentModelRequirementsFromSource(requirements, parseResult
24646
24688
  requirements = await importReferencedFiles(requirements);
24647
24689
  requirements = appendMcpServers(requirements, agentSource);
24648
24690
  requirements = appendNonCommitmentContent(requirements, parseResult);
24649
- return appendExampleInteractions(requirements, parseResult);
24691
+ requirements = appendExampleInteractions(requirements, parseResult);
24692
+ return appendUnknownCommitmentContent(requirements, parseResult);
24650
24693
  }
24651
24694
  /**
24652
24695
  * Imports text files referenced by IMPORT commitments and appends their transformed content to the system message.
@@ -24768,6 +24811,36 @@ function appendNonCommitmentContent(requirements, parseResult) {
24768
24811
  }
24769
24812
  return appendSystemMessageSection(requirements, nonCommitmentContent);
24770
24813
  }
24814
+ /**
24815
+ * Appends unknown commitment blocks as final extra context without applying commitment side effects.
24816
+ *
24817
+ * @param requirements - Current requirements snapshot.
24818
+ * @param parseResult - Parsed source including unknown commitment blocks.
24819
+ * @returns Requirements with unknown commitment context appended at the end of the system message.
24820
+ *
24821
+ * @private internal utility of `augmentAgentModelRequirementsFromSource`
24822
+ */
24823
+ function appendUnknownCommitmentContent(requirements, parseResult) {
24824
+ const unknownCommitmentContent = getUnknownCommitmentContent(parseResult);
24825
+ if (!unknownCommitmentContent) {
24826
+ return requirements;
24827
+ }
24828
+ return appendSystemMessageSection(requirements, unknownCommitmentContent);
24829
+ }
24830
+ /**
24831
+ * Joins unknown commitment blocks into their final extra-context representation.
24832
+ *
24833
+ * @param parseResult - Parsed source including unknown commitment blocks.
24834
+ * @returns Unknown commitment source blocks in their original order.
24835
+ *
24836
+ * @private internal utility of `appendUnknownCommitmentContent`
24837
+ */
24838
+ function getUnknownCommitmentContent(parseResult) {
24839
+ return parseResult.unknownCommitments
24840
+ .map((commitment) => commitment.source)
24841
+ .filter(Boolean)
24842
+ .join('\n\n');
24843
+ }
24771
24844
  /**
24772
24845
  * Collects plain-text lines that were not parsed as commitments and should still become part of the final system message.
24773
24846
  *