{"name":"@promptbook/utils","version":"0.78.3","keywords":["ai","llm","prompt","template","language-model","chatgpt","autogpt","machine-learning","natural-language-processing","nlp","openai","gpt-3","gpt-4","gpt-4o","gpt-4o-mini","o1","o1-mini","o1-preview","anthropic","LLMOps"],"license":"CC-BY-4.0","_id":"@promptbook/utils@0.78.3","maintainers":[{"name":"hejny","email":"me@pavolhejny.com"}],"contributors":[{"url":"https://www.pavolhejny.com/","name":"Pavol Hejný","email":"me@pavolhejny.com"}],"homepage":"https://www.npmjs.com/package/@promptbook/core","bugs":{"url":"https://github.com/webgptorg/promptbook/issues"},"dist":{"shasum":"4ab3a30204bcc11040acc102da426cd8c08ba73e","tarball":"http://registry-npm.ywwl.com/@promptbook/utils/download/@promptbook/utils-0.78.3.tgz","fileCount":621,"integrity":"sha512-k1mAazxkIPRUAADOvfYbOawq0GyyYOdRKAhdeXHU/0A5bqU96AazRHFDZ8XQSUR0AYz4WoHBhouIYVOYdwVKlg==","signatures":[{"sig":"MEQCIBa9iCowjWjBnvLEdS6ufJXcJuJXKieSBqawIHUmMWhuAiBnWqbaWU8nvMeH0xOQmyjET11wiS662GS7ovDnlt8KgA==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"attestations":{"url":"https://registry.npmjs.org/-/npm/v1/attestations/@promptbook%2futils@0.78.3","provenance":{"predicateType":"https://slsa.dev/provenance/v1"}},"unpackedSize":867393,"size":201972,"noattachment":false,"key":"/@promptbook/utils/-/@promptbook/utils-0.78.3.tgz"},"main":"./umd/index.umd.js","module":"./esm/index.es.js","funding":[{"url":"https://buymeacoffee.com/hejny","type":"individual"},{"url":"https://github.com/webgptorg/promptbook/blob/main/README.md#%EF%B8%8F-contributing","type":"github"}],"gitHead":"7029343cad2ca752069f302aee6deab15c86cb29","private":false,"typings":"./esm/typings/src/_packages/utils.index.d.ts","--note-0":"    <- [🐊]","--todo-0":"TODO: [❇️] Make better list of keywords","_npmUser":{"name":"hejny","email":"me@pavolhejny.com"},"repository":{"url":"git+https://github.com/webgptorg/promptbook.git","type":"git"},"_npmVersion":"10.8.2","description":"It's time for a paradigm shift. The future of software in plain English, French or Latin","directories":{},"sideEffects":false,"_nodeVersion":"18.20.5","dependencies":{"spacetrim":"0.11.59"},"_hasShrinkwrap":false,"_npmOperationalInternal":{"tmp":"tmp/utils_0.78.3_1734966780703_0.5413162493993902","host":"s3://npm-registry-packages-npm-production"},"readme":"<!-- ⚠️ WARNING: This code has been generated so that any manual changes will be overwritten -->\n\n# 🐙 Promptbook: Invisible AI Agents\n\nCreate persistent AI agents that turn your company's scattered knowledge into action - powered by the [Agents Server](https://gallery.ptbk.io/)\n\n\n\n\n\n\n[![NPM Version of ![Promptbook logo](./design/logo-h1.png) Promptbook](https://badge.fury.io/js/promptbook.svg)](https://www.npmjs.com/package/promptbook)\n[![Quality of package ![Promptbook logo](./design/logo-h1.png) Promptbook](https://packagequality.com/shield/promptbook.svg)](https://packagequality.com/#?package=promptbook)\n[![Known Vulnerabilities](https://snyk.io/test/github/webgptorg/promptbook/badge.svg)](https://snyk.io/test/github/webgptorg/promptbook)\n[![🧪 Test Books](https://github.com/webgptorg/promptbook/actions/workflows/test-books.yml/badge.svg)](https://github.com/webgptorg/promptbook/actions/workflows/test-books.yml)\n[![🧪 Test build](https://github.com/webgptorg/promptbook/actions/workflows/test-build.yml/badge.svg)](https://github.com/webgptorg/promptbook/actions/workflows/test-build.yml)\n[![🧪 Lint](https://github.com/webgptorg/promptbook/actions/workflows/test-lint.yml/badge.svg)](https://github.com/webgptorg/promptbook/actions/workflows/test-lint.yml)\n[![🧪 Spell check](https://github.com/webgptorg/promptbook/actions/workflows/test-spell-check.yml/badge.svg)](https://github.com/webgptorg/promptbook/actions/workflows/test-spell-check.yml)\n[![🧪 Test types](https://github.com/webgptorg/promptbook/actions/workflows/test-types.yml/badge.svg)](https://github.com/webgptorg/promptbook/actions/workflows/test-types.yml)\n[![Issues](https://img.shields.io/github/issues/webgptorg/promptbook.svg?style=flat)](https://github.com/webgptorg/promptbook/issues)\n\n## 🚀 Quick deploy\n\n\n\nRun the standalone VPS installer _(for example on DigitalOcean)_ only on a fresh server. Interactive mode asks for the installation values:\n\n```bash\nsudo curl -fsSL https://raw.githubusercontent.com/webgptorg/promptbook/refs/heads/main/install.sh | bash\n```\n\nNon-interactive mode takes defaults from command-line options. Use `--env live`, `--env preview`, `--env production`, or `--env lts` to pick the installed environment; the default is `preview`. When `--openai-api-key` is provided with the default OpenAI Codex runner, the installer installs and configures Codex automatically; other runner authentication can be configured later from the UI or SSH:\n\n```bash\nsudo curl -fsSL https://raw.githubusercontent.com/webgptorg/promptbook/refs/heads/main/install.sh | bash -s -- \\\n    --non-interactive \\\n    --yes-i-understand-that-script-should-be-run-on-fresh-server \\\n    --env preview \\\n    --domain my-server.com \\\n    --openai-api-key sk-proj-xxx \\\n    --admin-password xxx\n```\n\n\n\n<blockquote style=\"color: #ff8811\">\n    <b>⚠ Warning:</b> This is a pre-release version of the library. It is not yet ready for production use. Please look at <a href=\"https://www.npmjs.com/package/@promptbook/core?activeTab=versions\">latest stable release</a>.\n</blockquote>\n\n## 📦 Package `@promptbook/utils`\n\n- Promptbooks are [divided into several](#-packages) packages, all are published from [single monorepo](https://github.com/webgptorg/promptbook).\n- This package `@promptbook/utils` is one part of the promptbook ecosystem.\n\nTo install this package, run:\n\n```bash\n# Install entire promptbook ecosystem\nnpm i ptbk\n\n# Install just this package to save space\nnpm install @promptbook/utils\n```\n\nComprehensive utility functions for text processing, validation, normalization, and LLM input/output handling in the Promptbook ecosystem.\n\n## 🎯 Purpose and Motivation\n\nThe utils package provides a rich collection of utility functions that are essential for working with LLM inputs and outputs. It handles common tasks like text normalization, parameter templating, validation, and postprocessing, eliminating the need to implement these utilities from scratch in every promptbook application.\n\n## 🔧 High-Level Functionality\n\nThis package offers utilities across multiple domains:\n\n-   **Text Processing**: Counting, splitting, and analyzing text content\n-   **Template System**: Secure parameter substitution and prompt formatting\n-   **Normalization**: Converting text to various naming conventions and formats\n-   **Validation**: Comprehensive validation for URLs, emails, file paths, and more\n-   **Serialization**: JSON handling, deep cloning, and object manipulation\n-   **Environment Detection**: Runtime environment identification utilities\n-   **Format Parsing**: Support for CSV, JSON, XML validation and parsing\n\n## ✨ Key Features\n\n-   🔒 **Secure Templating** - Prompt injection protection with template functions\n-   📊 **Text Analysis** - Count words, sentences, paragraphs, pages, and characters\n-   🔄 **Case Conversion** - Support for kebab-case, camelCase, PascalCase, SCREAMING_CASE\n-   ✅ **Comprehensive Validation** - Email, URL, file path, UUID, and format validators\n-   🧹 **Text Cleaning** - Remove emojis, quotes, diacritics, and normalize whitespace\n-   📦 **Serialization Tools** - Deep cloning, JSON export, and serialization checking\n-   🌐 **Environment Aware** - Detect browser, Node.js, Jest, and Web Worker environments\n-   🎯 **LLM Optimized** - Functions specifically designed for LLM input/output processing\n\n## Simple templating\n\nThe `prompt` template tag function helps format prompt strings for LLM interactions. It handles string interpolation and maintains consistent formatting for multiline strings and lists and also handles a security to avoid **prompt injection**.\n\n```typescript\nimport { prompt } from '@promptbook/utils';\n\nconst promptString = prompt`\n    Correct the following sentence:\n\n    > ${unsecureUserInput}\n`;\n```\n\nThe `prompt` name could be overloaded by multiple things in your code. If you want to use the `promptTemplate` which is alias for `prompt`:\n\n```typescript\nimport { promptTemplate } from '@promptbook/utils';\n\nconst promptString = promptTemplate`\n    Correct the following sentence:\n\n    > ${unsecureUserInput}\n`;\n```\n\n## Advanced templating\n\nThere is a function `templateParameters` which is used to replace the parameters in given template optimized to LLM prompt templates.\n\n```typescript\nimport { templateParameters } from '@promptbook/utils';\n\ntemplateParameters('Hello, {name}!', { name: 'world' }); // 'Hello, world!'\n```\n\nAnd also multiline templates with blockquotes\n\n```typescript\nimport { templateParameters, spaceTrim } from '@promptbook/utils';\n\ntemplateParameters(\n    spaceTrim(`\n        Hello, {name}!\n\n        > {answer}\n    `),\n    {\n        name: 'world',\n        answer: spaceTrim(`\n            I'm fine,\n            thank you!\n\n            And you?\n        `),\n    },\n);\n\n// Hello, world!\n//\n// > I'm fine,\n// > thank you!\n// >\n// > And you?\n```\n\n## Counting\n\nThese functions are useful to count stats about the input/output in human-like terms not tokens and bytes, you can use\n`countCharacters`, `countLines`, `countPages`, `countParagraphs`, `countSentences`, `countWords`\n\n```typescript\nimport { countWords } from '@promptbook/utils';\n\nconsole.log(countWords('Hello, world!')); // 2\n```\n\n## Splitting\n\nSplitting functions are similar to counting but they return the split parts of the input/output, you can use\n`splitIntoCharacters`, `splitIntoLines`, `splitIntoPages`, `splitIntoParagraphs`, `splitIntoSentences`, `splitIntoWords`\n\n```typescript\nimport { splitIntoWords } from '@promptbook/utils';\n\nconsole.log(splitIntoWords('Hello, world!')); // ['Hello', 'world']\n```\n\n## Normalization\n\nNormalization functions are used to put the string into a normalized form, you can use\n`kebab-case`\n`PascalCase`\n`SCREAMING_CASE`\n`snake_case`\n`kebab-case`\n\n```typescript\nimport { normalizeTo } from '@promptbook/utils';\n\nconsole.log(normalizeTo['kebab-case']('Hello, world!')); // 'hello-world'\n```\n\n-   There are more normalization functions like `capitalize`, `decapitalize`, `removeDiacritics`,...\n-   These can be also used as postprocessing functions in the `POSTPROCESS` command in promptbook\n\n## Postprocessing\n\nSometimes you need to postprocess the output of the LLM model, every postprocessing function that is available through `POSTPROCESS` command in promptbook is exported from `@promptbook/utils`. You can use:\n\n-   `spaceTrim`\n-   `extractAllBlocksFromMarkdown`, _<- Note: Exported from [`@promptbook/markdown-utils`](https://www.npmjs.com/package/@promptbook/markdown-utils)_\n-   `extractAllListItemsFromMarkdown` _<- Note: Exported from [`@promptbook/markdown-utils`](https://www.npmjs.com/package/@promptbook/markdown-utils)_\n-   `extractBlock`\n-   `extractOneBlockFromMarkdown `_<- Note: Exported from [`@promptbook/markdown-utils`](https://www.npmjs.com/package/@promptbook/markdown-utils)_\n-   `prettifyPipelineString`\n-   `removeMarkdownComments`\n-   `removeEmojis`\n-   `removeMarkdownFormatting` _<- Note: Exported from [`@promptbook/markdown-utils`](https://www.npmjs.com/package/@promptbook/markdown-utils)_\n-   `removeQuotes`\n-   `trimCodeBlock`\n-   `trimEndOfCodeBlock`\n-   `unwrapResult`\n\nVery often you will use `unwrapResult`, which is used to extract the result you need from output with some additional information:\n\n```typescript\nimport { unwrapResult } from '@promptbook/utils';\n\nunwrapResult('Best greeting for the user is \"Hi Pavol!\"'); // 'Hi Pavol!'\n```\n\n## 📦 Exported Entities\n\n### Version Information\n\n-   `BOOK_LANGUAGE_VERSION` - Current book language version\n-   `PROMPTBOOK_ENGINE_VERSION` - Current engine version\n\n### Configuration Constants\n\n-   `VALUE_STRINGS` - Standard value strings\n-   `SMALL_NUMBER` - Small number constant\n\n### Visualization\n\n-   `renderPromptbookMermaid` - Render promptbook as Mermaid diagram\n\n### Error Handling\n\n-   `deserializeError` - Deserialize error objects\n-   `serializeError` - Serialize error objects\n\n### Async Utilities\n\n-   `forEachAsync` - Async forEach implementation\n\n### Format Validation\n\n-   `isValidCsvString` - Validate CSV string format\n-   `isValidJsonString` - Validate JSON string format\n-   `jsonParse` - Safe JSON parsing\n-   `isValidXmlString` - Validate XML string format\n\n### Template Functions\n\n-   `prompt` - Template tag for secure prompt formatting\n-   `promptTemplate` - Alias for prompt template tag\n\n### Environment Detection\n\n-   `$getCurrentDate` - Get current date (side effect)\n-   `$isRunningInBrowser` - Check if running in browser\n-   `$isRunningInJest` - Check if running in Jest\n-   `$isRunningInNode` - Check if running in Node.js\n-   `$isRunningInWebWorker` - Check if running in Web Worker\n\n### Text Counting and Analysis\n\n-   `CHARACTERS_PER_STANDARD_LINE` - Characters per standard line constant\n-   `LINES_PER_STANDARD_PAGE` - Lines per standard page constant\n-   `countCharacters` - Count characters in text\n-   `countLines` - Count lines in text\n-   `countPages` - Count pages in text\n-   `countParagraphs` - Count paragraphs in text\n-   `splitIntoSentences` - Split text into sentences\n-   `countSentences` - Count sentences in text\n-   `countWords` - Count words in text\n-   `CountUtils` - Utility object with all counting functions\n\n### Text Normalization\n\n-   `capitalize` - Capitalize first letter\n-   `decapitalize` - Decapitalize first letter\n-   `DIACRITIC_VARIANTS_LETTERS` - Diacritic variants mapping\n-   `string_keyword` - Keyword string type (type)\n-   `Keywords` - Keywords type (type)\n-   `isValidKeyword` - Validate keyword format\n-   `nameToUriPart` - Convert name to URI part\n-   `nameToUriParts` - Convert name to URI parts\n-   `string_kebab_case` - Kebab case string type (type)\n-   `normalizeToKebabCase` - Convert to kebab-case\n-   `string_camelCase` - Camel case string type (type)\n-   `normalizeTo_camelCase` - Convert to camelCase\n-   `string_PascalCase` - Pascal case string type (type)\n-   `normalizeTo_PascalCase` - Convert to PascalCase\n-   `string_SCREAMING_CASE` - Screaming case string type (type)\n-   `normalizeTo_SCREAMING_CASE` - Convert to SCREAMING_CASE\n-   `normalizeTo_snake_case` - Convert to snake_case\n-   `normalizeWhitespaces` - Normalize whitespace characters\n-   `orderJson` - Order JSON object properties\n-   `parseKeywords` - Parse keywords from input\n-   `parseKeywordsFromString` - Parse keywords from string\n-   `removeDiacritics` - Remove diacritic marks\n-   `searchKeywords` - Search within keywords\n-   `suffixUrl` - Add suffix to URL\n-   `titleToName` - Convert title to name format\n\n### Text Organization\n\n-   `spaceTrim` - Trim spaces while preserving structure\n\n### Parameter Processing\n\n-   `extractParameterNames` - Extract parameter names from template\n-   `numberToString` - Convert number to string\n-   `templateParameters` - Replace template parameters\n-   `valueToString` - Convert value to string\n\n### Parsing Utilities\n\n-   `parseNumber` - Parse number from string\n\n### Text Processing\n\n-   `removeEmojis` - Remove emoji characters\n-   `removeQuotes` - Remove quote characters\n\n### Serialization\n\n-   `$deepFreeze` - Deep freeze object (side effect)\n-   `checkSerializableAsJson` - Check if serializable as JSON\n-   `clonePipeline` - Clone pipeline object\n-   `deepClone` - Deep clone object\n-   `exportJson` - Export object as JSON\n-   `isSerializableAsJson` - Check if object is JSON serializable\n-   `jsonStringsToJsons` - Convert JSON strings to objects\n\n### Set Operations\n\n-   `difference` - Set difference operation\n-   `intersection` - Set intersection operation\n-   `union` - Set union operation\n\n### Code Processing\n\n-   `trimCodeBlock` - Trim code block formatting\n-   `trimEndOfCodeBlock` - Trim end of code block\n-   `unwrapResult` - Extract result from wrapped output\n\n### Validation\n\n-   `isValidEmail` - Validate email address format\n-   `isRootPath` - Check if path is root path\n-   `isValidFilePath` - Validate file path format\n-   `isValidJavascriptName` - Validate JavaScript identifier\n-   `isValidPromptbookVersion` - Validate promptbook version\n-   `isValidSemanticVersion` - Validate semantic version\n-   `isHostnameOnPrivateNetwork` - Check if hostname is on private network\n-   `isUrlOnPrivateNetwork` - Check if URL is on private network\n-   `isValidPipelineUrl` - Validate pipeline URL format\n-   `isValidUrl` - Validate URL format\n-   `isValidUuid` - Validate UUID format\n\n> 💡 This package provides utility functions for promptbook applications. For the core functionality, see [@promptbook/core](#-packages) or install all packages with `npm i ptbk`\n\n\n---\n\nRest of the documentation is common for **entire promptbook ecosystem**:\n\n\n\n\n## 📖 The Book Whitepaper\n\nPromptbook lets you create **persistent AI agents** that work on real goals for your company. The [**Agents Server**](https://gallery.ptbk.io/) is the heart of the project - a place where your AI agents live, remember context, collaborate in teams, and get things done.\n\nNowadays, the biggest challenge for most business applications isn't the raw capabilities of AI models. Large language models such as Claude Mythos, GPT-5.6 or Kimi K2.7 are incredibly capable.\n\nThe main challenge lies in **managing the context**, providing rules and knowledge, and narrowing the personality.\n\nIn Promptbook, you define your agents **using simple Books** - a human-readable language that is explicit, easy to understand and write, reliable, and highly portable. You then deploy them to the **Agents Server**, where they run persistently and work toward their goals.\n\n<table style=\"border: 1px solid #777; border-radius: 10px;\"><tr><td>\n\n**<ins>Lawyer</ins>**<br/>\n<br/>\nGOAL You are a company lawyer.<br/>\nYour job is to provide legal advice and support to the company and its employees.<br/>\nRespond to incoming legal inquiries via email and keep the company website updated with the latest legal policies.<br/>\n<br/>\n**RULE** You are knowledgeable, professional, and detail-oriented.<br/>\n**KNOWLEDGE** https://company.com/company-policies.pdf<br/>\n**KNOWLEDGE** https://company.com/internal-documents/employee-handbook.docx<br/>\n<br/>\n<br/>\nTEAM You are part of the legal team of Paul Smith & Associés, you discuss with {Emily White}, the head of the compliance department. {George Brown} is expert in corporate law and {Sophia Black} is expert in labor law.<br/>\n\n</td></tr></table>\n\n<div style=\"page-break-after: always;\"></div>\n\n### Aspects of great AI agent\n\nWe have created a language called **Book**, which allows you to write AI agents in their native language and create your own AI persona. Book provides a guide to define all the traits and commitments.\n\nYou can look at it as \"prompting\" _(or writing a system message)_, but decorated by **commitments**.\n\n**Commitments** are special syntax elements that define contracts between you and the AI agent. They are transformed by Promptbook Engine into low-level parameters like which model to use, its temperature, system message, RAG index, MCP servers, and many other parameters. For some commitments _(for example `RULE` commitment)_ Promptbook Engine can even create adversary agents and extra checks to enforce the rules.\n\n#### `Persona` commitment\n\nPersonas define the character of your AI persona, its role, and how it should interact with users. It sets the tone and style of communication.\n\n<table style=\"border: 1px solid #777; border-radius: 10px;\"><tr><td>\n\n**<ins>Paul Smith & Associés</ins>**<br/>\n<br/>\n**PERSONA** You are a company lawyer.<br/>\nYour job is to provide legal advice and support to the company and its employees.<br/>\n\n</td></tr></table>\n\n#### `Goal` commitment\n\nGoals define what the agent should actively work toward. Unlike a chatbot that only responds when asked, an agent with goals takes initiative and works on tasks persistently on the Agents Server.\n\n<table style=\"border: 1px solid #777; border-radius: 10px;\"><tr><td>\n\n**<ins>Company Lawyer</ins>**<br/>\n<br/>\nGOAL<br/>\nYour job is to provide legal advice and support to the company and its employees.<br/>\nGOAL Respond to incoming legal inquiries via email within 24 hours.<br/>\nGOAL Keep the company website updated with the latest legal policies and compliance information.<br/>\n\n</td></tr></table>\n\n#### `Knowledge` commitment\n\nKnowledge Commitment allows you to provide specific information, facts, or context that the AI should be aware of when responding.\n\nThis can include domain-specific knowledge, company policies, or any other relevant information.\n\nPromptbook Engine will automatically enforce this knowledge during interactions. When the knowledge is short enough, it will be included in the prompt. When it is too long, it will be stored in vector databases and RAG retrieved when needed. But you don't need to care about it.\n\n<table style=\"border: 1px solid #777; border-radius: 10px;\"><tr><td>\n\n**<ins>Paul Smith & Associés</ins>**<br/>\n<br/>\n**PERSONA** You are a company lawyer.<br/>\nYour job is to provide legal advice and support to the company and its employees.<br/>\nGOAL Respond to incoming legal inquiries via email within 24 hours.<br/>\nGOAL Keep the company website updated with the latest legal policies and compliance information.<br/>\n**KNOWLEDGE** https://company.com/company-policies.pdf<br/>\n**KNOWLEDGE** https://company.com/internal-documents/employee-handbook.docx<br/>\n\n</td></tr></table>\n\n#### `Rule` commitment\n\nRules will enforce specific behaviors or constraints on the AI's responses. This can include ethical guidelines, communication styles, or any other rules you want the AI to follow.\n\nDepending on rule strictness, Promptbook will either propagate it to the prompt or use other techniques, like adversary agent, to enforce it.\n\n<table style=\"border: 1px solid #777; border-radius: 10px;\"><tr><td>\n\n**<ins>Paul Smith & Associés</ins>**<br/>\n<br/>\n**PERSONA** You are a company lawyer.<br/>\nYour job is to provide legal advice and support to the company and its employees.<br/>\nGOAL Respond to incoming legal inquiries via email within 24 hours.<br/>\nGOAL Keep the company website updated with the latest legal policies and compliance information.<br/>\n**RULE** Always ensure compliance with local laws and regulations.<br/>\n**RULE** Never provide legal advice outside your area of expertise.<br/>\n**RULE** Never provide legal advice about criminal law.<br/>\n**KNOWLEDGE** https://company.com/company-policies.pdf<br/>\n**KNOWLEDGE** https://company.com/internal-documents/employee-handbook.docx<br/>\n\n</td></tr></table>\n\n#### `Use` commitments\n\nUse commitments grant the agent real capabilities - tools it can use to interact with the outside world. `USE CALENDAR` lets the agent work with a calendar, `USE PROJECT` gives it access to a code repository, `USE MCP` connects any external Model Context Protocol server, and many more.\n\nThese are what turn a chatbot into a persistent agent that actually does work.\n\n<table style=\"border: 1px solid #777; border-radius: 10px;\"><tr><td>\n\n**<ins>Paul Smith & Associés</ins>**<br/>\n<br/>\n**PERSONA** You are a company lawyer.<br/>\nYour job is to provide legal advice and support to the company and its employees.<br/>\nGOAL Respond to incoming legal inquiries via email within 24 hours.<br/>\nGOAL Keep the company website updated with the latest legal policies and compliance information.<br/>\n**RULE** Always ensure compliance with local laws and regulations.<br/>\n**RULE** Never provide legal advice outside your area of expertise.<br/>\n**RULE** Never provide legal advice about criminal law.<br/>\n**KNOWLEDGE** https://company.com/company-policies.pdf<br/>\n**KNOWLEDGE** https://company.com/internal-documents/employee-handbook.docx<br/>\n\n</td></tr></table>\n\n#### `Team` commitment\n\nTeam commitment allows you to define the team structure and advisory fellow members the AI can consult with. This allows the AI to simulate collaboration and consultation with other experts, enhancing the quality of its responses.\n\n<table style=\"border: 1px solid #777; border-radius: 10px;\"><tr><td>\n\n**<ins>Paul Smith & Associés</ins>**<br/>\n<br/>\n**PERSONA** You are a company lawyer.<br/>\nYour job is to provide legal advice and support to the company and its employees.<br/>\nGOAL Respond to incoming legal inquiries via email within 24 hours.<br/>\nGOAL Keep the company website updated with the latest legal policies and compliance information.<br/>\n**RULE** Always ensure compliance with local laws and regulations.<br/>\n**RULE** Never provide legal advice outside your area of expertise.<br/>\n**RULE** Never provide legal advice about criminal law.<br/>\n**KNOWLEDGE** https://company.com/company-policies.pdf<br/>\n**KNOWLEDGE** https://company.com/internal-documents/employee-handbook.docx<br/>\nTEAM You are part of the legal team of Paul Smith & Associés, you discuss with {Emily White}, the head of the compliance department. {George Brown} is expert in corporate law and {Sophia Black} is expert in labor law.<br/>\n\n</td></tr></table>\n\n### Promptbook Ecosystem\n\nPromptbook is an ecosystem of tools centered around the **Agents Server** - a production-ready platform for running persistent AI agents.\n\n#### Agents Server\n\nThe [**Agents Server**](https://gallery.ptbk.io/) is the primary way to use Promptbook. It is a web application where your AI agents live and work. You can create agents, give them knowledge and rules using the Book language, organize them into teams, and let them work on goals persistently. The Agents Server provides a UI for managing agents, an API for integrating them into your applications, and can be self-hosted via [Docker](https://hub.docker.com/r/hejny/promptbook/) or deployed on Vercel.\n\n#### Promptbook Engine\n\nThe [Promptbook Engine](https://github.com/webgptorg/promptbook) is the open-source core that powers everything. It parses the Book language, applies commitments, manages LLM provider integrations, and executes agents. The Agents Server is built on top of the Engine. If you need to embed agent capabilities directly into your own application, you can use the Engine as a standalone TypeScript/JavaScript library via [NPM packages](https://www.npmjs.com/package/@promptbook/core).\n\n\n\n\n\n\n\n\n\n\n\n## 💜 The Promptbook Project\n\nPromptbook project is an ecosystem centered around the **Agents Server** - a platform for creating, deploying, and running persistent AI agents. Following is a list of the most important pieces of the project:\n\n<table>\n  <thead>\n    <tr>\n      <th>Project</th>\n      <th>About</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <td><a href=\"https://gallery.ptbk.io/\"><strong>⭐ Agents Server</strong></a></td>\n      <td>\n          The primary way to use Promptbook. A production-ready platform where your AI agents live - create, manage, deploy, and interact with persistent agents that work on goals. Available as a hosted service or <a href=\"https://hub.docker.com/r/hejny/promptbook/\">self-hosted via Docker</a>.\n      </td>\n    </tr>\n    <tr>\n      <td><a href=\"https://github.com/webgptorg/book\">Book language</a></td>\n      <td>\n          Human-friendly, high-level language that abstracts away low-level details of AI. It allows to focus on personality, behavior, knowledge, and rules of AI agents rather than on models, parameters, and prompt engineering.\n          <hr>\n          There is also <a href=\"https://github.com/webgptorg/book-extension\">a plugin for VSCode</a> to support <code>.book</code> file extension\n      </td>\n    </tr>\n    <tr>\n      <td><a href=\"https://github.com/webgptorg/promptbook\">Promptbook Engine</a></td>\n      <td>\n          The open-source core that powers the Agents Server. Can also be used as a standalone TypeScript/JavaScript library to embed agent capabilities into your own applications.\n          Released as <a href=\"https://www.npmjs.com/package/@promptbook/core#-packages-for-developers\">multiple NPM packages</a>.\n      </td>\n    </tr>\n    \n  </tbody>\n</table>\n\n### 🌐 Community & Social Media\n\nJoin our growing community of developers and users:\n\n<table>\n  <thead>\n    <tr>\n      <th>Platform</th>\n      <th>Description</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <td><a href=\"https://discord.gg/x3QWNaa89N\">💬 Discord</a></td>\n      <td>Join our active developer community for discussions and support</td>\n    </tr>\n    <tr>\n      <td><a href=\"https://github.com/webgptorg/promptbook/discussions\">🗣️ GitHub Discussions</a></td>\n      <td>Technical discussions, feature requests, and community Q&A</td>\n    </tr>\n    <tr>\n      <td><a href=\"https://linkedin.com/company/promptbook\">👔 LinkedIn</a></td>\n      <td>Professional updates and industry insights</td>\n    </tr>\n    <tr>\n      <td><a href=\"https://www.facebook.com/61560776453536\">📱 Facebook</a></td>\n      <td>General announcements and community engagement</td>\n    </tr>\n    <tr>\n      <td><a href=\"https://ptbk.io\">🔗 ptbk.io</a></td>\n      <td>Official landing page with project information</td>\n    </tr>\n  </tbody>\n</table>\n\n### 🖼️ Product & Brand Channels\n\n#### Promptbook.studio\n\n<table>\n  <tbody>\n    <tr>\n      <td><a href=\"https://www.instagram.com/promptbook.studio/\">📸 Instagram @promptbook.studio</a></td>\n      <td>Visual updates, UI showcases, and design inspiration</td>\n    </tr>\n    \n  </tbody>\n</table>\n\n\n\n\n\n\n\n\n## 📚 Documentation\n\nSee detailed guides and API reference in the [docs](https://github.com/webgptorg/promptbook/discussions/categories/concepts) or [online](https://discord.gg/x3QWNaa89N).\n\n## 🔒 Security\n\nFor information on reporting security vulnerabilities, see our [Security Policy](./SECURITY.md).\n\n## 📦 Deployment & Packages\n\nThe fastest way to get started is with the **Agents Server**:\n\n-   🐋 **[Docker image](https://hub.docker.com/r/hejny/promptbook/)** - Self-host the Agents Server with full control over your data\n-   ☁️ **[Hosted Agents Server](https://gallery.ptbk.io/)** - Start creating agents immediately, no setup required\n\n### NPM Packages _(for developers embedding the Engine)_\n\nIf you want to embed the Promptbook Engine directly into your application, the library is divided into several packages published from a [single monorepo](https://github.com/webgptorg/promptbook).\nYou can install all of them at once:\n\n```bash\nnpm i ptbk\n```\n\nOr you can install them separately:\n\n> ⭐ Marked packages are worth to try first\n\n-   ⭐ **[ptbk](https://www.npmjs.com/package/ptbk)** - Bundle of all packages, when you want to install everything and you don't care about the size\n-   **[promptbook](https://www.npmjs.com/package/promptbook)** - Same as `ptbk`\n-   ⭐🧙‍♂️ **[@promptbook/wizard](https://www.npmjs.com/package/@promptbook/wizard)** - Wizard to just run the books in node without any struggle\n-   **[@promptbook/core](https://www.npmjs.com/package/@promptbook/core)** - Core of the library, it contains the main logic for promptbooks\n-   **[@promptbook/node](https://www.npmjs.com/package/@promptbook/node)** - Core of the library for Node.js environment\n-   **[@promptbook/browser](https://www.npmjs.com/package/@promptbook/browser)** - Core of the library for browser environment\n-   ⭐ **[@promptbook/utils](https://www.npmjs.com/package/@promptbook/utils)** - Utility functions used in the library but also useful for individual use in preprocessing and postprocessing LLM inputs and outputs\n-   **[@promptbook/markdown-utils](https://www.npmjs.com/package/@promptbook/markdown-utils)** - Utility functions used for processing markdown\n-   **[@promptbook/javascript](https://www.npmjs.com/package/@promptbook/javascript)** - Execution tools for javascript inside promptbooks\n-   **[@promptbook/openai](https://www.npmjs.com/package/@promptbook/openai)** - Execution tools for OpenAI API, wrapper around OpenAI SDK\n-   **[@promptbook/anthropic-claude](https://www.npmjs.com/package/@promptbook/anthropic-claude)** - Execution tools for Anthropic Claude API, wrapper around Anthropic Claude SDK \n-   **[@promptbook/vercel](https://www.npmjs.com/package/@promptbook/vercel)** - Adapter for Vercel functionalities\n-   **[@promptbook/google](https://www.npmjs.com/package/@promptbook/google)** - Integration with Google's Gemini API\n-   **[@promptbook/deepseek](https://www.npmjs.com/package/@promptbook/deepseek)** - Integration with [DeepSeek API](https://www.deepseek.com/)\n-   **[@promptbook/ollama](https://www.npmjs.com/package/@promptbook/ollama)** - Integration with [Ollama](https://ollama.com/) API\n-   **[@promptbook/azure-openai](https://www.npmjs.com/package/@promptbook/azure-openai)** - Execution tools for Azure OpenAI API\n\n-   **[@promptbook/fake-llm](https://www.npmjs.com/package/@promptbook/fake-llm)** - Mocked execution tools for testing the library and saving the tokens\n-   **[@promptbook/remote-client](https://www.npmjs.com/package/@promptbook/remote-client)** - Remote client for remote execution of promptbooks\n-   **[@promptbook/remote-server](https://www.npmjs.com/package/@promptbook/remote-server)** - Remote server for remote execution of promptbooks\n-   **[@promptbook/pdf](https://www.npmjs.com/package/@promptbook/pdf)** - Read knowledge from `.pdf` documents\n-   **[@promptbook/documents](https://www.npmjs.com/package/@promptbook/markitdown)** - Integration of [Markitdown by Microsoft](https://github.com/microsoft/markitdown)\n-   **[@promptbook/documents](https://www.npmjs.com/package/@promptbook/documents)** - Read knowledge from documents like `.docx`, `.odt`,…\n-   **[@promptbook/legacy-documents](https://www.npmjs.com/package/@promptbook/legacy-documents)** - Read knowledge from legacy documents like `.doc`, `.rtf`,…\n-   **[@promptbook/website-crawler](https://www.npmjs.com/package/@promptbook/website-crawler)** - Crawl knowledge from the web\n-   **[@promptbook/editable](https://www.npmjs.com/package/@promptbook/editable)** - Editable book as native javascript object with imperative object API\n-   **[@promptbook/templates](https://www.npmjs.com/package/@promptbook/templates)** - Useful templates and examples of books which can be used as a starting point\n-   **[@promptbook/types](https://www.npmjs.com/package/@promptbook/types)** - Just typescript types used in the library\n-   **[@promptbook/color](https://www.npmjs.com/package/@promptbook/color)** - Color manipulation library\n-   **[@promptbook/cli](https://www.npmjs.com/package/@promptbook/cli)** - Command line interface utilities for promptbooks\n\n\n\n### 🤖 Promptbook Coder\n\n`ptbk coder` is Promptbook's workflow layer for AI-assisted software changes. Instead of opening one chat and manually copy-pasting tasks, you keep a queue of coding prompts in `prompts/*.md`, let a coding agent execute the next ready task, and then verify the result before archiving the prompt.\n\nPromptbook Coder is **not another standalone coding model**. It is an orchestration layer over coding agents such as **GitHub Copilot**, **OpenAI Codex**, **Claude Code**, **Opencode**, **Cline**, and **Gemini CLI**. The difference is that Promptbook Coder adds a repeatable repository workflow on top of them:\n\n-   prompt files with explicit statuses like `[ ]`, `[^]`, `[x]`, and `[-]`\n-   automatic selection of the next runnable task, including priority support\n-   shared project context loaded from `AGENTS.md` by default\n-   automatic `git add`, commit, and push after each successful prompt\n-   dedicated coding-agent Git identity and optional GPG signing\n-   verification and repair flow for work that is done, partial, or broken\n-   helper commands for generating boilerplates and finding refactor prompts\n\nIn short: tools like Claude Code, Codex, or GitHub Copilot are the **engines**; Promptbook Coder is the **workflow** that keeps coding work structured, reviewable, and repeatable across many prompts.\n\n#### How the workflow works\n\n1. `ptbk coder init` prepares the project for the coder workflow, seeds project-owned generic templates in `prompts/templates/`, creates a starter `AGENTS.md` context file, adds helper `npm run coder:*` scripts, ensures `.gitignore` ignores `node_modules` and `/.promptbook`, creates missing `.gitattributes` for LF line endings, and configures VS Code prompt screenshots in `prompts/screenshots/`.\n2. `ptbk coder generate-boilerplates` creates prompt files in `prompts/`.\n3. You replace placeholder `@@@` sections with real coding tasks.\n4. `ptbk coder run` sends the next ready `[ ]` prompt to the selected coding agent and immediately marks it as in progress `[^]`, naming the harness, the model and the step which is running.\n5. Promptbook Coder marks the prompt as done `[x]`, records runner metadata, then stages, commits, and pushes the resulting changes.\n6. `ptbk coder verify` reviews completed prompts, archives finished files to `prompts/done/`, and appends a repair prompt when more work is needed.\n\nPrompts marked with `[-]` are not ready yet, prompts containing `@@@` are treated as not fully written, and prompts with more `!` markers have higher priority. A prompt left as `[^]` was interrupted in the middle of its implementation — the in-progress status is never reverted, so a killed or crashed coder always leaves that signal behind, and `--git-changes continue` resumes exactly that prompt with its uncommitted changes still in place.\n\n#### Features\n\n-   **Multi-runner execution:** `openai-codex`, `github-copilot`, `cline`, `claude-code`, `opencode`, `gemini`, `qwen-code`\n-   **Project defaults:** Developer, invocation cwd, and project `AGENTS.md`; `--agent`, `--path`, and `--context` independently override them\n-   **Reasoning control:** `--thinking-level low|medium|high|xhigh` for supported runners\n-   **Unattended or interactive runs:** default auto mode, or `--no-auto` to wait for user confirmation before each prompt\n-   **Git safety:** clean working tree check by default, or `--git-changes ignore` to keep the changes and `--git-changes continue` to resume an interrupted prompt\n-   **Opt-in remote pushes:** commits stay local unless you explicitly pass `--auto-push`\n-   **Prompt triage:** `--priority` to process only more important tasks first\n-   **Failure logging:** failed runs write a neighboring `.error.log`\n-   **Line-ending normalization:** changed files are normalized back to LF by default\n\n#### Local usage in this repository\n\nWhen working on Promptbook itself, the repository usually runs the CLI straight from source:\n\n```bash\nnpx ts-node ./src/cli/test/ptbk.ts coder init\n\nnpx ts-node ./src/cli/test/ptbk.ts coder generate-boilerplates --template prompts/templates/common.md\n\nnpx ts-node ./src/cli/test/ptbk.ts coder generate-boilerplates --template prompts/templates/agents-server.md\n\nnpx ts-node ./src/cli/test/ptbk.ts coder run --harness github-copilot --model gpt-5.4 --thinking-level xhigh --agent agents/coding/developer.book\n\nnpx ts-node ./src/cli/test/ptbk.ts coder run --harness github-copilot --model gpt-5.4 --thinking-level xhigh --agent agents/coding/developer.book --auto-push\n\nnpx ts-node ./src/cli/test/ptbk.ts coder run --harness github-copilot --model gpt-5.4 --thinking-level xhigh --agent agents/coding/developer.book --git-changes ignore\n\nnpx ts-node ./src/cli/test/ptbk.ts coder find-refactor-candidates\n\nnpx ts-node ./src/cli/test/ptbk.ts coder find-refactor-candidates --level xhigh\n\nnpx ts-node ./src/cli/test/ptbk.ts coder verify\n```\n\n#### Using `ptbk coder` in an external project\n\nIf you want to use the workflow in another repository, install the package and invoke the `ptbk` binary directly.\n\n```bash\nnpm install ptbk\n\nptbk coder init\n\nptbk coder generate-boilerplates\n\nptbk coder generate-boilerplates --template prompts/templates/common.md\n\nptbk coder run --harness github-copilot --model gpt-5.4 --thinking-level xhigh --agent agents/coding/developer.book --check \"npm run check\"\n\nptbk coder run --harness github-copilot --model gpt-5.4 --thinking-level xhigh --agent agents/coding/developer.book --auto-push\n\nptbk coder run --harness github-copilot --model gpt-5.4 --thinking-level xhigh --agent agents/coding/developer.book --check \"npm run check\" --git-changes ignore\n\nptbk coder find-refactor-candidates\n\nptbk coder find-refactor-candidates --level xhigh\n\nptbk coder verify\n```\n\n`ptbk coder init` also bootstraps a starter `AGENTS.md`, adds `package.json` scripts for the four main coder commands, adds `node_modules` and the shared `/.promptbook` temp ignore to `.gitignore`, and configures `.vscode/settings.json` so pasted images from `prompts/*.md` land in `prompts/screenshots/`. It creates a missing `.gitattributes` with `* text=auto eol=lf` and preserves existing attributes.\n\n#### What each command does\n\n| Command                               | What it does                                                                                                                                                                                                                                                                                                                                                                                                                                                                |\n| ------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --- | ------ | ---- | ----- | ------------------------------------------------------------------------ |\n| `ptbk coder init`                     | Creates `prompts/`, `prompts/done/`, the project-generic template files materialized in `prompts/templates/` (currently `common.md`), and a starter `AGENTS.md`; ensures `.env` contains `CODING_AGENT_GIT_NAME`, `CODING_AGENT_GIT_EMAIL`, and `CODING_AGENT_GIT_SIGNING_KEY`; adds helper coder scripts to `package.json`; ensures `.gitignore` contains `node_modules` and `/.promptbook`; creates missing `.gitattributes` with `* text=auto eol=lf`; and configures `.vscode/settings.json` to save pasted prompt images into `prompts/screenshots/`. |\n| `ptbk coder generate-boilerplates`    | Creates new prompt markdown files with fresh emoji tags so you can quickly fill in coding tasks; `--template` accepts either a built-in alias or a markdown file path relative to the project root.                                                                                                                                                                                                                                                                         |\n| `ptbk coder run`                      | Picks the next ready prompt, can run project checks before coding to stop or repair pre-existing failures, appends optional context, runs it through the selected coding agent, can optionally check each attempt with the project command and feed failing output back for retries, then marks success or failure, commits the result, and pushes only when `--auto-push` is enabled.                                                                                      |\n| `ptbk coder find-refactor-candidates` | Scans the repository for oversized or overpacked files and writes prompt files for likely refactors; `--level <xlow                                                                                                                                                                                                                                                                                                                                                         | low | medium | high | xhigh | extreme>` ranges from a very benevolent scan to a very aggressive sweep. |\n| `ptbk coder verify`                   | Walks through completed prompts, archives truly finished work, and adds follow-up repair prompts for unfinished results.                                                                                                                                                                                                                                                                                                                                                    |\n\n#### Most useful `ptbk coder run` flags\n\nA **check** is the project's aggregate validation: tests, linting, typechecking, builds, generated-code consistency,\nand other quality checks. `ptbk init` and `ptbk coder init` preserve an existing `scripts.check`, or compose available\nvalidation scripts and report their scope. Configure the failing setup placeholder if the project has none.\n\n```bash\nptbk coder run --harness openai-codex --check \"npm run check\" --check-before yes-and-fix\nptbk coder run --harness openai-codex --check \"npm run lint && npm run build && npm test\"\n```\n\nThe default preflight mode remains `no`. Enabled preflight uses `npm run check` when no command is supplied;\npost-prompt verification remains opt-in. Initial checks and repairs use the same command and actual process result.\nReplace retired `--test` and `--test-before` with `--check` and `--check-before`. Init migrates recognized generated\nscripts while preserving custom validation. For conflicts or custom callers, it reports the exact entries/files to\nreview: preserve the required validation in `check`, update references, then remove the unused legacy entry.\nAutomation that invokes `npm run test-for-ptbk-coder` must switch to `npm run check`. Restart an already-running\nCoder invocation with the new flags to release its captured legacy command; initialization creates no compatibility alias.\n\n| Flag                       | Purpose                                                                                                                                                                                               |\n| -------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |\n| `--harness <name>`         | Selects the coding harness.                                                                                                                                                                           |\n| `--agent <book>`           | Selects the primary Book; defaults to the selected project's `agents/developer.book`.                                                                                                                 |\n| `--path <directory>`       | Selects the project; defaults to invocation cwd. Relative paths start there, not at the CLI installation or enclosing Git root.                                                                       |\n| `--model <model>`          | Chooses the runner model; required for `openai-codex`, `gemini` and `qwen-code`, optional for `github-copilot`.                                                                                       |\n| `--context <text-or-file>` | Replaces the default project `AGENTS.md` with inline instructions or a project-relative file; an empty value disables context.                                                                        |\n| `--check <command>`        | Runs a verification command after each prompt attempt and feeds failing output back for retries.                                                                                                      |\n| `--check-before <mode>`    | Runs project checks before coding: `no` (default), `yes-and-fail` (stop with results), or `yes-and-fix` (create one repair prompt first); defaults to `npm run check` when enabled without `--check`. |\n| `--thinking-level <level>` | Sets reasoning effort for supported runners.                                                                                                                                                          |\n| `--no-auto`                | Waits for user confirmation before each prompt instead of running automatically through the queue.                                                                                                    |\n| `--git-changes <mode>`     | Decides what happens with a dirty working tree: `fail` (default), `ignore` to keep the changes, or `continue` to resume the single interrupted `[^]` prompt with them.                                |\n| `--priority <n>`           | Runs only prompts at or above the given priority.                                                                                                                                                     |\n| `--dry-run`                | Prints which prompts are ready instead of executing them.                                                                                                                                             |\n| `--allow-credits`          | Lets OpenAI Codex spend credits when required.                                                                                                                                                        |\n| `--auto-push`              | Pushes each successful coding-agent commit to the configured remote.                                                                                                                                  |\n| `--auto-migrate`           | Runs testing-server database migrations after each successful prompt.                                                                                                                                 |\n\n#### Typical usage pattern\n\n1. Initialize once with `ptbk coder init`.\n2. Customize `prompts/templates/*.md` if needed, then create or write prompt files in `prompts/`.\n3. Customize `agents/developer.book` and `AGENTS.md`; the runner selects both automatically. Use `--path` for another project or `--agent` and `--context` for explicit overrides.\n4. Run unattended batches by default, or pass `--no-auto` to confirm each prompt interactively.\n5. Finish with `ptbk coder verify` so resolved prompts are archived and broken ones get explicit repair follow-ups.\n\n\n\n\n## 📚 Dictionary\n\nThe following glossary is used to clarify certain concepts:\n\n### General LLM / AI terms\n\n-   **Prompt drift** is a phenomenon where the AI model starts to generate outputs that are not aligned with the original prompt. This can happen due to the model's training data, the prompt's wording, or the model's architecture.\n-   [**Pipeline, workflow scenario or chain** is a sequence of tasks that are executed in a specific order. In the context of AI, a pipeline can refer to a sequence of AI models that are used to process data.](https://github.com/webgptorg/promptbook/discussions/88)\n-   **Fine-tuning** is a process where a pre-trained AI model is further trained on a specific dataset to improve its performance on a specific task.\n-   **Zero-shot learning** is a machine learning paradigm where a model is trained to perform a task without any labeled examples. Instead, the model is provided with a description of the task and is expected to generate the correct output.\n-   **Few-shot learning** is a machine learning paradigm where a model is trained to perform a task with only a few labeled examples. This is in contrast to traditional machine learning, where models are trained on large datasets.\n-   **Meta-learning** is a machine learning paradigm where a model is trained on a variety of tasks and is able to learn new tasks with minimal additional training. This is achieved by learning a set of meta-parameters that can be quickly adapted to new tasks.\n-   **Retrieval-augmented generation** is a machine learning paradigm where a model generates text by retrieving relevant information from a large database of text. This approach combines the benefits of generative models and retrieval models.\n-   **Longtail** refers to non-common or rare events, items, or entities that are not well-represented in the training data of machine learning models. Longtail items are often challenging for models to predict accurately.\n\n_Note: This section is not a complete dictionary, more list of general AI / LLM terms that has connection with Promptbook_\n\n### 💯 Core concepts\n\n-   [📚 Collection of pipelines](https://github.com/webgptorg/promptbook/discussions/65)\n-   [📯 Pipeline](https://github.com/webgptorg/promptbook/discussions/64)\n-   [🙇‍♂️ Tasks and pipeline sections](https://github.com/webgptorg/promptbook/discussions/88)\n-   [🤼 Personas](https://github.com/webgptorg/promptbook/discussions/22)\n-   [⭕ Parameters](https://github.com/webgptorg/promptbook/discussions/83)\n-   [🚀 Pipeline execution](https://github.com/webgptorg/promptbook/discussions/84)\n-   [🧪 Expectations](https://github.com/webgptorg/promptbook/discussions/30) - Define what outputs should look like and how they're validated\n-   [✂️ Postprocessing](https://github.com/webgptorg/promptbook/discussions/31) - How outputs are refined after generation\n-   [🔣 Words not tokens](https://github.com/webgptorg/promptbook/discussions/29) - The human-friendly way to think about text generation\n-   [☯ Separation of concerns](https://github.com/webgptorg/promptbook/discussions/32) - How Book language organizes different aspects of AI workflows\n\n### Advanced concepts\n\n<table>\n  <tr>\n    <th>Data & Knowledge Management</th>\n    <th>Pipeline Control</th>\n  </tr>\n  <tr>\n    <td>\n      <ul>\n        <li><a href=\"https://github.com/webgptorg/promptbook/discussions/41\">📚 Knowledge (RAG)</a> - Retrieve and use external information</li>\n        <li><a href=\"https://github.com/webgptorg/promptbook/discussions/54\">📽 Media handling</a> - Working with images, audio, video, spreadsheets</li>\n        <li><a href=\"https://github.com/webgptorg/promptbook/discussions/40\">🔴 Anomaly detection</a> - Identifying unusual patterns or outputs</li>\n      </ul>\n    </td>\n    <td>\n      <ul>\n        <li><a href=\"https://github.com/webgptorg/promptbook/discussions/89\">🌏 Remote server</a> - Executing workflows on remote infrastructure</li>\n        <li><a href=\"https://github.com/webgptorg/promptbook/discussions/66\">🃏 Jokers (conditions)</a> - Adding conditional logic to workflows</li>\n        <li><a href=\"https://github.com/webgptorg/promptbook/discussions/35\">🔳 Metaprompting</a> - Creating prompts that generate other prompts</li>\n      </ul>\n    </td>\n  </tr>\n  <tr>\n    <th>Language & Output Control</th>\n    <th>Advanced Generation</th>\n  </tr>\n  <tr>\n    <td>\n      <ul>\n        <li><a href=\"https://github.com/webgptorg/promptbook/discussions/53\">🌏 Linguistically typed languages</a> - Type systems for natural language</li>\n        <li><a href=\"https://github.com/webgptorg/promptbook/discussions/42\">🌍 Auto-Translations</a> - Automatic multilingual support</li>\n        <li><a href=\"https://github.com/webgptorg/promptbook/discussions/39\">👮 Agent adversary expectations</a> - Safety and control mechanisms</li>\n      </ul>\n    </td>\n    <td>\n      <ul>\n        <li><a href=\"https://github.com/webgptorg/promptbook/discussions/37\">🔙 Expectation-aware generation</a> - Outputs that meet defined criteria</li>\n        <li><a href=\"https://github.com/webgptorg/promptbook/discussions/33\">⏳ Just-in-time fine-tuning</a> - Dynamic model adaptation</li>\n      </ul>\n    </td>\n  </tr>\n</table>\n\n<p align=\"center\"><a href=\"https://github.com/webgptorg/promptbook/discussions/categories/concepts\">🔍 View more concepts</a></p>\n\n\n\n## � Agents Server\n\nThe **[Agents Server](https://gallery.ptbk.io/)** is the primary way to use Promptbook. It is a production-ready platform where you create, deploy, and manage persistent AI agents that work toward goals. Agents remember context across conversations, collaborate in teams, and follow the rules and knowledge you define in the Book language.\n\n-   **Hosted** at [gallery.ptbk.io](https://gallery.ptbk.io/) - start creating agents immediately\n-   **Self-hosted** via [Docker](https://hub.docker.com/r/hejny/promptbook/) - full control over your data and infrastructure\n-   **API** for integrating agents into your own applications\n\n## 🚂 Promptbook Engine\n\nThe Engine is the open-source core that powers the Agents Server. If you need to embed agent capabilities directly into your TypeScript/JavaScript application, you can use it as a standalone library.\n\n![Schema of Promptbook Engine](./documents/promptbook-engine.svg)\n\n## ➕➖ When to use Promptbook?\n\n### ➕ When to use\n\n-   When you want to **deploy persistent AI agents** that work on goals for your company\n-   When you need agents with **specific personalities, knowledge, and rules** tailored to your business\n-   When you want agents that **collaborate in teams** and consult each other\n-   When you need to **integrate AI agents into your existing applications** via API\n-   When you want to **self-host** your AI agents with full control over data and infrastructure\n-   When you are writing an app that generates complex things via LLM - like **websites, articles, presentations, code, stories, songs**,...\n-   When you want to **version** your agent definitions and **test multiple versions**\n-   When you want to **log** agent execution and backtrace issues\n\n[See more](https://github.com/webgptorg/promptbook/discussions/111)\n\n### ➖ When not to use\n\n-   When a single simple prompt already works fine for your job\n-   When [OpenAI Assistant (GPTs)](https://help.openai.com/en/articles/8673914-gpts-vs-assistants) is enough for you\n-   When you need streaming _(this may be implemented in the future, [see discussion](https://github.com/webgptorg/promptbook/discussions/102))_\n-   When you need to use something other than JavaScript or TypeScript _(other languages are on the way, [see the discussion](https://github.com/webgptorg/promptbook/discussions/101))_\n-   When your main focus is on something other than text - like images, audio, video, spreadsheets _(other media types may be added in the future, [see discussion](https://github.com/webgptorg/promptbook/discussions/103))_\n-   When you need to use recursion _([see the discussion](https://github.com/webgptorg/promptbook/discussions/38))_\n\n[See more](https://github.com/webgptorg/promptbook/discussions/112)\n\n## 🐜 Known issues\n\n-   [🤸‍♂️ Iterations not working yet](https://github.com/webgptorg/promptbook/discussions/55)\n-   [⤵️ Imports not working yet](https://github.com/webgptorg/promptbook/discussions/34)\n\n## 🧼 Intentionally not implemented features\n\n-   [➿ No recursion](https://github.com/webgptorg/promptbook/discussions/38)\n-   [🏳 There are no types, just strings](https://github.com/webgptorg/promptbook/discussions/52)\n\n## ❔ FAQ\n\nIf you have a question [start a discussion](https://github.com/webgptorg/promptbook/discussions/), [open an issue](https://github.com/webgptorg/promptbook/issues) or [write me an email](https://www.pavolhejny.com/contact).\n\n-   [❔ Why not just use the OpenAI SDK / Anthropic Claude SDK / ...?](https://github.com/webgptorg/promptbook/discussions/114)\n-   [❔ How is it different from the OpenAI`s GPTs?](https://github.com/webgptorg/promptbook/discussions/118)\n-   [❔ How is it different from the Langchain?](https://github.com/webgptorg/promptbook/discussions/115)\n-   [❔ How is it different from the DSPy?](https://github.com/webgptorg/promptbook/discussions/117)\n-   [❔ How is it different from _anything_?](https://github.com/webgptorg/promptbook/discussions?discussions_q=is%3Aopen+label%3A%22Promptbook+vs%22)\n-   [❔ Is Promptbook using RAG _(Retrieval-Augmented Generation)_?](https://github.com/webgptorg/promptbook/discussions/123)\n-   [❔ Is Promptbook using function calling?](https://github.com/webgptorg/promptbook/discussions/124)\n\n## 📅 Changelog\n\nSee [CHANGELOG.md](./CHANGELOG.md)\n\n## 📜 License\n\nThis project is licensed under [BUSL 1.1](./LICENSE.md).\n\n## 🤝 Contributing\n\nWe welcome contributions! See [CONTRIBUTING.md](./CONTRIBUTING.md) for guidelines.\n\nYou can also ⭐ star the project, [follow us on GitHub](https://github.com/hejny) or [various other social networks](https://www.pavolhejny.com/contact/).We are open to [pull requests, feedback, and suggestions](./CONTRIBUTING.md).\n\n## 🆘 Support & Community\n\nNeed help with Book language? We're here for you!\n\n-   💬 [Join our Discord community](https://discord.gg/x3QWNaa89N) for real-time support\n-   📝 [Browse our GitHub discussions](https://github.com/webgptorg/promptbook/discussions) for FAQs and community knowledge\n-   🐛 [Report issues](https://github.com/webgptorg/book/issues) for bugs or feature requests\n-   📚 Visit [ptbk.io](https://ptbk.io) for more resources and documentation\n-   📧 Contact us directly through the channels listed in our [signpost](./SIGNPOST.md)\n\nWe welcome contributions and feedback to make Book language better for everyone!","publish_time":1734966781000,"_cnpm_publish_time":1734966781000,"dist-tags":{"latest":"0.114.0-50","legacy":"0.114.0-51"}}