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