storybook-addon-playwright 5.4.0 → 5.5.0

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
@@ -88,7 +88,7 @@ Every option is documented with a JSDoc comment explaining its purpose, paramete
88
88
 
89
89
  ### AI prompt helper for `getScreenshotTitle`
90
90
 
91
- This package exports `createScreenshotTitlePrompt(data, options)` so you can build a strict LLM prompt for title generation and reuse it across projects.
91
+ The AI helper is exported from `storybook-addon-playwright/ai` as `createScreenshotTitlePrompt(data, options)` so you can build a strict LLM prompt for title generation and reuse it across projects.
92
92
 
93
93
  The helper is designed for small models too. It asks the model to:
94
94
 
@@ -101,7 +101,7 @@ Example:
101
101
 
102
102
  ```js
103
103
  const { setConfig } = require('storybook-addon-playwright/configs');
104
- const { createScreenshotTitlePrompt } = require('storybook-addon-playwright');
104
+ const { createScreenshotTitlePrompt } = require('storybook-addon-playwright/ai');
105
105
 
106
106
  async function askLlm(prompt) {
107
107
  // Call your LLM provider here and return parsed JSON.
package/ai.d.ts ADDED
@@ -0,0 +1 @@
1
+ export * from './dist/ai/index';
package/ai.js ADDED
@@ -0,0 +1 @@
1
+ module.exports = require('./dist/ai/index');
@@ -0,0 +1,45 @@
1
+ import { G as GenerateScreenshotTitleInput } from '../story-DSpVrFjG.mjs';
2
+ import 'playwright';
3
+ import 'zod';
4
+
5
+ interface CreateScreenshotTitlePromptOptions {
6
+ /**
7
+ * Maximum number of characters allowed in the returned title.
8
+ *
9
+ * @default 80
10
+ */
11
+ maxTitleLength?: number;
12
+ /**
13
+ * Fallback title the model should use when input is too sparse.
14
+ *
15
+ * @default 'Should render correctly.'
16
+ */
17
+ fallbackTitle?: string;
18
+ /**
19
+ * Whether the generated title should include the browser type when useful.
20
+ *
21
+ * @default true
22
+ */
23
+ includeBrowserType?: boolean;
24
+ /**
25
+ * Whether the generated title can include the story id.
26
+ *
27
+ * @default false
28
+ */
29
+ includeStoryId?: boolean;
30
+ /**
31
+ * Additional instructions for the output format, appended to the prompt's output contract section.
32
+ *
33
+ * @default 'Return only the generated title as string, without any additional text or formatting.'
34
+ */
35
+ outputPrompt?: string | string[];
36
+ }
37
+ /**
38
+ * Creates a strict prompt for LLMs to generate a screenshot title from Storybook data.
39
+ *
40
+ * The prompt enforces JSON-only output in the form:
41
+ * `{"title":"..."}`.
42
+ */
43
+ declare function createScreenshotTitlePrompt(data: GenerateScreenshotTitleInput, options?: CreateScreenshotTitlePromptOptions): string;
44
+
45
+ export { type CreateScreenshotTitlePromptOptions, createScreenshotTitlePrompt };
@@ -0,0 +1,45 @@
1
+ import { G as GenerateScreenshotTitleInput } from '../story-DSpVrFjG.js';
2
+ import 'playwright';
3
+ import 'zod';
4
+
5
+ interface CreateScreenshotTitlePromptOptions {
6
+ /**
7
+ * Maximum number of characters allowed in the returned title.
8
+ *
9
+ * @default 80
10
+ */
11
+ maxTitleLength?: number;
12
+ /**
13
+ * Fallback title the model should use when input is too sparse.
14
+ *
15
+ * @default 'Should render correctly.'
16
+ */
17
+ fallbackTitle?: string;
18
+ /**
19
+ * Whether the generated title should include the browser type when useful.
20
+ *
21
+ * @default true
22
+ */
23
+ includeBrowserType?: boolean;
24
+ /**
25
+ * Whether the generated title can include the story id.
26
+ *
27
+ * @default false
28
+ */
29
+ includeStoryId?: boolean;
30
+ /**
31
+ * Additional instructions for the output format, appended to the prompt's output contract section.
32
+ *
33
+ * @default 'Return only the generated title as string, without any additional text or formatting.'
34
+ */
35
+ outputPrompt?: string | string[];
36
+ }
37
+ /**
38
+ * Creates a strict prompt for LLMs to generate a screenshot title from Storybook data.
39
+ *
40
+ * The prompt enforces JSON-only output in the form:
41
+ * `{"title":"..."}`.
42
+ */
43
+ declare function createScreenshotTitlePrompt(data: GenerateScreenshotTitleInput, options?: CreateScreenshotTitlePromptOptions): string;
44
+
45
+ export { type CreateScreenshotTitlePromptOptions, createScreenshotTitlePrompt };
@@ -0,0 +1,3 @@
1
+ 'use strict';var o={fallbackTitle:"Should render correctly.",includeBrowserType:true,includeStoryId:false,maxTitleLength:80,outputPrompt:"Return only the generated title as string, without any additional text or formatting."},i=2,s=10;function a(e={}){let n=Number.isFinite(e.maxTitleLength)?Math.max(s,Math.floor(e.maxTitleLength)):o.maxTitleLength,t=(Array.isArray(e.outputPrompt)?e.outputPrompt:typeof e.outputPrompt=="string"?[e.outputPrompt]:[o.outputPrompt]).map(r=>r.trim()).map(r=>"- "+r);return {fallbackTitle:typeof e.fallbackTitle=="string"&&e.fallbackTitle.trim()?e.fallbackTitle.trim():o.fallbackTitle,includeBrowserType:e.includeBrowserType??o.includeBrowserType,includeStoryId:e.includeStoryId??o.includeStoryId,maxTitleLength:n,outputPrompt:t}}function l(e,n){let t=a(n),r=JSON.stringify(e,null,i);return ["You are a screenshot title generator for Storybook Playwright.","Your goal is to read the input JSON and produce one clear screenshot title.","","Follow this process internally before writing the final answer:","1) Parse INPUT_JSON as JSON.","2) Review every top-level and nested field and understand what each field says about the screenshot context.","3) Decide the most important details for naming this screenshot.","4) Build a short, human-friendly title.","","Field guide:","- story.name: story display name.","- story.title: Storybook group/title path.","- story.changedArgs: args changed from defaults; high-priority signal for title.","- story.initialArgs: default args for the story; use for context only.","- story.argTypes: arg metadata; use only when it clarifies changedArgs.","- story.parameters: Storybook-level metadata; only use if it impacts screenshot meaning.","- story.filePath: source story file path.","- story.id: unique Storybook story id.","- browser.type: browser engine (chromium, firefox, webkit).","- browser.options: browser/device options such as viewport and device profile.","- screenshotOptions: screenshot behavior options that may change output meaning.","","Title rules:",`- Maximum length: ${t.maxTitleLength} characters.`,`- ${t.includeBrowserType?"Include browser type only when it adds useful context.":"Do not include browser type in the title."}`,`- ${t.includeStoryId?"You may include story.id when needed for uniqueness.":"Do not include story.id unless no other unique context exists."}`,"- Prefer changedArgs details when present.","- Avoid filler words and generic phrases.","- Title must be plain text (no markdown, no quotes around the full title).","","Output contract (strict):",...t.outputPrompt,`- If context is insufficient, use fallback title: ${JSON.stringify(t.fallbackTitle)}`,"","INPUT_JSON:",r].join(`
2
+ `)}exports.createScreenshotTitlePrompt=l;//# sourceMappingURL=index.js.map
3
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/ai/generate-screenshot-title-prompt.ts"],"names":["DEFAULT_OPTIONS","INPUT_JSON_INDENT","MIN_TITLE_LENGTH","normalizeOptions","options","maxTitleLength","outputPrompt","instruction","x","createScreenshotTitlePrompt","data","resolved","inputJson"],"mappings":"aAuCA,IAAMA,EAAgE,CACpE,aAAA,CAAe,2BACf,kBAAA,CAAoB,IAAA,CACpB,eAAgB,KAAA,CAChB,cAAA,CAAgB,GAChB,YAAA,CACE,uFACJ,EAEMC,CAAAA,CAAoB,CAAA,CACpBC,EAAmB,EAAA,CAEzB,SAASC,EACPC,CAAAA,CAA8C,EAAC,CACD,CAC9C,IAAMC,CAAAA,CAAiB,MAAA,CAAO,SAASD,CAAAA,CAAQ,cAAc,EACzD,IAAA,CAAK,GAAA,CAAIF,EAAkB,IAAA,CAAK,KAAA,CAAME,EAAQ,cAAwB,CAAC,EACvEJ,CAAAA,CAAgB,cAAA,CAEdM,GACJ,KAAA,CAAM,OAAA,CAAQF,CAAAA,CAAQ,YAAY,EAC9BA,CAAAA,CAAQ,YAAA,CACR,OAAOA,CAAAA,CAAQ,YAAA,EAAiB,SAC9B,CAACA,CAAAA,CAAQ,YAAY,CAAA,CACrB,CAACJ,EAAgB,YAAY,CAAA,EAElC,IAAKO,CAAAA,EAAiBA,CAAAA,CAAuB,MAAM,CAAA,CACnD,IAAKC,CAAAA,EAAM,IAAA,CAAOA,CAAC,CAAA,CAEtB,OAAO,CACL,aAAA,CACE,OAAOJ,EAAQ,aAAA,EAAkB,QAAA,EAAYA,EAAQ,aAAA,CAAc,IAAA,GAC/DA,CAAAA,CAAQ,aAAA,CAAc,MAAK,CAC3BJ,CAAAA,CAAgB,cACtB,kBAAA,CAAoBI,CAAAA,CAAQ,kBAAA,EAAsBJ,CAAAA,CAAgB,mBAClE,cAAA,CAAgBI,CAAAA,CAAQ,gBAAkBJ,CAAAA,CAAgB,cAAA,CAC1D,eAAAK,CAAAA,CACA,YAAA,CAAcC,CAChB,CACF,CAQO,SAASG,CAAAA,CACdC,CAAAA,CACAN,EACQ,CACR,IAAMO,EAAWR,CAAAA,CAAiBC,CAAO,CAAA,CACnCQ,CAAAA,CAAY,KAAK,SAAA,CAAUF,CAAAA,CAAM,KAAMT,CAAiB,CAAA,CAE9D,OAAO,CACL,gEAAA,CACA,8EACA,EAAA,CACA,iEAAA,CACA,+BACA,8GAAA,CACA,kEAAA,CACA,0CACA,EAAA,CACA,cAAA,CACA,oCACA,4CAAA,CACA,kFAAA,CACA,wEAAA,CACA,yEAAA,CACA,2FACA,2CAAA,CACA,wCAAA,CACA,8DACA,gFAAA,CACA,kFAAA,CACA,GACA,cAAA,CACA,CAAA,kBAAA,EAAqBU,EAAS,cAAc,CAAA,YAAA,CAAA,CAC5C,KAAKA,CAAAA,CAAS,kBAAA,CAAqB,yDAA2D,2CAA2C,CAAA,CAAA,CACzI,KAAKA,CAAAA,CAAS,cAAA,CAAiB,uDAAyD,gEAAgE,CAAA,CAAA,CACxJ,6CACA,2CAAA,CACA,4EAAA,CACA,GACA,2BAAA,CACA,GAAGA,EAAS,YAAA,CACZ,CAAA,kDAAA,EAAqD,KAAK,SAAA,CAAUA,CAAAA,CAAS,aAAa,CAAC,CAAA,CAAA,CAC3F,GACA,aAAA,CACAC,CACF,EAAE,IAAA,CAAK;AAAA,CAAI,CACb","file":"index.js","sourcesContent":["import type { GenerateScreenshotTitleInput } from '../schema';\n\nexport interface CreateScreenshotTitlePromptOptions {\n /**\n * Maximum number of characters allowed in the returned title.\n *\n * @default 80\n */\n maxTitleLength?: number;\n\n /**\n * Fallback title the model should use when input is too sparse.\n *\n * @default 'Should render correctly.'\n */\n fallbackTitle?: string;\n\n /**\n * Whether the generated title should include the browser type when useful.\n *\n * @default true\n */\n includeBrowserType?: boolean;\n\n /**\n * Whether the generated title can include the story id.\n *\n * @default false\n */\n includeStoryId?: boolean;\n\n /**\n * Additional instructions for the output format, appended to the prompt's output contract section.\n *\n * @default 'Return only the generated title as string, without any additional text or formatting.'\n */\n outputPrompt?: string | string[];\n}\n\nconst DEFAULT_OPTIONS: Required<CreateScreenshotTitlePromptOptions> = {\n fallbackTitle: 'Should render correctly.',\n includeBrowserType: true,\n includeStoryId: false,\n maxTitleLength: 80,\n outputPrompt:\n 'Return only the generated title as string, without any additional text or formatting.',\n};\n\nconst INPUT_JSON_INDENT = 2;\nconst MIN_TITLE_LENGTH = 10;\n\nfunction normalizeOptions(\n options: CreateScreenshotTitlePromptOptions = {},\n): Required<CreateScreenshotTitlePromptOptions> {\n const maxTitleLength = Number.isFinite(options.maxTitleLength)\n ? Math.max(MIN_TITLE_LENGTH, Math.floor(options.maxTitleLength as number))\n : DEFAULT_OPTIONS.maxTitleLength;\n\n const outputPrompt = (\n Array.isArray(options.outputPrompt)\n ? options.outputPrompt\n : typeof options.outputPrompt === 'string'\n ? [options.outputPrompt]\n : [DEFAULT_OPTIONS.outputPrompt]\n )\n .map((instruction) => (instruction as string).trim())\n .map((x) => '- ' + x);\n\n return {\n fallbackTitle:\n typeof options.fallbackTitle === 'string' && options.fallbackTitle.trim()\n ? options.fallbackTitle.trim()\n : DEFAULT_OPTIONS.fallbackTitle,\n includeBrowserType: options.includeBrowserType ?? DEFAULT_OPTIONS.includeBrowserType,\n includeStoryId: options.includeStoryId ?? DEFAULT_OPTIONS.includeStoryId,\n maxTitleLength,\n outputPrompt: outputPrompt,\n };\n}\n\n/**\n * Creates a strict prompt for LLMs to generate a screenshot title from Storybook data.\n *\n * The prompt enforces JSON-only output in the form:\n * `{\"title\":\"...\"}`.\n */\nexport function createScreenshotTitlePrompt(\n data: GenerateScreenshotTitleInput,\n options?: CreateScreenshotTitlePromptOptions,\n): string {\n const resolved = normalizeOptions(options);\n const inputJson = JSON.stringify(data, null, INPUT_JSON_INDENT);\n\n return [\n 'You are a screenshot title generator for Storybook Playwright.',\n 'Your goal is to read the input JSON and produce one clear screenshot title.',\n '',\n 'Follow this process internally before writing the final answer:',\n '1) Parse INPUT_JSON as JSON.',\n '2) Review every top-level and nested field and understand what each field says about the screenshot context.',\n '3) Decide the most important details for naming this screenshot.',\n '4) Build a short, human-friendly title.',\n '',\n 'Field guide:',\n '- story.name: story display name.',\n '- story.title: Storybook group/title path.',\n '- story.changedArgs: args changed from defaults; high-priority signal for title.',\n '- story.initialArgs: default args for the story; use for context only.',\n '- story.argTypes: arg metadata; use only when it clarifies changedArgs.',\n '- story.parameters: Storybook-level metadata; only use if it impacts screenshot meaning.',\n '- story.filePath: source story file path.',\n '- story.id: unique Storybook story id.',\n '- browser.type: browser engine (chromium, firefox, webkit).',\n '- browser.options: browser/device options such as viewport and device profile.',\n '- screenshotOptions: screenshot behavior options that may change output meaning.',\n '',\n 'Title rules:',\n `- Maximum length: ${resolved.maxTitleLength} characters.`,\n `- ${resolved.includeBrowserType ? 'Include browser type only when it adds useful context.' : 'Do not include browser type in the title.'}`,\n `- ${resolved.includeStoryId ? 'You may include story.id when needed for uniqueness.' : 'Do not include story.id unless no other unique context exists.'}`,\n '- Prefer changedArgs details when present.',\n '- Avoid filler words and generic phrases.',\n '- Title must be plain text (no markdown, no quotes around the full title).',\n '',\n 'Output contract (strict):',\n ...resolved.outputPrompt,\n `- If context is insufficient, use fallback title: ${JSON.stringify(resolved.fallbackTitle)}`,\n '',\n 'INPUT_JSON:',\n inputJson,\n ].join('\\n');\n}\n"]}
@@ -0,0 +1,3 @@
1
+ var o={fallbackTitle:"Should render correctly.",includeBrowserType:true,includeStoryId:false,maxTitleLength:80,outputPrompt:"Return only the generated title as string, without any additional text or formatting."},i=2,s=10;function a(e={}){let n=Number.isFinite(e.maxTitleLength)?Math.max(s,Math.floor(e.maxTitleLength)):o.maxTitleLength,t=(Array.isArray(e.outputPrompt)?e.outputPrompt:typeof e.outputPrompt=="string"?[e.outputPrompt]:[o.outputPrompt]).map(r=>r.trim()).map(r=>"- "+r);return {fallbackTitle:typeof e.fallbackTitle=="string"&&e.fallbackTitle.trim()?e.fallbackTitle.trim():o.fallbackTitle,includeBrowserType:e.includeBrowserType??o.includeBrowserType,includeStoryId:e.includeStoryId??o.includeStoryId,maxTitleLength:n,outputPrompt:t}}function l(e,n){let t=a(n),r=JSON.stringify(e,null,i);return ["You are a screenshot title generator for Storybook Playwright.","Your goal is to read the input JSON and produce one clear screenshot title.","","Follow this process internally before writing the final answer:","1) Parse INPUT_JSON as JSON.","2) Review every top-level and nested field and understand what each field says about the screenshot context.","3) Decide the most important details for naming this screenshot.","4) Build a short, human-friendly title.","","Field guide:","- story.name: story display name.","- story.title: Storybook group/title path.","- story.changedArgs: args changed from defaults; high-priority signal for title.","- story.initialArgs: default args for the story; use for context only.","- story.argTypes: arg metadata; use only when it clarifies changedArgs.","- story.parameters: Storybook-level metadata; only use if it impacts screenshot meaning.","- story.filePath: source story file path.","- story.id: unique Storybook story id.","- browser.type: browser engine (chromium, firefox, webkit).","- browser.options: browser/device options such as viewport and device profile.","- screenshotOptions: screenshot behavior options that may change output meaning.","","Title rules:",`- Maximum length: ${t.maxTitleLength} characters.`,`- ${t.includeBrowserType?"Include browser type only when it adds useful context.":"Do not include browser type in the title."}`,`- ${t.includeStoryId?"You may include story.id when needed for uniqueness.":"Do not include story.id unless no other unique context exists."}`,"- Prefer changedArgs details when present.","- Avoid filler words and generic phrases.","- Title must be plain text (no markdown, no quotes around the full title).","","Output contract (strict):",...t.outputPrompt,`- If context is insufficient, use fallback title: ${JSON.stringify(t.fallbackTitle)}`,"","INPUT_JSON:",r].join(`
2
+ `)}export{l as createScreenshotTitlePrompt};//# sourceMappingURL=index.mjs.map
3
+ //# sourceMappingURL=index.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/ai/generate-screenshot-title-prompt.ts"],"names":["DEFAULT_OPTIONS","INPUT_JSON_INDENT","MIN_TITLE_LENGTH","normalizeOptions","options","maxTitleLength","outputPrompt","instruction","x","createScreenshotTitlePrompt","data","resolved","inputJson"],"mappings":"AAuCA,IAAMA,EAAgE,CACpE,aAAA,CAAe,2BACf,kBAAA,CAAoB,IAAA,CACpB,eAAgB,KAAA,CAChB,cAAA,CAAgB,GAChB,YAAA,CACE,uFACJ,EAEMC,CAAAA,CAAoB,CAAA,CACpBC,EAAmB,EAAA,CAEzB,SAASC,EACPC,CAAAA,CAA8C,EAAC,CACD,CAC9C,IAAMC,CAAAA,CAAiB,MAAA,CAAO,SAASD,CAAAA,CAAQ,cAAc,EACzD,IAAA,CAAK,GAAA,CAAIF,EAAkB,IAAA,CAAK,KAAA,CAAME,EAAQ,cAAwB,CAAC,EACvEJ,CAAAA,CAAgB,cAAA,CAEdM,GACJ,KAAA,CAAM,OAAA,CAAQF,CAAAA,CAAQ,YAAY,EAC9BA,CAAAA,CAAQ,YAAA,CACR,OAAOA,CAAAA,CAAQ,YAAA,EAAiB,SAC9B,CAACA,CAAAA,CAAQ,YAAY,CAAA,CACrB,CAACJ,EAAgB,YAAY,CAAA,EAElC,IAAKO,CAAAA,EAAiBA,CAAAA,CAAuB,MAAM,CAAA,CACnD,IAAKC,CAAAA,EAAM,IAAA,CAAOA,CAAC,CAAA,CAEtB,OAAO,CACL,aAAA,CACE,OAAOJ,EAAQ,aAAA,EAAkB,QAAA,EAAYA,EAAQ,aAAA,CAAc,IAAA,GAC/DA,CAAAA,CAAQ,aAAA,CAAc,MAAK,CAC3BJ,CAAAA,CAAgB,cACtB,kBAAA,CAAoBI,CAAAA,CAAQ,kBAAA,EAAsBJ,CAAAA,CAAgB,mBAClE,cAAA,CAAgBI,CAAAA,CAAQ,gBAAkBJ,CAAAA,CAAgB,cAAA,CAC1D,eAAAK,CAAAA,CACA,YAAA,CAAcC,CAChB,CACF,CAQO,SAASG,CAAAA,CACdC,CAAAA,CACAN,EACQ,CACR,IAAMO,EAAWR,CAAAA,CAAiBC,CAAO,CAAA,CACnCQ,CAAAA,CAAY,KAAK,SAAA,CAAUF,CAAAA,CAAM,KAAMT,CAAiB,CAAA,CAE9D,OAAO,CACL,gEAAA,CACA,8EACA,EAAA,CACA,iEAAA,CACA,+BACA,8GAAA,CACA,kEAAA,CACA,0CACA,EAAA,CACA,cAAA,CACA,oCACA,4CAAA,CACA,kFAAA,CACA,wEAAA,CACA,yEAAA,CACA,2FACA,2CAAA,CACA,wCAAA,CACA,8DACA,gFAAA,CACA,kFAAA,CACA,GACA,cAAA,CACA,CAAA,kBAAA,EAAqBU,EAAS,cAAc,CAAA,YAAA,CAAA,CAC5C,KAAKA,CAAAA,CAAS,kBAAA,CAAqB,yDAA2D,2CAA2C,CAAA,CAAA,CACzI,KAAKA,CAAAA,CAAS,cAAA,CAAiB,uDAAyD,gEAAgE,CAAA,CAAA,CACxJ,6CACA,2CAAA,CACA,4EAAA,CACA,GACA,2BAAA,CACA,GAAGA,EAAS,YAAA,CACZ,CAAA,kDAAA,EAAqD,KAAK,SAAA,CAAUA,CAAAA,CAAS,aAAa,CAAC,CAAA,CAAA,CAC3F,GACA,aAAA,CACAC,CACF,EAAE,IAAA,CAAK;AAAA,CAAI,CACb","file":"index.mjs","sourcesContent":["import type { GenerateScreenshotTitleInput } from '../schema';\n\nexport interface CreateScreenshotTitlePromptOptions {\n /**\n * Maximum number of characters allowed in the returned title.\n *\n * @default 80\n */\n maxTitleLength?: number;\n\n /**\n * Fallback title the model should use when input is too sparse.\n *\n * @default 'Should render correctly.'\n */\n fallbackTitle?: string;\n\n /**\n * Whether the generated title should include the browser type when useful.\n *\n * @default true\n */\n includeBrowserType?: boolean;\n\n /**\n * Whether the generated title can include the story id.\n *\n * @default false\n */\n includeStoryId?: boolean;\n\n /**\n * Additional instructions for the output format, appended to the prompt's output contract section.\n *\n * @default 'Return only the generated title as string, without any additional text or formatting.'\n */\n outputPrompt?: string | string[];\n}\n\nconst DEFAULT_OPTIONS: Required<CreateScreenshotTitlePromptOptions> = {\n fallbackTitle: 'Should render correctly.',\n includeBrowserType: true,\n includeStoryId: false,\n maxTitleLength: 80,\n outputPrompt:\n 'Return only the generated title as string, without any additional text or formatting.',\n};\n\nconst INPUT_JSON_INDENT = 2;\nconst MIN_TITLE_LENGTH = 10;\n\nfunction normalizeOptions(\n options: CreateScreenshotTitlePromptOptions = {},\n): Required<CreateScreenshotTitlePromptOptions> {\n const maxTitleLength = Number.isFinite(options.maxTitleLength)\n ? Math.max(MIN_TITLE_LENGTH, Math.floor(options.maxTitleLength as number))\n : DEFAULT_OPTIONS.maxTitleLength;\n\n const outputPrompt = (\n Array.isArray(options.outputPrompt)\n ? options.outputPrompt\n : typeof options.outputPrompt === 'string'\n ? [options.outputPrompt]\n : [DEFAULT_OPTIONS.outputPrompt]\n )\n .map((instruction) => (instruction as string).trim())\n .map((x) => '- ' + x);\n\n return {\n fallbackTitle:\n typeof options.fallbackTitle === 'string' && options.fallbackTitle.trim()\n ? options.fallbackTitle.trim()\n : DEFAULT_OPTIONS.fallbackTitle,\n includeBrowserType: options.includeBrowserType ?? DEFAULT_OPTIONS.includeBrowserType,\n includeStoryId: options.includeStoryId ?? DEFAULT_OPTIONS.includeStoryId,\n maxTitleLength,\n outputPrompt: outputPrompt,\n };\n}\n\n/**\n * Creates a strict prompt for LLMs to generate a screenshot title from Storybook data.\n *\n * The prompt enforces JSON-only output in the form:\n * `{\"title\":\"...\"}`.\n */\nexport function createScreenshotTitlePrompt(\n data: GenerateScreenshotTitleInput,\n options?: CreateScreenshotTitlePromptOptions,\n): string {\n const resolved = normalizeOptions(options);\n const inputJson = JSON.stringify(data, null, INPUT_JSON_INDENT);\n\n return [\n 'You are a screenshot title generator for Storybook Playwright.',\n 'Your goal is to read the input JSON and produce one clear screenshot title.',\n '',\n 'Follow this process internally before writing the final answer:',\n '1) Parse INPUT_JSON as JSON.',\n '2) Review every top-level and nested field and understand what each field says about the screenshot context.',\n '3) Decide the most important details for naming this screenshot.',\n '4) Build a short, human-friendly title.',\n '',\n 'Field guide:',\n '- story.name: story display name.',\n '- story.title: Storybook group/title path.',\n '- story.changedArgs: args changed from defaults; high-priority signal for title.',\n '- story.initialArgs: default args for the story; use for context only.',\n '- story.argTypes: arg metadata; use only when it clarifies changedArgs.',\n '- story.parameters: Storybook-level metadata; only use if it impacts screenshot meaning.',\n '- story.filePath: source story file path.',\n '- story.id: unique Storybook story id.',\n '- browser.type: browser engine (chromium, firefox, webkit).',\n '- browser.options: browser/device options such as viewport and device profile.',\n '- screenshotOptions: screenshot behavior options that may change output meaning.',\n '',\n 'Title rules:',\n `- Maximum length: ${resolved.maxTitleLength} characters.`,\n `- ${resolved.includeBrowserType ? 'Include browser type only when it adds useful context.' : 'Do not include browser type in the title.'}`,\n `- ${resolved.includeStoryId ? 'You may include story.id when needed for uniqueness.' : 'Do not include story.id unless no other unique context exists.'}`,\n '- Prefer changedArgs details when present.',\n '- Avoid filler words and generic phrases.',\n '- Title must be plain text (no markdown, no quotes around the full title).',\n '',\n 'Output contract (strict):',\n ...resolved.outputPrompt,\n `- If context is insufficient, use fallback title: ${JSON.stringify(resolved.fallbackTitle)}`,\n '',\n 'INPUT_JSON:',\n inputJson,\n ].join('\\n');\n}\n"]}
@@ -2,12 +2,13 @@ import { appRouter } from '../../trpc/router.mjs';
2
2
  import '@material-ui/core';
3
3
  import 'playwright';
4
4
  import 'ts-to-json';
5
- import '../../request-B60Gnj7P.mjs';
5
+ import '../../story-DSpVrFjG.mjs';
6
6
  import 'zod';
7
7
  import '@trpc/server';
8
8
  import 'node:http';
9
9
  import 'jest-image-snapshot';
10
- import '../../image-diff-DeB-XSUP.mjs';
10
+ import '../../image-diff-BDN_FVyD.mjs';
11
+ import '../../request-CGNOwtQo.mjs';
11
12
  import '../../get-screenshot-paths-BhXNedbs.mjs';
12
13
 
13
14
 
@@ -2,12 +2,13 @@ import { appRouter } from '../../trpc/router.js';
2
2
  import '@material-ui/core';
3
3
  import 'playwright';
4
4
  import 'ts-to-json';
5
- import '../../request-B60Gnj7P.js';
5
+ import '../../story-DSpVrFjG.js';
6
6
  import 'zod';
7
7
  import '@trpc/server';
8
8
  import 'node:http';
9
9
  import 'jest-image-snapshot';
10
- import '../../image-diff-DwK_Ui8E.js';
10
+ import '../../image-diff-BKKtLPxv.js';
11
+ import '../../request-DVZ6cFCg.js';
11
12
  import '../../get-screenshot-paths-BhXNedbs.js';
12
13
 
13
14
 
@@ -1,5 +1,6 @@
1
1
  import { S as ScreenshotPathInfo } from './get-screenshot-paths-BhXNedbs.mjs';
2
- import { R as RequestData } from './request-B60Gnj7P.mjs';
2
+ import { R as RequestData } from './request-CGNOwtQo.mjs';
3
+ import './story-DSpVrFjG.mjs';
3
4
  import 'playwright';
4
5
  import 'zod';
5
6
 
@@ -1,5 +1,6 @@
1
1
  import { S as ScreenshotPathInfo } from './get-screenshot-paths-BhXNedbs.js';
2
- import { R as RequestData } from './request-B60Gnj7P.js';
2
+ import { R as RequestData } from './request-DVZ6cFCg.js';
3
+ import './story-DSpVrFjG.js';
3
4
  import 'playwright';
4
5
  import 'zod';
5
6
 
@@ -1,4 +1,4 @@
1
- import { I as ImageDiffResultOutput } from './request-B60Gnj7P.js';
1
+ import { I as ImageDiffResultOutput } from './story-DSpVrFjG.mjs';
2
2
 
3
3
  type DiffDirection = 'horizontal' | 'vertical';
4
4
  type ImageDiffResult = ImageDiffResultOutput;
@@ -1,4 +1,4 @@
1
- import { I as ImageDiffResultOutput } from './request-B60Gnj7P.mjs';
1
+ import { I as ImageDiffResultOutput } from './story-DSpVrFjG.js';
2
2
 
3
3
  type DiffDirection = 'horizontal' | 'vertical';
4
4
  type ImageDiffResult = ImageDiffResultOutput;
package/dist/index.d.mts CHANGED
@@ -1,45 +1,10 @@
1
- import { G as GenerateScreenshotTitleInput } from './request-B60Gnj7P.mjs';
2
1
  export { getScreenshots } from './get-screenshots.mjs';
3
2
  export { runImageDiff } from './run-image-diff.mjs';
4
3
  export { toMatchScreenshots } from './to-match-screenshots.mjs';
4
+ import './get-screenshot-paths-BhXNedbs.mjs';
5
+ import './request-CGNOwtQo.mjs';
6
+ import './story-DSpVrFjG.mjs';
5
7
  import 'playwright';
6
8
  import 'zod';
7
- import './get-screenshot-paths-BhXNedbs.mjs';
8
- import './image-diff-DeB-XSUP.mjs';
9
+ import './image-diff-BDN_FVyD.mjs';
9
10
  import 'jest-image-snapshot';
10
-
11
- interface CreateScreenshotTitlePromptOptions {
12
- /**
13
- * Maximum number of characters allowed in the returned title.
14
- *
15
- * @default 80
16
- */
17
- maxTitleLength?: number;
18
- /**
19
- * Fallback title the model should use when input is too sparse.
20
- *
21
- * @default 'Should render correctly.'
22
- */
23
- fallbackTitle?: string;
24
- /**
25
- * Whether the generated title should include the browser type when useful.
26
- *
27
- * @default true
28
- */
29
- includeBrowserType?: boolean;
30
- /**
31
- * Whether the generated title can include the story id.
32
- *
33
- * @default false
34
- */
35
- includeStoryId?: boolean;
36
- }
37
- /**
38
- * Creates a strict prompt for LLMs to generate a screenshot title from Storybook data.
39
- *
40
- * The prompt enforces JSON-only output in the form:
41
- * `{"title":"..."}`.
42
- */
43
- declare function createScreenshotTitlePrompt(data: GenerateScreenshotTitleInput, options?: CreateScreenshotTitlePromptOptions): string;
44
-
45
- export { type CreateScreenshotTitlePromptOptions, createScreenshotTitlePrompt };
package/dist/index.d.ts CHANGED
@@ -1,45 +1,10 @@
1
- import { G as GenerateScreenshotTitleInput } from './request-B60Gnj7P.js';
2
1
  export { getScreenshots } from './get-screenshots.js';
3
2
  export { runImageDiff } from './run-image-diff.js';
4
3
  export { toMatchScreenshots } from './to-match-screenshots.js';
4
+ import './get-screenshot-paths-BhXNedbs.js';
5
+ import './request-DVZ6cFCg.js';
6
+ import './story-DSpVrFjG.js';
5
7
  import 'playwright';
6
8
  import 'zod';
7
- import './get-screenshot-paths-BhXNedbs.js';
8
- import './image-diff-DwK_Ui8E.js';
9
+ import './image-diff-BKKtLPxv.js';
9
10
  import 'jest-image-snapshot';
10
-
11
- interface CreateScreenshotTitlePromptOptions {
12
- /**
13
- * Maximum number of characters allowed in the returned title.
14
- *
15
- * @default 80
16
- */
17
- maxTitleLength?: number;
18
- /**
19
- * Fallback title the model should use when input is too sparse.
20
- *
21
- * @default 'Should render correctly.'
22
- */
23
- fallbackTitle?: string;
24
- /**
25
- * Whether the generated title should include the browser type when useful.
26
- *
27
- * @default true
28
- */
29
- includeBrowserType?: boolean;
30
- /**
31
- * Whether the generated title can include the story id.
32
- *
33
- * @default false
34
- */
35
- includeStoryId?: boolean;
36
- }
37
- /**
38
- * Creates a strict prompt for LLMs to generate a screenshot title from Storybook data.
39
- *
40
- * The prompt enforces JSON-only output in the form:
41
- * `{"title":"..."}`.
42
- */
43
- declare function createScreenshotTitlePrompt(data: GenerateScreenshotTitleInput, options?: CreateScreenshotTitlePromptOptions): string;
44
-
45
- export { type CreateScreenshotTitlePromptOptions, createScreenshotTitlePrompt };