@promptbook/wizard 0.103.0-51 → 0.103.0-52

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/esm/index.es.js CHANGED
@@ -36,7 +36,7 @@ const BOOK_LANGUAGE_VERSION = '2.0.0';
36
36
  * @generated
37
37
  * @see https://github.com/webgptorg/promptbook
38
38
  */
39
- const PROMPTBOOK_ENGINE_VERSION = '0.103.0-51';
39
+ const PROMPTBOOK_ENGINE_VERSION = '0.103.0-52';
40
40
  /**
41
41
  * TODO: string_promptbook_version should be constrained to the all versions of Promptbook engine
42
42
  * Note: [💞] Ignore a discrepancy between file name and entity name
@@ -13418,9 +13418,13 @@ const _FormattedBookInMarkdownTranspilerRegistration = $bookTranspilersRegister.
13418
13418
  *
13419
13419
  * @private - TODO: [🧠] Maybe should be public?
13420
13420
  */
13421
- function createCommitmentRegex(commitment) {
13422
- const escapedCommitment = commitment.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
13423
- const keywordPattern = escapedCommitment.split(/\s+/).join('\\s+');
13421
+ function createCommitmentRegex(commitment, aliases = []) {
13422
+ const allCommitments = [commitment, ...aliases];
13423
+ const patterns = allCommitments.map((c) => {
13424
+ const escapedCommitment = c.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
13425
+ return escapedCommitment.split(/\s+/).join('\\s+');
13426
+ });
13427
+ const keywordPattern = patterns.join('|');
13424
13428
  const regex = new RegExp(`^\\s*(?<type>${keywordPattern})\\b\\s+(?<contents>.+)$`, 'gim');
13425
13429
  return regex;
13426
13430
  }
@@ -13433,9 +13437,13 @@ function createCommitmentRegex(commitment) {
13433
13437
  *
13434
13438
  * @private
13435
13439
  */
13436
- function createCommitmentTypeRegex(commitment) {
13437
- const escapedCommitment = commitment.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
13438
- const keywordPattern = escapedCommitment.split(/\s+/).join('\\s+');
13440
+ function createCommitmentTypeRegex(commitment, aliases = []) {
13441
+ const allCommitments = [commitment, ...aliases];
13442
+ const patterns = allCommitments.map((c) => {
13443
+ const escapedCommitment = c.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
13444
+ return escapedCommitment.split(/\s+/).join('\\s+');
13445
+ });
13446
+ const keywordPattern = patterns.join('|');
13439
13447
  const regex = new RegExp(`^\\s*(?<type>${keywordPattern})\\b`, 'gim');
13440
13448
  return regex;
13441
13449
  }
@@ -13447,22 +13455,23 @@ function createCommitmentTypeRegex(commitment) {
13447
13455
  * @private
13448
13456
  */
13449
13457
  class BaseCommitmentDefinition {
13450
- constructor(type) {
13458
+ constructor(type, aliases = []) {
13451
13459
  this.type = type;
13460
+ this.aliases = aliases;
13452
13461
  }
13453
13462
  /**
13454
13463
  * Creates a regex pattern to match this commitment in agent source
13455
13464
  * Uses the existing createCommitmentRegex function as internal helper
13456
13465
  */
13457
13466
  createRegex() {
13458
- return createCommitmentRegex(this.type);
13467
+ return createCommitmentRegex(this.type, this.aliases);
13459
13468
  }
13460
13469
  /**
13461
13470
  * Creates a regex pattern to match just the commitment type
13462
13471
  * Uses the existing createCommitmentTypeRegex function as internal helper
13463
13472
  */
13464
13473
  createTypeRegex() {
13465
- return createCommitmentTypeRegex(this.type);
13474
+ return createCommitmentTypeRegex(this.type, this.aliases);
13466
13475
  }
13467
13476
  /**
13468
13477
  * Helper method to create a new requirements object with updated system message
@@ -14374,6 +14383,165 @@ class MetaCommitmentDefinition extends BaseCommitmentDefinition {
14374
14383
  * Note: [💞] Ignore a discrepancy between file name and entity name
14375
14384
  */
14376
14385
 
14386
+ /**
14387
+ * META COLOR commitment definition
14388
+ *
14389
+ * The META COLOR commitment sets the agent's accent color.
14390
+ * This commitment is special because it doesn't affect the system message,
14391
+ * but is handled separately in the parsing logic.
14392
+ *
14393
+ * Example usage in agent source:
14394
+ *
14395
+ * ```book
14396
+ * META COLOR #ff0000
14397
+ * META COLOR #00ff00
14398
+ * ```
14399
+ *
14400
+ * @private [🪔] Maybe export the commitments through some package
14401
+ */
14402
+ class MetaColorCommitmentDefinition extends BaseCommitmentDefinition {
14403
+ constructor() {
14404
+ super('META COLOR', ['COLOR']);
14405
+ }
14406
+ /**
14407
+ * Short one-line description of META COLOR.
14408
+ */
14409
+ get description() {
14410
+ return "Set the agent's accent color.";
14411
+ }
14412
+ /**
14413
+ * Markdown documentation for META COLOR commitment.
14414
+ */
14415
+ get documentation() {
14416
+ return spaceTrim$1(`
14417
+ # META COLOR
14418
+
14419
+ Sets the agent's accent color.
14420
+
14421
+ ## Key aspects
14422
+
14423
+ - Does not modify the agent's behavior or responses.
14424
+ - Only one \`META COLOR\` should be used per agent.
14425
+ - If multiple are specified, the last one takes precedence.
14426
+ - Used for visual representation in user interfaces.
14427
+
14428
+ ## Examples
14429
+
14430
+ \`\`\`book
14431
+ Professional Assistant
14432
+
14433
+ META COLOR #3498db
14434
+ PERSONA You are a professional business assistant
14435
+ \`\`\`
14436
+
14437
+ \`\`\`book
14438
+ Creative Helper
14439
+
14440
+ META COLOR #e74c3c
14441
+ PERSONA You are a creative and inspiring assistant
14442
+ \`\`\`
14443
+ `);
14444
+ }
14445
+ applyToAgentModelRequirements(requirements, content) {
14446
+ // META COLOR doesn't modify the system message or model requirements
14447
+ // It's handled separately in the parsing logic for profile color extraction
14448
+ // This method exists for consistency with the CommitmentDefinition interface
14449
+ return requirements;
14450
+ }
14451
+ /**
14452
+ * Extracts the profile color from the content
14453
+ * This is used by the parsing logic
14454
+ */
14455
+ extractProfileColor(content) {
14456
+ const trimmedContent = content.trim();
14457
+ return trimmedContent || null;
14458
+ }
14459
+ }
14460
+ /**
14461
+ * Note: [💞] Ignore a discrepancy between file name and entity name
14462
+ */
14463
+
14464
+ /**
14465
+ * META IMAGE commitment definition
14466
+ *
14467
+ * The META IMAGE commitment sets the agent's avatar/profile image URL.
14468
+ * This commitment is special because it doesn't affect the system message,
14469
+ * but is handled separately in the parsing logic.
14470
+ *
14471
+ * Example usage in agent source:
14472
+ *
14473
+ * ```book
14474
+ * META IMAGE https://example.com/avatar.jpg
14475
+ * META IMAGE /assets/agent-avatar.png
14476
+ * ```
14477
+ *
14478
+ * @private [🪔] Maybe export the commitments through some package
14479
+ */
14480
+ class MetaImageCommitmentDefinition extends BaseCommitmentDefinition {
14481
+ constructor() {
14482
+ super('META IMAGE', ['IMAGE']);
14483
+ }
14484
+ /**
14485
+ * Short one-line description of META IMAGE.
14486
+ */
14487
+ get description() {
14488
+ return "Set the agent's profile image URL.";
14489
+ }
14490
+ /**
14491
+ * Markdown documentation for META IMAGE commitment.
14492
+ */
14493
+ get documentation() {
14494
+ return spaceTrim$1(`
14495
+ # META IMAGE
14496
+
14497
+ Sets the agent's avatar/profile image URL.
14498
+
14499
+ ## Key aspects
14500
+
14501
+ - Does not modify the agent's behavior or responses.
14502
+ - Only one \`META IMAGE\` should be used per agent.
14503
+ - If multiple are specified, the last one takes precedence.
14504
+ - Used for visual representation in user interfaces.
14505
+
14506
+ ## Examples
14507
+
14508
+ \`\`\`book
14509
+ Professional Assistant
14510
+
14511
+ META IMAGE https://example.com/professional-avatar.jpg
14512
+ PERSONA You are a professional business assistant
14513
+ STYLE Maintain a formal and courteous tone
14514
+ \`\`\`
14515
+
14516
+ \`\`\`book
14517
+ Creative Helper
14518
+
14519
+ META IMAGE /assets/creative-bot-avatar.png
14520
+ PERSONA You are a creative and inspiring assistant
14521
+ STYLE Be enthusiastic and encouraging
14522
+ ACTION Can help with brainstorming and ideation
14523
+ \`\`\`
14524
+ `);
14525
+ }
14526
+ applyToAgentModelRequirements(requirements, content) {
14527
+ // META IMAGE doesn't modify the system message or model requirements
14528
+ // It's handled separately in the parsing logic for profile image extraction
14529
+ // This method exists for consistency with the CommitmentDefinition interface
14530
+ return requirements;
14531
+ }
14532
+ /**
14533
+ * Extracts the profile image URL from the content
14534
+ * This is used by the parsing logic
14535
+ */
14536
+ extractProfileImageUrl(content) {
14537
+ const trimmedContent = content.trim();
14538
+ return trimmedContent || null;
14539
+ }
14540
+ }
14541
+ /**
14542
+ * Note: [💞] Ignore a discrepancy between file name and entity name
14543
+ */
14544
+
14377
14545
  /**
14378
14546
  * MODEL commitment definition
14379
14547
  *
@@ -15281,6 +15449,8 @@ const COMMITMENT_REGISTRY = [
15281
15449
  new ModelCommitmentDefinition('MODELS'),
15282
15450
  new ActionCommitmentDefinition('ACTION'),
15283
15451
  new ActionCommitmentDefinition('ACTIONS'),
15452
+ new MetaImageCommitmentDefinition(),
15453
+ new MetaColorCommitmentDefinition(),
15284
15454
  new MetaCommitmentDefinition(),
15285
15455
  new NoteCommitmentDefinition('NOTE'),
15286
15456
  new NoteCommitmentDefinition('NOTES'),
@@ -16114,6 +16284,14 @@ function parseAgentSource(agentSource) {
16114
16284
  links.push(spaceTrim(commitment.content));
16115
16285
  continue;
16116
16286
  }
16287
+ if (commitment.type === 'META IMAGE') {
16288
+ meta.image = spaceTrim(commitment.content);
16289
+ continue;
16290
+ }
16291
+ if (commitment.type === 'META COLOR') {
16292
+ meta.color = spaceTrim(commitment.content);
16293
+ continue;
16294
+ }
16117
16295
  if (commitment.type !== 'META') {
16118
16296
  continue;
16119
16297
  }
@@ -16129,6 +16307,10 @@ function parseAgentSource(agentSource) {
16129
16307
  if (!meta.image) {
16130
16308
  meta.image = generatePlaceholderAgentProfileImageUrl(parseResult.agentName || '!!');
16131
16309
  }
16310
+ // Generate fullname fallback if no meta fullname specified
16311
+ if (!meta.fullname) {
16312
+ meta.fullname = parseResult.agentName || createDefaultAgentName(agentSource);
16313
+ }
16132
16314
  // Parse parameters using unified approach - both @Parameter and {parameter} notations
16133
16315
  // are treated as the same syntax feature with unified representation
16134
16316
  const parameters = parseParameters(agentSource);