@promptbook/components 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 CHANGED
@@ -647,26 +647,27 @@ ptbk coder verify
647
647
  | ------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --- | ------ | ---- | ----- | ------------------------------------------------------------------------ |
648
648
  | `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 `/.promptbook`; and configures `.vscode/settings.json` to save pasted prompt images into `prompts/screenshots/`. |
649
649
  | `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. |
650
- | `ptbk coder run` | Picks the next ready prompt, appends optional context, runs it through the selected coding agent, can optionally verify each attempt with a shell test command and feed failing output back for retries, then marks success or failure, commits the result, and pushes only when `--auto-push` is enabled. |
650
+ | `ptbk coder run` | Picks the next ready prompt, can run tests before coding to stop or repair pre-existing failures, appends optional context, runs it through the selected coding agent, can optionally verify each attempt with a shell test command and feed failing output back for retries, then marks success or failure, commits the result, and pushes only when `--auto-push` is enabled. |
651
651
  | `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. |
652
652
  | `ptbk coder verify` | Walks through completed prompts, archives truly finished work, and adds follow-up repair prompts for unfinished results. |
653
653
 
654
654
  #### Most useful `ptbk coder run` flags
655
655
 
656
- | Flag | Purpose |
657
- | -------------------------- | -------------------------------------------------------------------------------------------------- |
658
- | `--harness <name>` | Selects the coding harness. |
659
- | `--model <model>` | Chooses the runner model; required for `openai-codex` and `gemini`, optional for `github-copilot`. |
660
- | `--context <text-or-file>` | Appends extra instructions inline or from a file like `AGENTS.md`. |
661
- | `--test <command>` | Runs a verification command after each prompt attempt and feeds failing output back for retries. |
662
- | `--thinking-level <level>` | Sets reasoning effort for supported runners. |
663
- | `--no-auto` | Waits for user confirmation before each prompt instead of running automatically through the queue. |
664
- | `--ignore-git-changes` | Disables the clean-working-tree guard. |
665
- | `--priority <n>` | Runs only prompts at or above the given priority. |
666
- | `--dry-run` | Prints which prompts are ready instead of executing them. |
667
- | `--allow-credits` | Lets OpenAI Codex spend credits when required. |
668
- | `--auto-push` | Pushes each successful coding-agent commit to the configured remote. |
669
- | `--auto-migrate` | Runs testing-server database migrations after each successful prompt. |
656
+ | Flag | Purpose |
657
+ | -------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
658
+ | `--harness <name>` | Selects the coding harness. |
659
+ | `--model <model>` | Chooses the runner model; required for `openai-codex` and `gemini`, optional for `github-copilot`. |
660
+ | `--context <text-or-file>` | Appends extra instructions inline or from a file like `AGENTS.md`. |
661
+ | `--test <command>` | Runs a verification command after each prompt attempt and feeds failing output back for retries. |
662
+ | `--test-before <mode>` | Runs tests before coding: `no` (default), `yes-and-fail` (stop with results), or `yes-and-fix` (create one repair prompt first); defaults to `npm test` when enabled without `--test`. |
663
+ | `--thinking-level <level>` | Sets reasoning effort for supported runners. |
664
+ | `--no-auto` | Waits for user confirmation before each prompt instead of running automatically through the queue. |
665
+ | `--ignore-git-changes` | Disables the clean-working-tree guard. |
666
+ | `--priority <n>` | Runs only prompts at or above the given priority. |
667
+ | `--dry-run` | Prints which prompts are ready instead of executing them. |
668
+ | `--allow-credits` | Lets OpenAI Codex spend credits when required. |
669
+ | `--auto-push` | Pushes each successful coding-agent commit to the configured remote. |
670
+ | `--auto-migrate` | Runs testing-server database migrations after each successful prompt. |
670
671
 
671
672
  #### Typical usage pattern
672
673
 
package/esm/index.es.js CHANGED
@@ -41,7 +41,7 @@ const BOOK_LANGUAGE_VERSION = '2.0.0';
41
41
  * @generated
42
42
  * @see https://github.com/webgptorg/promptbook
43
43
  */
44
- const PROMPTBOOK_ENGINE_VERSION = '0.114.0-0';
44
+ const PROMPTBOOK_ENGINE_VERSION = '0.114.0-2';
45
45
  /**
46
46
  * TODO: string_promptbook_version should be constrained to the all versions of Promptbook engine
47
47
  * Note: [💞] Ignore a discrepancy between file name and entity name
@@ -28093,6 +28093,14 @@ const DETAILS_PLACEHOLDER_WRAPPED_REGEX = new RegExp(`<p>\\s*(${DETAILS_PLACEHOL
28093
28093
  * @private utility of `renderMarkdown`
28094
28094
  */
28095
28095
  const INLINE_REFERENCE_REGEX = /\[\[([^\]\r\n]+?)\]\]/g;
28096
+ /**
28097
+ * Pattern matching ordinary markdown links that can be promoted to inline reference chips.
28098
+ *
28099
+ * Images are intentionally captured separately and left unchanged by the replacement helper.
28100
+ *
28101
+ * @private utility of `renderMarkdown`
28102
+ */
28103
+ const MARKDOWN_INLINE_REFERENCE_LINK_REGEX = /(!?)\[([^\]\r\n]*)\]\(\s*(<[^>\r\n]+>|[^)\s]+)(?:\s+(?:"[^"\r\n]*"|'[^'\r\n]*'|\([^)]*\)))?\s*\)/g;
28096
28104
  /**
28097
28105
  * Collection of math delimiter definitions.
28098
28106
  */
@@ -28330,11 +28338,12 @@ const CHAT_MARKDOWN_CONVERTER = createChatMarkdownConverter();
28330
28338
  * outer `<details>` and optional `<summary>` markup untouched.
28331
28339
  *
28332
28340
  * @param detailsBlock - Raw `<details>...</details>` HTML captured from markdown.
28341
+ * @param options - Markdown rendering options to reuse for the details body.
28333
28342
  * @returns `<details>` HTML whose body has been converted from markdown to HTML.
28334
28343
  *
28335
28344
  * @private utility of `renderMarkdown`
28336
28345
  */
28337
- function renderDetailsBlock(detailsBlock) {
28346
+ function renderDetailsBlock(detailsBlock, options) {
28338
28347
  var _a, _b;
28339
28348
  const openTagMatch = detailsBlock.match(/^<details\b[^>]*>/i);
28340
28349
  const closeTagMatch = detailsBlock.match(/<\/details\s*>$/i);
@@ -28347,7 +28356,7 @@ function renderDetailsBlock(detailsBlock) {
28347
28356
  const summaryMatch = innerContent.match(/^(\s*<summary\b[^>]*>[\s\S]*?<\/summary\s*>)([\s\S]*)$/i);
28348
28357
  const summaryHtml = (_a = summaryMatch === null || summaryMatch === void 0 ? void 0 : summaryMatch[1]) !== null && _a !== void 0 ? _a : '';
28349
28358
  const bodyMarkdown = ((_b = summaryMatch === null || summaryMatch === void 0 ? void 0 : summaryMatch[2]) !== null && _b !== void 0 ? _b : innerContent);
28350
- const renderedBody = renderMarkdown(bodyMarkdown);
28359
+ const renderedBody = renderMarkdown(bodyMarkdown, options);
28351
28360
  return `${openTag}${summaryHtml}${renderedBody}${closeTag}`;
28352
28361
  }
28353
28362
  /**
@@ -28384,16 +28393,17 @@ function maskMarkdownCodeSegments(markdown) {
28384
28393
  * processes their content.
28385
28394
  *
28386
28395
  * @param markdown - Markdown text that may contain raw HTML `<details>` blocks.
28396
+ * @param options - Markdown rendering options to reuse for the details body.
28387
28397
  * @returns Masked markdown and a restore helper that returns `string_html`.
28388
28398
  *
28389
28399
  * @private utility of `renderMarkdown`
28390
28400
  */
28391
- function maskDetailsBlocks(markdown) {
28401
+ function maskDetailsBlocks(markdown, options) {
28392
28402
  const blocks = [];
28393
28403
  DETAILS_BLOCK_REGEX.lastIndex = 0;
28394
28404
  const masked = markdown.replace(DETAILS_BLOCK_REGEX, (match) => {
28395
28405
  const placeholder = `${DETAILS_PLACEHOLDER_PREFIX}${blocks.length}__`;
28396
- blocks.push(renderDetailsBlock(match));
28406
+ blocks.push(renderDetailsBlock(match, options));
28397
28407
  return placeholder;
28398
28408
  });
28399
28409
  return {
@@ -28494,6 +28504,79 @@ function createMarkdownInlineReferenceByKey(references) {
28494
28504
  }
28495
28505
  return referenceByKey;
28496
28506
  }
28507
+ /**
28508
+ * Returns whether a href starts with a configured source href prefix.
28509
+ *
28510
+ * @param href - Markdown link destination.
28511
+ * @param sourceHrefPrefix - Configured source href prefix.
28512
+ * @returns Whether the href belongs to the source prefix.
28513
+ *
28514
+ * @private utility of `renderMarkdown`
28515
+ */
28516
+ function doesHrefStartWithSourceHrefPrefix(href, sourceHrefPrefix) {
28517
+ if (href === sourceHrefPrefix) {
28518
+ return true;
28519
+ }
28520
+ const normalizedSourceHrefPrefix = sourceHrefPrefix.endsWith('/') ? sourceHrefPrefix : `${sourceHrefPrefix}/`;
28521
+ return href.startsWith(normalizedSourceHrefPrefix);
28522
+ }
28523
+ /**
28524
+ * Returns a comparable path for an absolute href when the configured source prefix is relative.
28525
+ *
28526
+ * @param href - Href to normalize.
28527
+ * @returns Absolute URL pathname or the original href when it is relative/invalid.
28528
+ *
28529
+ * @private utility of `renderMarkdown`
28530
+ */
28531
+ function resolveAbsoluteHrefPath(href) {
28532
+ try {
28533
+ return new URL(href).pathname;
28534
+ }
28535
+ catch (_a) {
28536
+ return href;
28537
+ }
28538
+ }
28539
+ /**
28540
+ * Returns whether one markdown link destination belongs to one inline reference.
28541
+ *
28542
+ * Relative project paths also match absolute URLs on the current server, which keeps
28543
+ * server-generated relative links and model-generated absolute links consistent.
28544
+ *
28545
+ * @param reference - Candidate inline reference.
28546
+ * @param href - Markdown link destination.
28547
+ * @returns Whether the href should render as the reference chip.
28548
+ *
28549
+ * @private utility of `renderMarkdown`
28550
+ */
28551
+ function doesMarkdownInlineReferenceMatchHref(reference, href) {
28552
+ const normalizedHref = href.trim();
28553
+ return (reference.sourceHrefPrefixes || []).some((sourceHrefPrefix) => {
28554
+ const normalizedSourceHrefPrefix = sourceHrefPrefix.trim();
28555
+ if (!normalizedSourceHrefPrefix) {
28556
+ return false;
28557
+ }
28558
+ if (doesHrefStartWithSourceHrefPrefix(normalizedHref, normalizedSourceHrefPrefix)) {
28559
+ return true;
28560
+ }
28561
+ const isRelativeSourceHrefPrefix = !/^[a-z][a-z0-9+.-]*:/i.test(normalizedSourceHrefPrefix);
28562
+ const isAbsoluteHref = /^[a-z][a-z0-9+.-]*:/i.test(normalizedHref);
28563
+ return (isRelativeSourceHrefPrefix &&
28564
+ isAbsoluteHref &&
28565
+ doesHrefStartWithSourceHrefPrefix(resolveAbsoluteHrefPath(normalizedHref), normalizedSourceHrefPrefix));
28566
+ });
28567
+ }
28568
+ /**
28569
+ * Finds the inline reference represented by a markdown link destination.
28570
+ *
28571
+ * @param references - Inline references available to the markdown renderer.
28572
+ * @param href - Markdown link destination.
28573
+ * @returns Matching reference or `undefined` when the href is unrelated.
28574
+ *
28575
+ * @private utility of `renderMarkdown`
28576
+ */
28577
+ function findMarkdownInlineReferenceByHref(references, href) {
28578
+ return references.find((reference) => doesMarkdownInlineReferenceMatchHref(reference, href));
28579
+ }
28497
28580
  /**
28498
28581
  * Renders one inline reference as raw HTML that is sanitized by the shared markdown sanitizer.
28499
28582
  *
@@ -28573,10 +28656,18 @@ function applyMarkdownInlineReferences(markdown, options) {
28573
28656
  if (referenceByKey.size === 0) {
28574
28657
  return markdown;
28575
28658
  }
28576
- return markdown.replace(INLINE_REFERENCE_REGEX, (match, rawReference) => {
28659
+ const markdownWithInlineReferenceTokens = markdown.replace(INLINE_REFERENCE_REGEX, (match, rawReference) => {
28577
28660
  const reference = referenceByKey.get(normalizeMarkdownInlineReferenceKey(rawReference));
28578
28661
  return reference ? renderMarkdownInlineReferenceHtml(reference, className) : match;
28579
28662
  });
28663
+ return markdownWithInlineReferenceTokens.replace(MARKDOWN_INLINE_REFERENCE_LINK_REGEX, (match, imageMarker, _linkLabel, rawHref) => {
28664
+ if (imageMarker) {
28665
+ return match;
28666
+ }
28667
+ const href = rawHref.replace(/^<|>$/g, '');
28668
+ const reference = findMarkdownInlineReferenceByHref(references, href);
28669
+ return reference ? renderMarkdownInlineReferenceHtml(reference, className) : match;
28670
+ });
28580
28671
  }
28581
28672
  /**
28582
28673
  * Loads KaTeX CSS in browser environments that need to display math output.
@@ -28614,7 +28705,7 @@ function renderMarkdown(markdown, options) {
28614
28705
  const converter = options ? createChatMarkdownConverter(options) : CHAT_MARKDOWN_CONVERTER;
28615
28706
  try {
28616
28707
  const normalizedMarkdown = normalizeMarkdownSublists(markdown);
28617
- const { masked: maskedMarkdown, restore: restoreDetails } = maskDetailsBlocks(normalizedMarkdown);
28708
+ const { masked: maskedMarkdown, restore: restoreDetails } = maskDetailsBlocks(normalizedMarkdown, options);
28618
28709
  const { masked: codeMaskedMarkdown, restore: restoreCode } = maskMarkdownCodeSegments(maskedMarkdown);
28619
28710
  const referencedMarkdown = applyMarkdownInlineReferences(codeMaskedMarkdown, options);
28620
28711
  const inlineReferenceMarkdown = restoreCode(referencedMarkdown);