/** * playwright-generation.skill.ts * * Generates the complete Page Object Model (POM) TypeScript file and the * compact element table used in the spec-generation prompt. * * This is the most important skill in the system. It always runs first in * the autoExecute() pipeline and produces: * 1. An ElementContext[] — one entry per interactive element, with all * metadata needed for healing and code generation. * 2. A CompactElement[] — a minimal table of (key, action, locator, method) * for inclusion in the compact prompt sent to Claude. * 3. A complete POM TypeScript file — including the ELEMENT_CONTEXTS constant, * property declarations, a constructor, a goto() method, and one typed * action method per element. * * Claude never rewrites this POM — it saves the generated code verbatim. * * Confidence is 0.92 — the POM is deterministic given the page elements. * * Role in the overall flow: * SkillOrchestrator.autoExecute() → PlaywrightGenerationSkill.execute() [runs first] * → pomCode (saved by save_test) + elementContexts (used by assertion-generation) */ import { SkillContext, SkillResult } from '../types'; import { BaseSkill } from './base.skill'; /** * Generates the complete Page Object Model and element context metadata for * a page. This is the primary code-generation skill in Playwright Pilot AI. */ export declare class PlaywrightGenerationSkill extends BaseSkill { readonly name = "playwright-generation"; private locator; /** * Build ElementContexts, a compact element table, and the complete POM code * for the current page. * * @param ctx - The skill context, must include pageAnalysis, slug, and className. * slug and className default to 'generated'/'GeneratedPage' if not set. * @returns A SkillResult where generatedCode is the full POM TypeScript source, * elementContexts holds all element metadata, and metadata.compactElements * holds the compact table for prompt injection. */ execute(ctx: SkillContext): Promise; /** * Generate the complete Page Object Model source code (TypeScript or JavaScript). * * When language is 'javascript', produces a CommonJS module with require() and * module.exports — no type annotations, no TypeScript syntax. * When language is 'typescript' (default), produces a typed TypeScript module. * * The generated file includes: * - An ELEMENT_CONTEXTS constant (used by StepTracker for healing) * - One property per element * - A constructor that initializes all locators * - A goto() method * - One action method per element (fill/click/navigate/select/check/assert) * * @param className - PascalCase class name, e.g. "LoginPage". * @param url - The page URL, embedded in the class as a property. * @param slug - Kebab-case slug, used in comments. * @param contexts - All element contexts to include in the POM. * @param language - Output language: 'javascript' (CommonJS) or 'typescript'. * @returns The full source code as a string. */ private buildPom; /** * Build the TypeScript version of the POM. * @private */ private buildPomTs; /** * Build the JavaScript CommonJS (Node.js) version of the POM. * No TypeScript type annotations — compatible with plain Node.js. * @private */ private buildPomJs; /** * Generate action methods for each element context. * In TypeScript mode methods have typed parameters and return types. * In JavaScript mode methods have JSDoc annotations instead. * * @param contexts - Element contexts to generate methods for. * @param language - 'typescript' (default) or 'javascript' (CommonJS, JSDoc). * @returns A multi-line string of method definitions. */ private buildActions; /** * Map an actionType to its verb prefix for the generated method name. * For example, actionType "fill" → verb "fill", "assert" → verb "verify". * * @param action - The element's inferred action type. * @returns A verb string used as the method name prefix. */ private verbFor; /** * Pick the best available human-readable description for an element, * falling back to "tag-index" if no text attributes are available. * * @param el - The DOM element. * @param i - The element index (used in fallback name). * @returns A human-readable description string, max 60 characters. */ private pickDescription; /** * Infer the most appropriate action type for an element based on its tag and role. * * @param el - The DOM element to classify. * @returns The inferred action type. */ private inferActionType; /** * Build a camelCase method name from a description and a verb prefix. * Example: description="email address", prefix="fill" → "fillEmailAddress". * * @param description - Human-readable element description. * @param prefix - Verb to prepend (e.g. "fill", "click", "verify"). * @returns A camelCase method name string. */ methodName(description: string, prefix: string): string; /** * Convert a description string into a camelCase property key suitable for * use as a TypeScript class property name and ELEMENT_CONTEXTS key. * * @param description - Human-readable description to convert. * @returns A camelCase key string. */ private toKey; } //# sourceMappingURL=playwright-generation.skill.d.ts.map