storybook-addon-playwright 5.4.0 → 5.4.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 +2 -2
- package/ai.d.ts +1 -0
- package/ai.js +1 -0
- package/dist/ai/index.d.mts +39 -0
- package/dist/ai/index.d.ts +39 -0
- package/dist/ai/index.js +3 -0
- package/dist/ai/index.js.map +1 -0
- package/dist/ai/index.mjs +3 -0
- package/dist/ai/index.mjs.map +1 -0
- package/dist/api/server/routes.d.mts +3 -2
- package/dist/api/server/routes.d.ts +3 -2
- package/dist/get-screenshots.d.mts +2 -1
- package/dist/get-screenshots.d.ts +2 -1
- package/dist/{image-diff-DwK_Ui8E.d.ts → image-diff-BDN_FVyD.d.mts} +1 -1
- package/dist/{image-diff-DeB-XSUP.d.mts → image-diff-BKKtLPxv.d.ts} +1 -1
- package/dist/index.d.mts +4 -39
- package/dist/index.d.ts +4 -39
- package/dist/index.js +3 -4
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +3 -4
- package/dist/index.mjs.map +1 -1
- package/dist/register.js +9 -9
- package/dist/register.js.map +1 -1
- package/dist/register.mjs +9 -9
- package/dist/register.mjs.map +1 -1
- package/dist/request-CGNOwtQo.d.mts +8 -0
- package/dist/request-DVZ6cFCg.d.ts +8 -0
- package/dist/run-image-diff.d.mts +3 -2
- package/dist/run-image-diff.d.ts +3 -2
- package/dist/{request-B60Gnj7P.d.mts → story-DSpVrFjG.d.mts} +22 -27
- package/dist/{request-B60Gnj7P.d.ts → story-DSpVrFjG.d.ts} +22 -27
- package/dist/trpc/router.d.mts +4 -3
- package/dist/trpc/router.d.ts +4 -3
- package/package.json +3 -1
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
|
-
|
|
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,39 @@
|
|
|
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
|
+
/**
|
|
32
|
+
* Creates a strict prompt for LLMs to generate a screenshot title from Storybook data.
|
|
33
|
+
*
|
|
34
|
+
* The prompt enforces JSON-only output in the form:
|
|
35
|
+
* `{"title":"..."}`.
|
|
36
|
+
*/
|
|
37
|
+
declare function createScreenshotTitlePrompt(data: GenerateScreenshotTitleInput, options?: CreateScreenshotTitlePromptOptions): string;
|
|
38
|
+
|
|
39
|
+
export { type CreateScreenshotTitlePromptOptions, createScreenshotTitlePrompt };
|
|
@@ -0,0 +1,39 @@
|
|
|
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
|
+
/**
|
|
32
|
+
* Creates a strict prompt for LLMs to generate a screenshot title from Storybook data.
|
|
33
|
+
*
|
|
34
|
+
* The prompt enforces JSON-only output in the form:
|
|
35
|
+
* `{"title":"..."}`.
|
|
36
|
+
*/
|
|
37
|
+
declare function createScreenshotTitlePrompt(data: GenerateScreenshotTitleInput, options?: CreateScreenshotTitlePromptOptions): string;
|
|
38
|
+
|
|
39
|
+
export { type CreateScreenshotTitlePromptOptions, createScreenshotTitlePrompt };
|
package/dist/ai/index.js
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
'use strict';var r={fallbackTitle:"Should render correctly.",includeBrowserType:true,includeStoryId:false,maxTitleLength:80},i=2,l=10;function s(e={}){let o=Number.isFinite(e.maxTitleLength)?Math.max(l,Math.floor(e.maxTitleLength)):r.maxTitleLength;return {fallbackTitle:typeof e.fallbackTitle=="string"&&e.fallbackTitle.trim()?e.fallbackTitle.trim():r.fallbackTitle,includeBrowserType:e.includeBrowserType??r.includeBrowserType,includeStoryId:e.includeStoryId??r.includeStoryId,maxTitleLength:o}}function a(e,o){let t=s(o),n=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):","- Return JSON only.","- Return exactly one object with exactly one key: title.",'- Shape: {"title":"<generated title>"}',`- If context is insufficient, use fallback title: ${JSON.stringify(t.fallbackTitle)}`,"","INPUT_JSON:",n].join(`
|
|
2
|
+
`)}exports.createScreenshotTitlePrompt=a;//# 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","createScreenshotTitlePrompt","data","resolved","inputJson"],"mappings":"aAgCA,IAAMA,CAAAA,CAAgE,CACpE,aAAA,CAAe,0BAAA,CACf,mBAAoB,IAAA,CACpB,cAAA,CAAgB,KAAA,CAChB,cAAA,CAAgB,EAClB,CAAA,CAEMC,CAAAA,CAAoB,CAAA,CACpBC,EAAmB,EAAA,CAEzB,SAASC,CAAAA,CACPC,CAAAA,CAA8C,EAAC,CACD,CAC9C,IAAMC,EAAiB,MAAA,CAAO,QAAA,CAASD,CAAAA,CAAQ,cAAc,EACzD,IAAA,CAAK,GAAA,CAAIF,CAAAA,CAAkB,IAAA,CAAK,MAAME,CAAAA,CAAQ,cAAwB,CAAC,CAAA,CACvEJ,CAAAA,CAAgB,cAAA,CAEpB,OAAO,CACL,cACE,OAAOI,CAAAA,CAAQ,aAAA,EAAkB,QAAA,EAAYA,EAAQ,aAAA,CAAc,IAAA,EAAK,CACpEA,CAAAA,CAAQ,cAAc,IAAA,EAAK,CAC3BJ,CAAAA,CAAgB,aAAA,CACtB,kBAAA,CAAoBI,CAAAA,CAAQ,kBAAA,EAAsBJ,CAAAA,CAAgB,mBAClE,cAAA,CAAgBI,CAAAA,CAAQ,cAAA,EAAkBJ,CAAAA,CAAgB,eAC1D,cAAA,CAAAK,CACF,CACF,CAQO,SAASC,CAAAA,CACdC,CAAAA,CACAH,CAAAA,CACQ,CACR,IAAMI,CAAAA,CAAWL,CAAAA,CAAiBC,CAAO,EACnCK,CAAAA,CAAY,IAAA,CAAK,SAAA,CAAUF,CAAAA,CAAM,KAAMN,CAAiB,CAAA,CAE9D,OAAO,CACL,iEACA,6EAAA,CACA,EAAA,CACA,iEAAA,CACA,8BAAA,CACA,8GAAA,CACA,kEAAA,CACA,yCAAA,CACA,EAAA,CACA,eACA,mCAAA,CACA,4CAAA,CACA,kFAAA,CACA,wEAAA,CACA,0EACA,0FAAA,CACA,2CAAA,CACA,wCAAA,CACA,6DAAA,CACA,iFACA,kFAAA,CACA,EAAA,CACA,cAAA,CACA,CAAA,kBAAA,EAAqBO,CAAAA,CAAS,cAAc,CAAA,YAAA,CAAA,CAC5C,CAAA,EAAA,EAAKA,EAAS,kBAAA,CAAqB,wDAAA,CAA2D,2CAA2C,CAAA,CAAA,CACzI,KAAKA,CAAAA,CAAS,cAAA,CAAiB,sDAAA,CAAyD,gEAAgE,GACxJ,4CAAA,CACA,2CAAA,CACA,4EAAA,CACA,EAAA,CACA,2BAAA,CACA,qBAAA,CACA,0DAAA,CACA,wCAAA,CACA,qDAAqD,IAAA,CAAK,SAAA,CAAUA,CAAAA,CAAS,aAAa,CAAC,CAAA,CAAA,CAC3F,EAAA,CACA,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\nconst DEFAULT_OPTIONS: Required<CreateScreenshotTitlePromptOptions> = {\n fallbackTitle: 'Should render correctly.',\n includeBrowserType: true,\n includeStoryId: false,\n maxTitleLength: 80,\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 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 };\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 '- Return JSON only.',\n '- Return exactly one object with exactly one key: title.',\n '- Shape: {\"title\":\"<generated title>\"}',\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 r={fallbackTitle:"Should render correctly.",includeBrowserType:true,includeStoryId:false,maxTitleLength:80},i=2,l=10;function s(e={}){let o=Number.isFinite(e.maxTitleLength)?Math.max(l,Math.floor(e.maxTitleLength)):r.maxTitleLength;return {fallbackTitle:typeof e.fallbackTitle=="string"&&e.fallbackTitle.trim()?e.fallbackTitle.trim():r.fallbackTitle,includeBrowserType:e.includeBrowserType??r.includeBrowserType,includeStoryId:e.includeStoryId??r.includeStoryId,maxTitleLength:o}}function a(e,o){let t=s(o),n=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):","- Return JSON only.","- Return exactly one object with exactly one key: title.",'- Shape: {"title":"<generated title>"}',`- If context is insufficient, use fallback title: ${JSON.stringify(t.fallbackTitle)}`,"","INPUT_JSON:",n].join(`
|
|
2
|
+
`)}export{a 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","createScreenshotTitlePrompt","data","resolved","inputJson"],"mappings":"AAgCA,IAAMA,CAAAA,CAAgE,CACpE,aAAA,CAAe,0BAAA,CACf,mBAAoB,IAAA,CACpB,cAAA,CAAgB,KAAA,CAChB,cAAA,CAAgB,EAClB,CAAA,CAEMC,CAAAA,CAAoB,CAAA,CACpBC,EAAmB,EAAA,CAEzB,SAASC,CAAAA,CACPC,CAAAA,CAA8C,EAAC,CACD,CAC9C,IAAMC,EAAiB,MAAA,CAAO,QAAA,CAASD,CAAAA,CAAQ,cAAc,EACzD,IAAA,CAAK,GAAA,CAAIF,CAAAA,CAAkB,IAAA,CAAK,MAAME,CAAAA,CAAQ,cAAwB,CAAC,CAAA,CACvEJ,CAAAA,CAAgB,cAAA,CAEpB,OAAO,CACL,cACE,OAAOI,CAAAA,CAAQ,aAAA,EAAkB,QAAA,EAAYA,EAAQ,aAAA,CAAc,IAAA,EAAK,CACpEA,CAAAA,CAAQ,cAAc,IAAA,EAAK,CAC3BJ,CAAAA,CAAgB,aAAA,CACtB,kBAAA,CAAoBI,CAAAA,CAAQ,kBAAA,EAAsBJ,CAAAA,CAAgB,mBAClE,cAAA,CAAgBI,CAAAA,CAAQ,cAAA,EAAkBJ,CAAAA,CAAgB,eAC1D,cAAA,CAAAK,CACF,CACF,CAQO,SAASC,CAAAA,CACdC,CAAAA,CACAH,CAAAA,CACQ,CACR,IAAMI,CAAAA,CAAWL,CAAAA,CAAiBC,CAAO,EACnCK,CAAAA,CAAY,IAAA,CAAK,SAAA,CAAUF,CAAAA,CAAM,KAAMN,CAAiB,CAAA,CAE9D,OAAO,CACL,iEACA,6EAAA,CACA,EAAA,CACA,iEAAA,CACA,8BAAA,CACA,8GAAA,CACA,kEAAA,CACA,yCAAA,CACA,EAAA,CACA,eACA,mCAAA,CACA,4CAAA,CACA,kFAAA,CACA,wEAAA,CACA,0EACA,0FAAA,CACA,2CAAA,CACA,wCAAA,CACA,6DAAA,CACA,iFACA,kFAAA,CACA,EAAA,CACA,cAAA,CACA,CAAA,kBAAA,EAAqBO,CAAAA,CAAS,cAAc,CAAA,YAAA,CAAA,CAC5C,CAAA,EAAA,EAAKA,EAAS,kBAAA,CAAqB,wDAAA,CAA2D,2CAA2C,CAAA,CAAA,CACzI,KAAKA,CAAAA,CAAS,cAAA,CAAiB,sDAAA,CAAyD,gEAAgE,GACxJ,4CAAA,CACA,2CAAA,CACA,4EAAA,CACA,EAAA,CACA,2BAAA,CACA,qBAAA,CACA,0DAAA,CACA,wCAAA,CACA,qDAAqD,IAAA,CAAK,SAAA,CAAUA,CAAAA,CAAS,aAAa,CAAC,CAAA,CAAA,CAC3F,EAAA,CACA,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\nconst DEFAULT_OPTIONS: Required<CreateScreenshotTitlePromptOptions> = {\n fallbackTitle: 'Should render correctly.',\n includeBrowserType: true,\n includeStoryId: false,\n maxTitleLength: 80,\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 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 };\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 '- Return JSON only.',\n '- Return exactly one object with exactly one key: title.',\n '- Shape: {\"title\":\"<generated title>\"}',\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 '../../
|
|
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-
|
|
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 '../../
|
|
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-
|
|
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-
|
|
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-
|
|
2
|
+
import { R as RequestData } from './request-DVZ6cFCg.js';
|
|
3
|
+
import './story-DSpVrFjG.js';
|
|
3
4
|
import 'playwright';
|
|
4
5
|
import 'zod';
|
|
5
6
|
|
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 './
|
|
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 './
|
|
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 };
|