@promptbook/core 0.114.0-0 → 0.114.0-2

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
@@ -28,7 +28,7 @@ const BOOK_LANGUAGE_VERSION = '2.0.0';
28
28
  * @generated
29
29
  * @see https://github.com/webgptorg/promptbook
30
30
  */
31
- const PROMPTBOOK_ENGINE_VERSION = '0.114.0-0';
31
+ const PROMPTBOOK_ENGINE_VERSION = '0.114.0-2';
32
32
  /**
33
33
  * TODO: string_promptbook_version should be constrained to the all versions of Promptbook engine
34
34
  * Note: [💞] Ignore a discrepancy between file name and entity name
@@ -29676,13 +29676,12 @@ const bookLanguageDocumentationExamples = [
29676
29676
  `),
29677
29677
  },
29678
29678
  {
29679
- id: 'use-project-and-wallet-integration-agent',
29679
+ id: 'use-project-integration-agent',
29680
29680
  source: spaceTrim$1(`
29681
29681
  Repository Maintainer
29682
29682
 
29683
29683
  GOAL Maintain a GitHub repository and prepare safe pull requests.
29684
29684
  USE PROJECT https://github.com/acme/website
29685
- WALLET Store credentials for repository operations.
29686
29685
  RULE Before editing files, explain the planned change and impacted paths.
29687
29686
  RULE Never reveal raw credentials in chat output.
29688
29687
  INITIAL MESSAGE I can inspect the repository and help you prepare PR-ready changes.
@@ -29754,24 +29753,6 @@ const DEPRECATED_COMMITMENT_DETAIL_LABEL = 'Deprecated commitment';
29754
29753
  * Longer label used for unfinished and low-level commitments.
29755
29754
  */
29756
29755
  const LOW_LEVEL_COMMITMENT_DETAIL_LABEL = 'Low-level commitment';
29757
- /**
29758
- * Prefix used when formatting replacement guidance.
29759
- */
29760
- const PREFERRED_REPLACEMENT_LABEL = 'Preferred replacement';
29761
- /**
29762
- * Formats preferred replacement guidance for deprecated commitments.
29763
- *
29764
- * @param replacedBy - Preferred replacement commitment keywords.
29765
- * @returns Optional replacement guidance sentence with leading space.
29766
- *
29767
- * @private internal utility of commitment catalog notices
29768
- */
29769
- function formatCommitmentReplacementText(replacedBy) {
29770
- if (!replacedBy || replacedBy.length === 0) {
29771
- return '';
29772
- }
29773
- return ` ${PREFERRED_REPLACEMENT_LABEL}: ${replacedBy.map((type) => `\`${type}\``).join(', ')}.`;
29774
- }
29775
29756
  /**
29776
29757
  * Returns true when one commitment notice should be rendered with low-visibility styling.
29777
29758
  *
@@ -29837,6 +29818,10 @@ function getBookLanguageManualCommitmentGroups() {
29837
29818
  if ((notice === null || notice === void 0 ? void 0 : notice.kind) === 'deprecated') {
29838
29819
  continue;
29839
29820
  }
29821
+ if (groupedCommitment.primary instanceof NotYetImplementedCommitmentDefinition ||
29822
+ groupedCommitment.primary.isUnfinished) {
29823
+ continue;
29824
+ }
29840
29825
  if (isLowVisibilityCommitmentNotice(notice)) {
29841
29826
  lowLevel.push(groupedCommitment);
29842
29827
  continue;
@@ -29864,9 +29849,7 @@ const czechBookLanguageManualDictionary = {
29864
29849
  metadataLabels: {
29865
29850
  bookLanguageVersion: 'Verze jazyka Book',
29866
29851
  generatedAt: 'Vygenerováno',
29867
- commitmentGroups: 'Skupin commitmentů',
29868
- implementedCommitments: 'Hotových commitmentů',
29869
- placeholderCommitments: 'Připravovaných commitmentů',
29852
+ commitmentCount: 'Počet commitmentů',
29870
29853
  },
29871
29854
  tableOfContentsTitle: 'Obsah',
29872
29855
  chapters: {
@@ -29928,15 +29911,7 @@ const czechBookLanguageManualDictionary = {
29928
29911
  commitmentCatalog: {
29929
29912
  title: 'Katalog commitmentů',
29930
29913
  body: spaceTrim$1(`
29931
- Tato kapitola se generuje z definic commitmentů v \`src/commitments\`.
29932
- U každé skupiny commitmentů najdete:
29933
-
29934
- - shrnutí významu (popis, ikona, stav)
29935
- - schéma pro parsování (\`createTypeRegex\` a \`createRegex\`)
29936
- - úplnou dokumentaci
29937
-
29938
- Klíčová slova commitmentů jsou součástí syntaxe, a proto zůstávají anglicky.
29939
- Anglicky zůstávají i jejich referenční popisy, které jsou závaznou specifikací jazyka.
29914
+ Každá sekce commitmentu vysvětluje jeho účel, důležité podrobnosti a ukazuje soustředěný příklad.
29940
29915
  `),
29941
29916
  },
29942
29917
  examples: {
@@ -30023,41 +29998,28 @@ const czechBookLanguageManualDictionary = {
30023
29998
  První neprázdný řádek, který není klíčovým slovem commitmentu.
30024
29999
  2. **Blok commitmentu**:
30025
30000
  Začíná klíčovým slovem commitmentu a pokračuje až k dalšímu commitmentu nebo oddělovači.
30026
- 3. **Vodorovný oddělovač**:
30027
- Řádky jako \`---\` dělí zdroj na části; v Agents Serveru jimi lze oddělit agenty vložené přímo v knize.
30001
+ 3. **Více agentů**:
30002
+ Řádky jako \`---\` oddělují agenty definované ve stejném zdroji Booku.
30028
30003
  4. **Bloky kódu**:
30029
- Uvnitř obsahu commitmentu zůstávají zachované; hodí se pro ukázky a instrukce.
30030
- 5. **Parametry**:
30031
- Podporovaný a rozpoznávaný je zápis \`@parametr\` i \`{parametr}\`.
30004
+ Začínají a končí pomocí <code>\`\`\`</code>; jejich obsah zůstává uvnitř commitmentu zachovaný a hodí se pro ukázky a instrukce.
30032
30005
  `),
30033
30006
  },
30034
30007
  references: {
30035
30008
  title: 'Odkazy a zástupní agenti',
30036
30009
  body: spaceTrim$1(`
30037
- - Zkrácené odkazy jako \`{Jméno agenta}\` vyhodnocuje resolver odkazů v Agents Serveru.
30010
+ - \`@Foo\` a \`{Foo foo}\` odkazují na jiného agenta; nejde o zápis parametrů.
30011
+ - Zkrácené odkazy jako \`@Jméno agenta\` a \`{Jméno agenta}\` vyhodnocuje resolver odkazů v Agents Serveru.
30038
30012
  - V příslušných commitmentech lze použít i zástupné agenty (například \`{User}\` nebo \`{Void}\`).
30039
30013
  - \`{User}\` je určený pro \`TEAM\`; \`{Void}\` se hodí pro výslovné zrušení dědičnosti.
30040
30014
  `),
30041
30015
  },
30042
- keywordsTitle: 'Aktuálně rozpoznávaná klíčová slova commitmentů',
30043
30016
  },
30044
30017
  commitmentCatalogTitleSuffixes: {
30045
30018
  usedFirst: ' (nejdřív používané commitmenty)',
30046
30019
  all: ' (všechny commitmenty)',
30047
30020
  },
30048
30021
  commitmentLabels: {
30049
- status: 'Stav',
30050
30022
  aliases: 'Varianty zápisu',
30051
- semantics: 'Význam',
30052
- typeSchema: 'Schéma klíčového slova',
30053
- blockSchema: 'Schéma bloku',
30054
- lowLevelNotice: 'Nízkoúrovňový commitment',
30055
- usage: 'Použití u vybraných agentů',
30056
- usageOccurrence: 'výskyt',
30057
- usageOccurrences: 'výskytů',
30058
- statusImplemented: 'Hotovo',
30059
- statusPlaceholder: 'Připravuje se (zatím není plně hotové)',
30060
- noAliases: 'Žádné',
30061
30023
  },
30062
30024
  exampleLabels: {
30063
30025
  commitmentsUsed: 'Použité commitmenty',
@@ -30107,14 +30069,14 @@ const czechBookLanguageManualDictionary = {
30107
30069
  'Hodí se pro asistenty, kteří si musí držet kontext v čase.',
30108
30070
  ],
30109
30071
  },
30110
- 'use-project-and-wallet-integration-agent': {
30111
- title: 'Napojení na projekt (USE PROJECT) a peněženku',
30112
- goal: 'Pracovat s repozitáři na GitHubu a s přihlašovacími údaji z peněženky.',
30072
+ 'use-project-integration-agent': {
30073
+ title: 'Napojení na projekt (USE PROJECT)',
30074
+ goal: 'Pracovat s repozitářem na GitHubu přes připojení projektu.',
30113
30075
  walkthrough: [
30114
30076
  '`USE PROJECT` zapne nástroje pro výpis, čtení a úpravy souborů a pro zakládání pull requestů.',
30115
30077
  'Přihlašovací údaje se v Agents Serveru za běhu načtou ze záznamů v peněžence.',
30116
- '`WALLET` je zde ponechaný jen kvůli zpětné kompatibilitě, aktuální parsování Book 2.0 ho ignoruje.',
30117
- 'V současném chování zajišťují napojení s přihlašovacími údaji commitmenty jako `USE PROJECT` a `USE EMAIL`.',
30078
+ 'Agent má také výslovná pravidla pro bezpečné úpravy a práci s přihlašovacími údaji.',
30079
+ 'Tento vzor použijte, když agent potřebuje soustředěný přístup k repozitáři.',
30118
30080
  ],
30119
30081
  },
30120
30082
  'use-calendar-integration-agent': {
@@ -30184,10 +30146,10 @@ const czechBookLanguageManualDictionary = {
30184
30146
  footer: {
30185
30147
  title: 'Vygenerováno z:',
30186
30148
  body: spaceTrim$1(`
30187
- - Registru commitmentů a běhové dokumentace v \`src/commitments\`
30188
- - Chování parseru a překladače v \`src/book-2.0/agent-source\`
30189
- - Vyhodnocení odkazů a dědičnosti v Agents Serveru v \`apps/agents-server/src/utils\`
30190
- - Zdrojových bloků samostatné dokumentace v \`apps/agents-server/src/utils/bookLanguageDocumentation\`
30149
+ - [Registru commitmentů a běhové dokumentace](https://github.com/webgptorg/promptbook/tree/main/src/commitments)
30150
+ - [Parseru jazyka Book a práce se zdrojem](https://github.com/webgptorg/promptbook/tree/main/src/book-2.0/agent-source)
30151
+ - [Vyhodnocení odkazů a dědičnosti v Agents Serveru](https://github.com/webgptorg/promptbook/tree/main/apps/agents-server/src/utils)
30152
+ - [Zdrojových kódů samostatné příručky](https://github.com/webgptorg/promptbook/tree/main/src/book-2.0/book-language-documentation)
30191
30153
  `),
30192
30154
  },
30193
30155
  };
@@ -30210,9 +30172,7 @@ const englishBookLanguageManualDictionary = {
30210
30172
  metadataLabels: {
30211
30173
  bookLanguageVersion: 'Book language version',
30212
30174
  generatedAt: 'Generated at',
30213
- commitmentGroups: 'Commitment groups',
30214
- implementedCommitments: 'Implemented commitments',
30215
- placeholderCommitments: 'Placeholder commitments',
30175
+ commitmentCount: 'Number of commitments',
30216
30176
  },
30217
30177
  tableOfContentsTitle: 'Table of Contents',
30218
30178
  chapters: {
@@ -30274,12 +30234,7 @@ const englishBookLanguageManualDictionary = {
30274
30234
  commitmentCatalog: {
30275
30235
  title: 'Commitment catalog',
30276
30236
  body: spaceTrim$1(`
30277
- This section is generated from commitment definitions in \`src/commitments\`.
30278
- For each commitment group you get:
30279
-
30280
- - semantics summary (description/icon/status)
30281
- - parsing schema (\`createTypeRegex\` and \`createRegex\`)
30282
- - canonical documentation block
30237
+ Each commitment section explains its purpose, important details, and a focused example.
30283
30238
  `),
30284
30239
  },
30285
30240
  examples: {
@@ -30366,41 +30321,28 @@ const englishBookLanguageManualDictionary = {
30366
30321
  First non-empty line that is not a commitment keyword.
30367
30322
  2. **Commitment block**:
30368
30323
  Starts with a commitment keyword and continues until the next commitment block or separator.
30369
- 3. **Horizontal separator**:
30370
- Lines like \`---\` split sections; in Agents Server they can delimit embedded in-book agents.
30324
+ 3. **Multiple agent**:
30325
+ Lines like \`---\` separate agents defined in the same Book source.
30371
30326
  4. **Code fences**:
30372
- Preserved inside commitment content; useful for examples/instructions.
30373
- 5. **Parameters**:
30374
- Both \`@parameter\` and \`{parameter}\` notations are supported and parsed.
30327
+ Start and end with <code>\`\`\`</code>; their content is preserved inside commitments and is useful for examples and instructions.
30375
30328
  `),
30376
30329
  },
30377
30330
  references: {
30378
30331
  title: 'Reference tokens and pseudo-agents',
30379
30332
  body: spaceTrim$1(`
30380
- - Compact references like \`{Agent Name}\` are resolved by Agents Server reference resolver.
30333
+ - \`@Foo\` and \`{Foo foo}\` reference another agent; they are not parameter notation.
30334
+ - Compact references like \`@Agent Name\` and \`{Agent Name}\` are resolved by the Agents Server reference resolver.
30381
30335
  - Pseudo-agent forms (for example \`{User}\`, \`{Void}\`) are supported in relevant commitments.
30382
30336
  - \`{User}\` is intended for \`TEAM\`; \`{Void}\` is useful for explicit no-parent inheritance.
30383
30337
  `),
30384
30338
  },
30385
- keywordsTitle: 'Commitment keywords currently recognized',
30386
30339
  },
30387
30340
  commitmentCatalogTitleSuffixes: {
30388
30341
  usedFirst: ' (used commitments first)',
30389
30342
  all: ' (all commitments)',
30390
30343
  },
30391
30344
  commitmentLabels: {
30392
- status: 'Status',
30393
30345
  aliases: 'Aliases',
30394
- semantics: 'Semantics',
30395
- typeSchema: 'Type schema',
30396
- blockSchema: 'Block schema',
30397
- lowLevelNotice: 'Low-level commitment',
30398
- usage: 'Used in selected agents',
30399
- usageOccurrence: 'occurrence',
30400
- usageOccurrences: 'occurrences',
30401
- statusImplemented: 'Implemented',
30402
- statusPlaceholder: 'Placeholder (not fully implemented)',
30403
- noAliases: 'None',
30404
30346
  },
30405
30347
  exampleLabels: {
30406
30348
  commitmentsUsed: 'Commitments used',
@@ -30450,14 +30392,14 @@ const englishBookLanguageManualDictionary = {
30450
30392
  'Use this for assistants that must preserve context over time.',
30451
30393
  ],
30452
30394
  },
30453
- 'use-project-and-wallet-integration-agent': {
30454
- title: 'USE PROJECT and WALLET external integration',
30455
- goal: 'Work with GitHub repositories and wallet-backed credentials.',
30395
+ 'use-project-integration-agent': {
30396
+ title: 'USE PROJECT external integration',
30397
+ goal: 'Work with a GitHub repository through a connected project integration.',
30456
30398
  walkthrough: [
30457
30399
  '`USE PROJECT` enables repository tools for listing, reading, editing files, and creating PRs.',
30458
30400
  'Credentials are resolved from wallet records at runtime in Agents Server.',
30459
- '`WALLET` is kept here as a compatibility marker, but current Book 2.0 parsing treats it as ignored.',
30460
- 'In current runtime behavior, wallet-backed integrations are driven by commitments such as `USE PROJECT` and `USE EMAIL`.',
30401
+ 'The agent also defines explicit rules for safe editing and credential handling.',
30402
+ 'Use this pattern when an agent needs focused repository access.',
30461
30403
  ],
30462
30404
  },
30463
30405
  'use-calendar-integration-agent': {
@@ -30527,10 +30469,10 @@ const englishBookLanguageManualDictionary = {
30527
30469
  footer: {
30528
30470
  title: 'Generated from:',
30529
30471
  body: spaceTrim$1(`
30530
- - Commitments registry and runtime docs in \`src/commitments\`
30531
- - Parser/compiler behavior in \`src/book-2.0/agent-source\`
30532
- - Agents Server reference/inheritance resolution in \`apps/agents-server/src/utils\`
30533
- - Standalone docs source blocks in \`apps/agents-server/src/utils/bookLanguageDocumentation\`
30472
+ - [Commitments registry and runtime documentation](https://github.com/webgptorg/promptbook/tree/main/src/commitments)
30473
+ - [Book language parser and source handling](https://github.com/webgptorg/promptbook/tree/main/src/book-2.0/agent-source)
30474
+ - [Agents Server reference and inheritance resolution](https://github.com/webgptorg/promptbook/tree/main/apps/agents-server/src/utils)
30475
+ - [Standalone manual source](https://github.com/webgptorg/promptbook/tree/main/src/book-2.0/book-language-documentation)
30534
30476
  `),
30535
30477
  },
30536
30478
  };
@@ -30579,6 +30521,28 @@ function getSafeCodeBlock(content, language = 'markdown') {
30579
30521
  return `${fence}${language}\n${content}\n${fence}`;
30580
30522
  }
30581
30523
 
30524
+ /**
30525
+ * Gets all available commitment definitions
30526
+ *
30527
+ * @returns Array of all commitment definitions
30528
+ *
30529
+ * @public exported from `@promptbook/core`
30530
+ */
30531
+ function getAllCommitmentDefinitions() {
30532
+ return $deepFreeze(sortCommitmentDefinitions(COMMITMENT_REGISTRY, { isUnfinishedLast: true, isLowLevelLast: true }));
30533
+ }
30534
+
30535
+ /**
30536
+ * Gets all available commitment types
30537
+ *
30538
+ * @returns Array of all commitment types
30539
+ *
30540
+ * @public exported from `@promptbook/core`
30541
+ */
30542
+ function getAllCommitmentTypes() {
30543
+ return $deepFreeze(getAllCommitmentDefinitions().map((commitmentDefinition) => commitmentDefinition.type));
30544
+ }
30545
+
30582
30546
  /**
30583
30547
  * Deepest heading level markdown supports.
30584
30548
  *
@@ -30652,6 +30616,19 @@ const CLOSED_COMMITMENT_TYPE = 'CLOSED';
30652
30616
  * @private internal utility of `createStandaloneBookLanguageMarkdown`
30653
30617
  */
30654
30618
  const COMMITMENT_DOCUMENTATION_SECTION_HEADING_LEVEL = 2;
30619
+ /**
30620
+ * Markdown code blocks whose Book source is shown as a commitment example.
30621
+ *
30622
+ * @private internal utility of `createStandaloneBookLanguageMarkdown`
30623
+ */
30624
+ const BOOK_CODE_BLOCK_PATTERN = /(`{3,})book[^\n]*\n([\s\S]*?)\n\1/gu;
30625
+ /**
30626
+ * Recognized commitment types, ordered so compound keywords take priority over
30627
+ * their shorter prefixes when reducing an example line by line.
30628
+ *
30629
+ * @private internal utility of `createStandaloneBookLanguageMarkdown`
30630
+ */
30631
+ const COMMITMENT_TYPES_BY_LENGTH = [...getAllCommitmentTypes()].sort((firstType, secondType) => secondType.length - firstType.length);
30655
30632
  /**
30656
30633
  * Removes the top-level heading from one commitment documentation block.
30657
30634
  *
@@ -30668,17 +30645,18 @@ function removeLeadingTopLevelHeading(markdown) {
30668
30645
  *
30669
30646
  * @param title - Heading label for the subsection.
30670
30647
  * @param documentation - Raw commitment documentation markdown.
30648
+ * @param group - Commitment family represented by the documentation entry.
30671
30649
  * @param headingLevelShift - How many levels the whole entry is nested by its host document.
30672
30650
  * @returns Markdown subsection introducing one commitment of the family.
30673
30651
  *
30674
30652
  * @private internal utility of `createStandaloneBookLanguageMarkdown`
30675
30653
  */
30676
- function renderDocumentationSection(title, documentation, headingLevelShift) {
30654
+ function renderDocumentationSection(title, documentation, group, headingLevelShift) {
30677
30655
  const headingPrefix = '#'.repeat(COMMITMENT_DOCUMENTATION_SECTION_HEADING_LEVEL + headingLevelShift);
30678
30656
  return spaceTrim$1((block) => `
30679
30657
  ${headingPrefix} ${title}
30680
30658
 
30681
- ${block(shiftMarkdownHeadingLevels(removeLeadingTopLevelHeading(documentation), headingLevelShift + 1))}
30659
+ ${block(shiftMarkdownHeadingLevels(removeLeadingTopLevelHeading(renderFocusedCommitmentExamples(documentation, group)), headingLevelShift + 1))}
30682
30660
  `);
30683
30661
  }
30684
30662
  /**
@@ -30695,18 +30673,199 @@ function renderDocumentationSection(title, documentation, headingLevelShift) {
30695
30673
  */
30696
30674
  function renderGroupedCommitmentDocumentationMarkdown(group, headingLevelShift = 0) {
30697
30675
  const commitmentTypes = new Set([group.primary.type, ...group.aliases]);
30698
- if (commitmentTypes.has(OPEN_COMMITMENT_TYPE) && commitmentTypes.has(CLOSED_COMMITMENT_TYPE)) {
30676
+ const isOpenClosedCommitmentFamily = commitmentTypes.has(OPEN_COMMITMENT_TYPE) && commitmentTypes.has(CLOSED_COMMITMENT_TYPE);
30677
+ if (isOpenClosedCommitmentFamily) {
30699
30678
  const openCommitmentDefinition = getCommitmentDefinition(OPEN_COMMITMENT_TYPE);
30700
30679
  const closedCommitmentDefinition = getCommitmentDefinition(CLOSED_COMMITMENT_TYPE);
30701
30680
  if (openCommitmentDefinition && closedCommitmentDefinition) {
30702
30681
  return spaceTrim$1((block) => `
30703
- ${block(renderDocumentationSection(OPEN_COMMITMENT_TYPE, openCommitmentDefinition.documentation, headingLevelShift))}
30682
+ ${block(renderDocumentationSection(OPEN_COMMITMENT_TYPE, openCommitmentDefinition.documentation, group, headingLevelShift))}
30704
30683
 
30705
- ${block(renderDocumentationSection(CLOSED_COMMITMENT_TYPE, closedCommitmentDefinition.documentation, headingLevelShift))}
30684
+ ${block(renderDocumentationSection(CLOSED_COMMITMENT_TYPE, closedCommitmentDefinition.documentation, group, headingLevelShift))}
30706
30685
  `);
30707
30686
  }
30708
30687
  }
30709
- return shiftMarkdownHeadingLevels(removeLeadingTopLevelHeading(group.primary.documentation), headingLevelShift);
30688
+ return shiftMarkdownHeadingLevels(removeLeadingTopLevelHeading(renderFocusedCommitmentExamples(group.primary.documentation, group)), headingLevelShift);
30689
+ }
30690
+ /**
30691
+ * Rewrites Book examples in commitment documentation to show one canonical
30692
+ * commitment in isolation, with only `GOAL` and `CLOSED` as supporting syntax.
30693
+ *
30694
+ * @param documentation - Raw commitment documentation markdown.
30695
+ * @param group - Commitment family represented by the documentation entry.
30696
+ * @returns Documentation whose Book examples use focused canonical syntax.
30697
+ *
30698
+ * @private internal utility of `createStandaloneBookLanguageMarkdown`
30699
+ */
30700
+ function renderFocusedCommitmentExamples(documentation, group) {
30701
+ return documentation.replace(BOOK_CODE_BLOCK_PATTERN, (codeBlock, _fence, source) => {
30702
+ const focusedSource = createFocusedCommitmentExampleSource(source, group);
30703
+ return focusedSource ? getSafeCodeBlock(focusedSource, 'book') : codeBlock;
30704
+ });
30705
+ }
30706
+ /**
30707
+ * Creates a focused Book source example for one commitment documentation entry.
30708
+ *
30709
+ * @param source - Original Book source from the commitment documentation.
30710
+ * @param group - Commitment family represented by the documentation entry.
30711
+ * @returns Focused source, or `null` when the source cannot be safely reduced.
30712
+ *
30713
+ * @private internal utility of `createStandaloneBookLanguageMarkdown`
30714
+ */
30715
+ function createFocusedCommitmentExampleSource(source, group) {
30716
+ const parsedSource = parseAgentSourceWithCommitments(source);
30717
+ const commitmentTypes = new Set([group.primary.type, ...group.aliases]);
30718
+ const isOpenClosedCommitmentFamily = commitmentTypes.has(OPEN_COMMITMENT_TYPE) && commitmentTypes.has(CLOSED_COMMITMENT_TYPE);
30719
+ const allowedCommitmentTypes = new Set([
30720
+ group.primary.type,
30721
+ ...group.aliases,
30722
+ 'GOAL',
30723
+ CLOSED_COMMITMENT_TYPE,
30724
+ ]);
30725
+ const canonicalTypeByCommitmentType = createCanonicalCommitmentTypeByCommitmentType(group, isOpenClosedCommitmentFamily);
30726
+ const focusedCommitments = parsedSource.commitments
30727
+ .filter((commitment) => allowedCommitmentTypes.has(commitment.type))
30728
+ .map((commitment) => {
30729
+ const type = canonicalTypeByCommitmentType.get(commitment.type) || commitment.type;
30730
+ return `${type}${commitment.content ? ` ${commitment.content}` : ''}`;
30731
+ });
30732
+ if (focusedCommitments.length > 0) {
30733
+ return finalizeFocusedCommitmentExampleSource(getFocusedExampleAgentName(parsedSource.agentName), focusedCommitments);
30734
+ }
30735
+ return createLineFocusedCommitmentExampleSource(source, group, isOpenClosedCommitmentFamily);
30736
+ }
30737
+ /**
30738
+ * Creates a focused example when the Book parser cannot recognize the target
30739
+ * commitment because it appears as the first source line or has a shared prefix.
30740
+ *
30741
+ * @param source - Original Book source from the documentation code block.
30742
+ * @param group - Commitment family represented by the documentation entry.
30743
+ * @param isOpenClosedCommitmentFamily - Whether the family contains both switch commitments.
30744
+ * @returns Focused source, or `null` when the source does not use this commitment family.
30745
+ *
30746
+ * @private internal utility of `createStandaloneBookLanguageMarkdown`
30747
+ */
30748
+ function createLineFocusedCommitmentExampleSource(source, group, isOpenClosedCommitmentFamily) {
30749
+ const sourceLines = source.split(/\r?\n/u);
30750
+ const allowedCommitmentTypes = new Set([group.primary.type, ...group.aliases, 'GOAL', CLOSED_COMMITMENT_TYPE]);
30751
+ const canonicalTypeByCommitmentType = createCanonicalCommitmentTypeByCommitmentType(group, isOpenClosedCommitmentFamily);
30752
+ const focusedCommitments = [];
30753
+ const firstSourceLine = sourceLines.find((line) => line.trim().length > 0) || null;
30754
+ const firstCommitmentType = firstSourceLine ? getCommitmentTypeAtLine(firstSourceLine) : null;
30755
+ const agentName = firstSourceLine && !firstCommitmentType ? firstSourceLine.trim() : null;
30756
+ let activeFocusedCommitmentIndex = null;
30757
+ let isInsideCodeBlock = false;
30758
+ for (const sourceLine of sourceLines) {
30759
+ const trimmedSourceLine = sourceLine.trim();
30760
+ if (trimmedSourceLine.startsWith('```')) {
30761
+ appendLineToActiveCommitment(focusedCommitments, activeFocusedCommitmentIndex, sourceLine);
30762
+ isInsideCodeBlock = !isInsideCodeBlock;
30763
+ continue;
30764
+ }
30765
+ if (isInsideCodeBlock) {
30766
+ appendLineToActiveCommitment(focusedCommitments, activeFocusedCommitmentIndex, sourceLine);
30767
+ continue;
30768
+ }
30769
+ const commitmentType = getCommitmentTypeAtLine(sourceLine);
30770
+ if (!commitmentType) {
30771
+ appendLineToActiveCommitment(focusedCommitments, activeFocusedCommitmentIndex, sourceLine);
30772
+ continue;
30773
+ }
30774
+ if (!allowedCommitmentTypes.has(commitmentType)) {
30775
+ activeFocusedCommitmentIndex = null;
30776
+ continue;
30777
+ }
30778
+ const canonicalType = canonicalTypeByCommitmentType.get(commitmentType) || commitmentType;
30779
+ const content = trimmedSourceLine.slice(commitmentType.length).trimStart();
30780
+ focusedCommitments.push(`${canonicalType}${content ? ` ${content}` : ''}`);
30781
+ activeFocusedCommitmentIndex = focusedCommitments.length - 1;
30782
+ }
30783
+ return finalizeFocusedCommitmentExampleSource(agentName, focusedCommitments);
30784
+ }
30785
+ /**
30786
+ * Finds the longest supported commitment keyword at the start of a source line.
30787
+ *
30788
+ * @param sourceLine - One Book source line to inspect.
30789
+ * @returns Matching commitment type, or `null` when the line is ordinary content.
30790
+ *
30791
+ * @private internal utility of `createStandaloneBookLanguageMarkdown`
30792
+ */
30793
+ function getCommitmentTypeAtLine(sourceLine) {
30794
+ const trimmedSourceLine = sourceLine.trim();
30795
+ return (COMMITMENT_TYPES_BY_LENGTH.find((commitmentType) => trimmedSourceLine === commitmentType || trimmedSourceLine.startsWith(`${commitmentType} `)) || null);
30796
+ }
30797
+ /**
30798
+ * Appends a source line only when a focused commitment currently owns it.
30799
+ *
30800
+ * @param focusedCommitments - Focused commitments assembled from the example.
30801
+ * @param activeFocusedCommitmentIndex - Index of the commitment receiving continuation lines.
30802
+ * @param sourceLine - Source line to append.
30803
+ *
30804
+ * @private internal utility of `createStandaloneBookLanguageMarkdown`
30805
+ */
30806
+ function appendLineToActiveCommitment(focusedCommitments, activeFocusedCommitmentIndex, sourceLine) {
30807
+ if (activeFocusedCommitmentIndex === null) {
30808
+ return;
30809
+ }
30810
+ focusedCommitments[activeFocusedCommitmentIndex] += `\n${sourceLine}`;
30811
+ }
30812
+ /**
30813
+ * Adds the standard closing marker and formats one reduced Book example.
30814
+ *
30815
+ * @param agentName - Optional human-readable title retained from the original example.
30816
+ * @param focusedCommitments - Canonical commitment blocks kept in the example.
30817
+ * @returns Focused source, or `null` when no relevant commitment was found.
30818
+ *
30819
+ * @private internal utility of `createStandaloneBookLanguageMarkdown`
30820
+ */
30821
+ function finalizeFocusedCommitmentExampleSource(agentName, focusedCommitments) {
30822
+ const normalizedFocusedCommitments = focusedCommitments.map((commitment) => commitment.trim());
30823
+ if (normalizedFocusedCommitments.length === 0) {
30824
+ return null;
30825
+ }
30826
+ const isClosedCommitmentIncluded = normalizedFocusedCommitments.some((commitment) => commitment.startsWith(CLOSED_COMMITMENT_TYPE));
30827
+ const isOpenCommitmentIncluded = normalizedFocusedCommitments.some((commitment) => commitment.startsWith(OPEN_COMMITMENT_TYPE));
30828
+ if (!isClosedCommitmentIncluded && !isOpenCommitmentIncluded) {
30829
+ normalizedFocusedCommitments.push(CLOSED_COMMITMENT_TYPE);
30830
+ }
30831
+ return [agentName, ...normalizedFocusedCommitments]
30832
+ .filter((line) => Boolean(line))
30833
+ .join('\n\n');
30834
+ }
30835
+ /**
30836
+ * Keeps an example title unless the parser interpreted a commitment-only
30837
+ * example's first line as its mandatory agent name.
30838
+ *
30839
+ * @param agentName - Parsed agent name from the original example.
30840
+ * @returns Agent title suitable for a focused example, or `null` when absent.
30841
+ *
30842
+ * @private internal utility of `createStandaloneBookLanguageMarkdown`
30843
+ */
30844
+ function getFocusedExampleAgentName(agentName) {
30845
+ if (!agentName || getCommitmentDefinition(agentName)) {
30846
+ return null;
30847
+ }
30848
+ return agentName;
30849
+ }
30850
+ /**
30851
+ * Maps aliases to the canonical keyword shown by a commitment example.
30852
+ *
30853
+ * `OPEN` and `CLOSED` share one documentation entry, but each remains a
30854
+ * distinct keyword and must therefore retain its own spelling.
30855
+ *
30856
+ * @param group - Commitment family represented by the documentation entry.
30857
+ * @param isOpenClosedCommitmentFamily - Whether the family contains both switch commitments.
30858
+ * @returns Canonical keyword by accepted source keyword.
30859
+ *
30860
+ * @private internal utility of `createStandaloneBookLanguageMarkdown`
30861
+ */
30862
+ function createCanonicalCommitmentTypeByCommitmentType(group, isOpenClosedCommitmentFamily) {
30863
+ const canonicalTypeByCommitmentType = new Map();
30864
+ canonicalTypeByCommitmentType.set(group.primary.type, group.primary.type);
30865
+ for (const alias of group.aliases) {
30866
+ canonicalTypeByCommitmentType.set(alias, isOpenClosedCommitmentFamily ? alias : group.primary.type);
30867
+ }
30868
+ return canonicalTypeByCommitmentType;
30710
30869
  }
30711
30870
 
30712
30871
  /**
@@ -30746,50 +30905,18 @@ const COMMITMENT_CATALOG_HEADING_LEVEL_SHIFT = 2;
30746
30905
  * @private internal utility of `createStandaloneBookLanguageMarkdown`
30747
30906
  */
30748
30907
  function renderCommitmentCatalogSection(options) {
30749
- var _a;
30750
- const { groupedCommitment, usageCount, dictionary } = options;
30908
+ const { groupedCommitment, dictionary } = options;
30751
30909
  const { primary, aliases } = groupedCommitment;
30752
30910
  const labels = dictionary.commitmentLabels;
30753
- const notice = getCommitmentNoticeMetadata(primary);
30754
- const status = primary instanceof NotYetImplementedCommitmentDefinition
30755
- ? labels.statusPlaceholder
30756
- : notice
30757
- ? `${labels.statusImplemented} (${notice.detailLabel})`
30758
- : labels.statusImplemented;
30759
- const aliasText = aliases.length === 0 ? labels.noAliases : aliases.map((alias) => `\`${alias}\``).join(', ');
30760
- const noticeText = notice
30761
- ? notice.kind === 'deprecated'
30762
- ? `- **${notice.detailLabel}:** ${notice.message}${formatCommitmentReplacementText((_a = primary.deprecation) === null || _a === void 0 ? void 0 : _a.replacedBy)}`
30763
- : `- **${labels.lowLevelNotice}:** ${notice.message}`
30764
- : '';
30765
- const usageMarkdown = usageCount > 0
30766
- ? `- **${labels.usage}:** ${usageCount} ${usageCount === 1 ? labels.usageOccurrence : labels.usageOccurrences}`
30767
- : '';
30911
+ const aliasesMarkdown = aliases.length === 0 ? '' : `- **${labels.aliases}:** ${aliases.map((alias) => `\`${alias}\``).join(', ')}`;
30768
30912
  return spaceTrim$1((block) => `
30769
30913
  ### <a id="commitment-${toStableAnchorId(primary.type)}"></a>${primary.icon} ${primary.type}
30770
30914
 
30771
- - **${labels.status}:** ${status}
30772
- - **${labels.aliases}:** ${aliasText}
30773
- - **${labels.semantics}:** ${primary.description}
30774
- - **${labels.typeSchema} (\`createTypeRegex\`):** \`${stringifyRegex(primary.createTypeRegex())}\`
30775
- - **${labels.blockSchema} (\`createRegex\`):** \`${stringifyRegex(primary.createRegex())}\`
30776
- ${noticeText}
30777
- ${usageMarkdown}
30915
+ ${aliasesMarkdown}
30778
30916
 
30779
30917
  ${block(renderGroupedCommitmentDocumentationMarkdown(groupedCommitment, COMMITMENT_CATALOG_HEADING_LEVEL_SHIFT))}
30780
30918
  `);
30781
30919
  }
30782
- /**
30783
- * Converts a regular expression into a concise literal-like string.
30784
- *
30785
- * @param regex - Regex instance.
30786
- * @returns Printable regex pattern and flags.
30787
- *
30788
- * @private internal utility of `renderCommitmentCatalogSection`
30789
- */
30790
- function stringifyRegex(regex) {
30791
- return `/${regex.source}/${regex.flags}`;
30792
- }
30793
30920
 
30794
30921
  /**
30795
30922
  * Commitment types that primarily model composition of multiple agents.
@@ -30896,11 +31023,10 @@ function createStandaloneBookLanguageMarkdown(options = {}) {
30896
31023
  : [];
30897
31024
  const manualCommitments = [...catalogCommitments, ...lowLevelCommitments];
30898
31025
  const generatedAtIso = new Date().toISOString();
30899
- const placeholderCommitmentCount = manualCommitments.filter(({ primary }) => primary instanceof NotYetImplementedCommitmentDefinition).length;
30900
31026
  const catalogTitleSuffix = isServerSpecificManual
30901
31027
  ? dictionary.commitmentCatalogTitleSuffixes.usedFirst
30902
31028
  : dictionary.commitmentCatalogTitleSuffixes.all;
30903
- const allCommitmentKeywords = manualCommitments.flatMap(({ primary, aliases }) => [primary.type, ...aliases]);
31029
+ const commitmentSectionAnchorByType = createCommitmentSectionAnchorByType(manualCommitments);
30904
31030
  return spaceTrim$1(
30905
31031
  // [✨]
30906
31032
  (block) => `
@@ -30910,9 +31036,7 @@ function createStandaloneBookLanguageMarkdown(options = {}) {
30910
31036
 
30911
31037
  - ${dictionary.metadataLabels.bookLanguageVersion}: \`${BOOK_LANGUAGE_VERSION}\`
30912
31038
  - ${dictionary.metadataLabels.generatedAt}: \`${generatedAtIso}\`
30913
- - ${dictionary.metadataLabels.commitmentGroups}: \`${manualCommitments.length}\`
30914
- - ${dictionary.metadataLabels.implementedCommitments}: \`${manualCommitments.length - placeholderCommitmentCount}\`
30915
- - ${dictionary.metadataLabels.placeholderCommitments}: \`${placeholderCommitmentCount}\`
31039
+ - ${dictionary.metadataLabels.commitmentCount}: \`${manualCommitments.length}\`
30916
31040
 
30917
31041
  ## <a id="table-of-contents"></a>${dictionary.tableOfContentsTitle}
30918
31042
 
@@ -30921,12 +31045,16 @@ function createStandaloneBookLanguageMarkdown(options = {}) {
30921
31045
  - [${dictionary.chapters.howToStructure.title}](#how-to-structure-good-agents)
30922
31046
  - [${dictionary.chapters.primitives.title}](#primitives-and-constructs-reference)
30923
31047
  - [${dictionary.chapters.commitmentCatalog.title}${catalogTitleSuffix}](#commitment-catalog)
31048
+ ${block(renderCommitmentCatalogTableOfContents(catalogCommitments))}
30924
31049
  - [${dictionary.chapters.examples.title}](#end-to-end-examples)
30925
31050
  - [${dictionary.chapters.pitfalls.title}](#do-nots-and-common-pitfalls)
30926
31051
  - [${dictionary.chapters.tutorial.title}](#build-an-agent-from-scratch-offline-tutorial)
30927
- ${isLowLevelCommitmentsIncluded
30928
- ? `- [${dictionary.chapters.lowLevelCommitments.title}](#low-level-commitments)`
30929
- : ''}
31052
+ ${block(isLowLevelCommitmentsIncluded
31053
+ ? spaceTrim$1(`
31054
+ - [${dictionary.chapters.lowLevelCommitments.title}](#low-level-commitments)
31055
+ ${renderCommitmentCatalogTableOfContents(lowLevelCommitments)}
31056
+ `)
31057
+ : '')}
30930
31058
 
30931
31059
  ## <a id="what-book-language-is"></a>${dictionary.chapters.whatIs.title}
30932
31060
 
@@ -30970,24 +31098,20 @@ function createStandaloneBookLanguageMarkdown(options = {}) {
30970
31098
 
30971
31099
  ${block(dictionary.primitivesSections.references.body)}
30972
31100
 
30973
- ### ${dictionary.primitivesSections.keywordsTitle}
30974
-
30975
- ${block(getSafeCodeBlock(allCommitmentKeywords.join(', '), 'text'))}
30976
-
30977
- <a id="commitment-catalog-all-commitments"></a>
30978
-
30979
31101
  ## <a id="commitment-catalog"></a>${dictionary.chapters.commitmentCatalog.title}${catalogTitleSuffix}
30980
31102
 
30981
31103
  ${block(dictionary.chapters.commitmentCatalog.body)}
30982
31104
 
30983
- ${block(renderCommitmentCatalogSections(catalogCommitments, commitmentUsageByType, dictionary))}
31105
+ ${block(renderCommitmentCatalogSections(catalogCommitments, dictionary))}
30984
31106
 
30985
31107
  ## <a id="end-to-end-examples"></a>${dictionary.chapters.examples.title}
30986
31108
 
30987
31109
  ${block(isServerSpecificManual
30988
- ? selectedAgents.map((agent) => renderBakedAgentExampleSection(agent, dictionary)).join('\n\n')
31110
+ ? selectedAgents
31111
+ .map((agent) => renderBakedAgentExampleSection(agent, dictionary, commitmentSectionAnchorByType))
31112
+ .join('\n\n')
30989
31113
  : bookLanguageDocumentationExamples
30990
- .map((example) => renderExampleSection(example, dictionary))
31114
+ .map((example) => renderExampleSection(example, dictionary, commitmentSectionAnchorByType))
30991
31115
  .join('\n\n'))}
30992
31116
 
30993
31117
  ## <a id="do-nots-and-common-pitfalls"></a>${dictionary.chapters.pitfalls.title}
@@ -31007,7 +31131,7 @@ function createStandaloneBookLanguageMarkdown(options = {}) {
31007
31131
  ${block(dictionary.tutorialSections.checklistBody)}
31008
31132
 
31009
31133
  ${block(isLowLevelCommitmentsIncluded
31010
- ? renderLowLevelCommitmentsChapter(lowLevelCommitments, commitmentUsageByType, dictionary)
31134
+ ? renderLowLevelCommitmentsChapter(lowLevelCommitments, dictionary)
31011
31135
  : '')}
31012
31136
 
31013
31137
  ---
@@ -31047,17 +31171,15 @@ function renderDetectedCommitmentList(commitmentGroups, dictionary) {
31047
31171
  * Renders every commitment section of one catalog chapter.
31048
31172
  *
31049
31173
  * @param commitmentGroups - Commitment groups to render, in final order.
31050
- * @param commitmentUsageByType - Selected-agent occurrence counts by primary type.
31051
31174
  * @param dictionary - Translated labels of the manual.
31052
31175
  * @returns Markdown sections joined by blank lines.
31053
31176
  *
31054
31177
  * @private internal utility of `createStandaloneBookLanguageMarkdown`
31055
31178
  */
31056
- function renderCommitmentCatalogSections(commitmentGroups, commitmentUsageByType, dictionary) {
31179
+ function renderCommitmentCatalogSections(commitmentGroups, dictionary) {
31057
31180
  return commitmentGroups
31058
31181
  .map((groupedCommitment) => renderCommitmentCatalogSection({
31059
31182
  groupedCommitment,
31060
- usageCount: commitmentUsageByType.get(groupedCommitment.primary.type) || 0,
31061
31183
  dictionary,
31062
31184
  }))
31063
31185
  .join('\n\n');
@@ -31066,21 +31188,52 @@ function renderCommitmentCatalogSections(commitmentGroups, commitmentUsageByType
31066
31188
  * Renders the closing chapter documenting low-level commitments.
31067
31189
  *
31068
31190
  * @param commitmentGroups - Low-level commitment groups, in final order.
31069
- * @param commitmentUsageByType - Selected-agent occurrence counts by primary type.
31070
31191
  * @param dictionary - Translated labels of the manual.
31071
31192
  * @returns Markdown chapter for low-level commitments.
31072
31193
  *
31073
31194
  * @private internal utility of `createStandaloneBookLanguageMarkdown`
31074
31195
  */
31075
- function renderLowLevelCommitmentsChapter(commitmentGroups, commitmentUsageByType, dictionary) {
31196
+ function renderLowLevelCommitmentsChapter(commitmentGroups, dictionary) {
31076
31197
  return spaceTrim$1((block) => `
31077
31198
  ## <a id="low-level-commitments"></a>${dictionary.chapters.lowLevelCommitments.title}
31078
31199
 
31079
31200
  ${block(dictionary.chapters.lowLevelCommitments.body)}
31080
31201
 
31081
- ${block(renderCommitmentCatalogSections(commitmentGroups, commitmentUsageByType, dictionary))}
31202
+ ${block(renderCommitmentCatalogSections(commitmentGroups, dictionary))}
31082
31203
  `);
31083
31204
  }
31205
+ /**
31206
+ * Renders links from the manual table of contents to the commitment sections.
31207
+ *
31208
+ * @param commitmentGroups - Commitment sections included in the manual.
31209
+ * @returns Indented markdown links ordered like the catalog.
31210
+ *
31211
+ * @private internal utility of `createStandaloneBookLanguageMarkdown`
31212
+ */
31213
+ function renderCommitmentCatalogTableOfContents(commitmentGroups) {
31214
+ return commitmentGroups
31215
+ .map(({ primary }) => ` - [${primary.icon} \`${primary.type}\`](#commitment-${toStableAnchorId(primary.type)})`)
31216
+ .join('\n');
31217
+ }
31218
+ /**
31219
+ * Maps every recognized spelling of a documented commitment to its stable section anchor.
31220
+ *
31221
+ * @param commitmentGroups - Commitment sections included in the manual.
31222
+ * @returns Canonical anchor id by parsed commitment type.
31223
+ *
31224
+ * @private internal utility of `createStandaloneBookLanguageMarkdown`
31225
+ */
31226
+ function createCommitmentSectionAnchorByType(commitmentGroups) {
31227
+ const anchorByType = new Map();
31228
+ for (const { primary, aliases } of commitmentGroups) {
31229
+ const anchorId = `commitment-${toStableAnchorId(primary.type)}`;
31230
+ anchorByType.set(primary.type, anchorId);
31231
+ for (const alias of aliases) {
31232
+ anchorByType.set(alias, anchorId);
31233
+ }
31234
+ }
31235
+ return anchorByType;
31236
+ }
31084
31237
  /**
31085
31238
  * Renders the "don't vs do" list of common authoring pitfalls.
31086
31239
  *
@@ -31187,9 +31340,9 @@ function prioritizeGroupedCommitments(groupedCommitments, commitmentUsageByType)
31187
31340
  *
31188
31341
  * @private internal utility of `createStandaloneBookLanguageMarkdown`
31189
31342
  */
31190
- function renderBakedAgentExampleSection(agent, dictionary) {
31343
+ function renderBakedAgentExampleSection(agent, dictionary, commitmentSectionAnchorByType) {
31191
31344
  const usedCommitmentTypes = Array.from(new Set(parseAgentSourceWithCommitments(agent.agentSource).commitments.map((commitment) => commitment.type)));
31192
- const usedCommitmentsMarkdown = usedCommitmentTypes.map((type) => `\`${type}\``).join(', ');
31345
+ const usedCommitmentsMarkdown = renderCommitmentSectionLinks(usedCommitmentTypes, commitmentSectionAnchorByType);
31193
31346
  return spaceTrim$1((block) => `
31194
31347
  ### <a id="example-${toStableAnchorId(agent.agentName)}"></a>${agent.agentName}
31195
31348
 
@@ -31209,7 +31362,7 @@ function renderBakedAgentExampleSection(agent, dictionary) {
31209
31362
  *
31210
31363
  * @private internal utility of `createStandaloneBookLanguageMarkdown`
31211
31364
  */
31212
- function renderExampleSection(example, dictionary) {
31365
+ function renderExampleSection(example, dictionary, commitmentSectionAnchorByType) {
31213
31366
  const exampleText = dictionary.exampleTexts[example.id];
31214
31367
  if (exampleText === undefined) {
31215
31368
  return '';
@@ -31219,6 +31372,8 @@ function renderExampleSection(example, dictionary) {
31219
31372
 
31220
31373
  **${dictionary.exampleLabels.goal}:** ${exampleText.goal}
31221
31374
 
31375
+ **${dictionary.exampleLabels.commitmentsUsed}:** ${renderCommitmentSectionLinks(parseAgentSourceWithCommitments(example.source).commitments.map((commitment) => commitment.type), commitmentSectionAnchorByType)}
31376
+
31222
31377
  **${dictionary.exampleLabels.fullSource}**
31223
31378
 
31224
31379
  ${block(getSafeCodeBlock(example.source, 'book'))}
@@ -31228,6 +31383,23 @@ function renderExampleSection(example, dictionary) {
31228
31383
  ${block(exampleText.walkthrough.map((step, index) => `${index + 1}. ${step}`).join('\n'))}
31229
31384
  `);
31230
31385
  }
31386
+ /**
31387
+ * Renders unique commitment links used by an end-to-end example.
31388
+ *
31389
+ * @param commitmentTypes - Commitment types in their source order.
31390
+ * @param commitmentSectionAnchorByType - Documented commitment anchors by parsed type.
31391
+ * @returns Comma-separated markdown links, or an empty string when none are documented.
31392
+ *
31393
+ * @private internal utility of `createStandaloneBookLanguageMarkdown`
31394
+ */
31395
+ function renderCommitmentSectionLinks(commitmentTypes, commitmentSectionAnchorByType) {
31396
+ return Array.from(new Set(commitmentTypes))
31397
+ .flatMap((type) => {
31398
+ const anchorId = commitmentSectionAnchorByType.get(type);
31399
+ return anchorId ? [`[\`${type}\`](#${anchorId})`] : [];
31400
+ })
31401
+ .join(', ');
31402
+ }
31231
31403
 
31232
31404
  /**
31233
31405
  * Generates an image for the agent to use as profile image
@@ -32207,17 +32379,6 @@ async function pipelineCollectionToJson(collection) {
32207
32379
  }
32208
32380
  // TODO: [🧠] Maybe clear `sourceFile` or clear when exposing through API or remote server
32209
32381
 
32210
- /**
32211
- * Gets all available commitment definitions
32212
- *
32213
- * @returns Array of all commitment definitions
32214
- *
32215
- * @public exported from `@promptbook/core`
32216
- */
32217
- function getAllCommitmentDefinitions() {
32218
- return $deepFreeze(sortCommitmentDefinitions(COMMITMENT_REGISTRY, { isUnfinishedLast: true, isLowLevelLast: true }));
32219
- }
32220
-
32221
32382
  /**
32222
32383
  * Gets all tool titles provided by all commitments
32223
32384
  *
@@ -32238,17 +32399,6 @@ function getAllCommitmentsToolTitles() {
32238
32399
  return allToolTitles;
32239
32400
  }
32240
32401
 
32241
- /**
32242
- * Gets all available commitment types
32243
- *
32244
- * @returns Array of all commitment types
32245
- *
32246
- * @public exported from `@promptbook/core`
32247
- */
32248
- function getAllCommitmentTypes() {
32249
- return $deepFreeze(getAllCommitmentDefinitions().map((commitmentDefinition) => commitmentDefinition.type));
32250
- }
32251
-
32252
32402
  /**
32253
32403
  * Checks if a commitment type is supported
32254
32404
  *