uwright 0.1.1 → 0.1.4

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
@@ -1,12 +1,14 @@
1
1
  # Uwright
2
2
 
3
- Write browser tests in Markdown and watch them run. Uwright uses a model to interpret your steps, drives the browser, and saves an execution lock that you can review and commit with your tests.
3
+ Uwright makes browser testing easier to write and cheaper to run. Describe a user journey in Markdown. AI helps you create and update the test, while routine runs replay it without relying on AI to drive every step.
4
4
 
5
- Uwright is an early preview. Model-assisted checks run against the current page on each run, and an unchanged lock cannot guarantee a passing test.
5
+ ## See it in action
6
+
7
+ ![Edit a Markdown flow in Uwright, then watch it run live against Softprobe Blackbox Explorer](assets/uwright-markdown-live.gif)
6
8
 
7
9
  ## Get started
8
10
 
9
- You need Node.js 22.22.3 or later on the 22.x line, an OpenAI API key for a supported model, and a web app to test. Uwright defaults to `gpt-6-luna`, but you can configure other OpenAI models your key can access. `npx` fetches Uwright when needed, and the first test run downloads Chromium automatically.
11
+ You need Node.js 22.22.3 or later, an OpenAI API key for a supported model, and a web app to test. Uwright defaults to `gpt-6-luna`, but you can configure other OpenAI models your key can access. `npx` fetches Uwright when needed, and the first test run downloads Chromium automatically.
10
12
 
11
13
  1. In your app's repository, create a starter configuration and flow:
12
14
 
@@ -14,50 +16,52 @@ You need Node.js 22.22.3 or later on the 22.x line, an OpenAI API key for a supp
14
16
  npx uwright init
15
17
  ```
16
18
 
17
- Set `target.baseUrl` in `uwright.config.yaml` to your running app's URL. Open `flows/example.flow.md` and describe the journey and expected outcome. For example:
19
+ `uwright/config.yaml` points to the DemoAir flight search app. For your own app, change `target.baseUrl` and update `uwright/flows/flight-search.flow.md`. The starter flow demonstrates a London to Paris search:
18
20
 
19
21
  ```markdown
20
22
  ---
21
- name: Open products
23
+ name: Search London to Paris flights
22
24
  ---
23
25
 
24
26
  ## Steps
25
- 1. Open the home page.
26
- 2. Click the Products link.
27
+ 1. Open the flight search home page at `/`.
28
+ 2. Select `London Heathrow (LHR)` as the departure airport and `Paris Charles de Gaulle (CDG)` as the arrival airport. Keep the default departure date.
29
+ 3. Click the Search button.
27
30
 
28
31
  ## Expected Outcome
29
- - The Products heading is visible.
32
+ - The flight search results page shows at least one button named `Select →`.
30
33
  ```
31
34
 
32
- 2. Set `OPENAI_API_KEY` in your shell. Keep the key out of Git. Validate the flow and open the live viewer:
35
+ 2. Set your API key in the shell. Keep the key out of Git. Validate the flow and open the live viewer:
33
36
 
34
37
  ```sh
38
+ export OPENAI_API_KEY="your-openai-api-key"
35
39
  npx uwright validate
36
- npx uwright watch flows/example.flow.md
40
+ npx uwright watch uwright/flows/flight-search.flow.md
37
41
  ```
38
42
 
39
- 3. Review the steps in the browser and select **Start test**. The viewer shows the application, actions, checks, and logs. When the flow passes, Uwright saves its lock under `.uwright/lock/e2e/`. Review the lock and commit it with the Markdown.
43
+ 3. Review the steps in the browser and select **Start test**. The viewer shows the application, actions, checks, and logs. When the flow passes, Uwright saves its lock under `uwright/locks/e2e/`. Review the lock and commit it with the Markdown.
40
44
 
41
45
  If the viewer does not open, use the URL printed in the terminal. Press Ctrl-C in the terminal to stop the watch server. The URL grants control of the local run; keep it private.
42
46
 
43
47
  ## Run and replay tests
44
48
 
45
- Run these commands from the directory containing `uwright.config.yaml`:
49
+ Run these commands from the directory containing `uwright/`:
46
50
 
47
51
  `npx` downloads Uwright on demand if it is not installed in the repository.
48
52
 
49
53
  ```sh
50
54
  npx uwright run # Run all flows in heal mode
51
- npx uwright run flows/example.flow.md # Run one flow
55
+ npx uwright run uwright/flows/flight-search.flow.md # Run one flow
52
56
  npx uwright run --mode strict # Replay locked actions
53
57
  npx uwright run --headed # Open a visible browser for the app under test
54
- npx uwright watch flows/example.flow.md --mode strict
55
- npx uwright watch flows/example.flow.md --headed
58
+ npx uwright watch uwright/flows/flight-search.flow.md --mode strict
59
+ npx uwright watch uwright/flows/flight-search.flow.md --headed
56
60
  npx uwright lock status
57
61
  npx uwright lock diff
58
62
  ```
59
63
 
60
- Heal mode reuses recorded actions and can ask the model to find a replacement when the UI changes. It publishes updated locks after a successful run. Strict mode checks the lock before opening the application and blocks model-selected navigation. Both modes evaluate model-assisted checks against the current page. A check can make model calls in strict mode.
64
+ Heal mode reuses recorded actions and can ask the model to find a replacement when an action is missing or stale. It publishes updated locks after a successful run. Strict mode checks the lock before opening the application and replays locked actions without model-selected navigation. Both modes evaluate checks against the current page, and those model-assisted checks can make model calls. A passing replay therefore does not depend on a past model verdict, though model-assisted checks can still vary.
61
65
 
62
66
  The terminal shows each flow as it starts, step progress, the result, and the saved HTML report path. A run stops on the first failure and reports how many flows were not run.
63
67
 
@@ -65,27 +69,23 @@ Watch lets you pause after a step, control the page, edit the Markdown, and ask
65
69
 
66
70
  ## Organize your tests
67
71
 
68
- Commit `uwright.config.yaml`, flows and skills in `flows/`, relevant `CONTEXT.md` files, non-sensitive test fixtures, and the corresponding `.uwright/lock/e2e/` files. Review lock changes like code. `uwright init` adds ignore rules for local artifacts and `.env` files without removing existing entries.
72
+ Commit `uwright/`, including its config, flows, skills, context, non-sensitive fixtures, and locks. Review generated lock changes for sensitive data before committing. `uwright/.gitignore` excludes local artifacts and lock publication state. Existing workspaces using `uwright.config.yaml` continue to work with their configured paths.
69
73
 
70
- Uwright records full Playwright traces and screenshots in `.uwright/artifacts/`. These can contain credentials, page content, and network data. Keep them out of Git and restrict access to CI artifacts. Each run prints the report and trace paths. Open a trace with `npx playwright show-trace <path-to-trace.zip>`.
74
+ Uwright records full Playwright traces and screenshots in `uwright/local/artifacts/`. These can contain credentials, page content, and network data. Keep them out of Git and restrict access to CI artifacts. Each run prints the report and trace paths. Open a trace with `npx playwright show-trace <path-to-trace.zip>`.
71
75
 
72
76
  For sign-in flows, declare secret environment variable names in the flow or skill and supply their values through the environment. Do not put secret values in Markdown or lock files. Review generated locks before committing them.
73
77
 
74
78
  ## Configuration
75
79
 
76
- The `execution` section is optional. Uwright defaults to the `e2e` runtime and `heal` mode, including in CI. Set `execution.runtime` or `execution.mode` to override them, or use `--mode` for a single run. Uwright defaults to OpenAI and `gpt-6-luna` for compilation, navigation, and checks. Set `ai.compilerModel`, `ai.explorerModel`, and `ai.judgeModel` to use other OpenAI models:
80
+ The `execution` section is optional. Uwright defaults to the `e2e` runtime and `heal` mode, including in CI. Set `execution.runtime` or `execution.mode` to override them, or use `--mode` for a single run. Uwright uses `gpt-6-luna` by default for compilation, navigation, and checks. Set `ai.defaultModel` to change all three. Set `ai.compilerModel`, `ai.explorerModel`, or `ai.judgeModel` to override a model for one role:
77
81
 
78
82
  ```yaml
79
83
  target:
80
84
  baseUrl: http://localhost:3000
81
85
  ai:
82
- compilerModel: your-openai-model
83
- explorerModel: your-openai-model
84
- judgeModel: your-openai-model
86
+ defaultModel: gpt-6-luna
85
87
  ```
86
88
 
87
- Replace `your-openai-model` with a model ID available to your API key.
88
-
89
89
  The model-call limit applies per e2e operation, rather than across an entire flow. See the [execution lock specification](design/lockfile-spec.md) for the lock format, recovery, and current limits. If an interrupted publication blocks a run, use `npx uwright lock recover`. The command refuses to overwrite conflicting external edits.
90
90
 
91
91
  ## Current limits
@@ -97,7 +97,7 @@ The model-call limit applies per e2e operation, rather than across an entire flo
97
97
  - Locks do not yet support all dynamic values and asset-path inputs. Lock diffs show full changed records rather than a concise semantic summary.
98
98
  - Tests can fail when the target UI, data, network, authentication, or model provider changes. Full trace creation can also fail.
99
99
 
100
- The legacy runtime and DemoAir example remain available in the source repository. See the [PRD](prd.md) and [implementation plan](implementation-plan.md) for planned work.
100
+ The legacy runtime remains available in the source repository. See the [PRD](prd.md) and [implementation plan](implementation-plan.md) for planned work.
101
101
 
102
102
  ## Develop and release
103
103
 
package/dist/cli.js CHANGED
@@ -46,47 +46,53 @@ Traces are recorded by default and can contain secrets.
46
46
  Use --headed to open a visible browser for the application under test.
47
47
  `;
48
48
  async function init() {
49
- await mkdir('flows', { recursive: true });
49
+ try {
50
+ await readFile('uwright.config.yaml');
51
+ throw new FlowError('CONFIG_ERROR', 'An existing uwright.config.yaml workspace was found; it has not been changed.');
52
+ }
53
+ catch (error) {
54
+ if (error.code !== 'ENOENT')
55
+ throw error;
56
+ }
57
+ await mkdir('uwright/flows', { recursive: true });
58
+ const files = {
59
+ 'uwright/config.yaml': `version: "2"\ntarget:\n platform: web\n baseUrl: https://demoair.softprobe.ai/\n browser: chromium\n headless: true\n`,
60
+ 'uwright/flows/flight-search.flow.md': `---\nname: Search London to Paris flights\n---\n\n## Steps\n1. Open the flight search home page at \`/\`.\n2. Select \`London Heathrow (LHR)\` as the departure airport and \`Paris Charles de Gaulle (CDG)\` as the arrival airport. Keep the default departure date.\n3. Click the Search button.\n\n## Expected Outcome\n- The flight search results page shows at least one button named \`Select →\`.\n`,
61
+ };
62
+ const ignorePath = 'uwright/.gitignore';
50
63
  const ignore = [
51
- '.uwright/artifacts/',
52
- '.uwright/lock/.write-lock/',
53
- '.uwright/lock/e2e/**/.write-lock/',
54
- '.uwright/lock/e2e/**/.transaction/',
55
- '.uwright/lock/.transaction/',
56
- '.uwright/lock/**/*.tmp-*',
57
- '.uwright/lock/generations/',
58
- '.uwright/legacy-locks/',
59
- '.env',
60
- '.env.*',
61
- '!.env.example',
64
+ '/local/',
65
+ '/locks/**/.write-lock/',
66
+ '/locks/**/.transaction/',
67
+ '/locks/**/*.tmp-*',
68
+ '/locks/generations/',
62
69
  ];
63
70
  let existing = '';
64
71
  try {
65
- existing = await readFile('.gitignore', 'utf8');
72
+ existing = await readFile(ignorePath, 'utf8');
66
73
  }
67
- catch (e) {
68
- if (e.code !== 'ENOENT')
69
- throw e;
74
+ catch (error) {
75
+ if (error.code !== 'ENOENT')
76
+ throw error;
70
77
  }
71
78
  const lines = new Set(existing.split(/\r?\n/));
72
79
  const missing = ignore.filter((line) => !lines.has(line));
73
- if (missing.length)
74
- await writeFile('.gitignore', existing + (existing && !existing.endsWith('\n') ? '\n' : '') + missing.join('\n') + '\n');
75
- const files = {
76
- 'uwright.config.yaml': `version: "2"\nflowsDir: ./flows\nlockDir: ./.uwright/lock\nartifactsDir: ./.uwright/artifacts\ntarget:\n platform: web\n baseUrl: http://localhost:3000\n browser: chromium\n headless: true\n`,
77
- 'flows/example.flow.md': `---\nname: Example\n---\n\n## Steps\n1. Open the home page.\n\n## Expected Outcome\n- The page is visible.\n`,
78
- };
79
- for (const [f, content] of Object.entries(files)) {
80
+ if (missing.length) {
81
+ await writeFile(ignorePath, existing + (existing && !existing.endsWith('\n') ? '\n' : '') + missing.join('\n') + '\n');
82
+ process.stdout.write(`Updated ${ignorePath}\n`);
83
+ }
84
+ for (const [file, content] of Object.entries(files)) {
80
85
  try {
81
- await writeFile(f, content, { flag: 'wx' });
82
- process.stdout.write(`Created ${f}\n`);
86
+ await writeFile(file, content, { flag: 'wx' });
87
+ process.stdout.write(`Created ${file}\n`);
83
88
  }
84
- catch (e) {
85
- if (e.code !== 'EEXIST')
86
- throw e;
87
- process.stdout.write(`Kept ${f}\n`);
89
+ catch (error) {
90
+ if (error.code !== 'EEXIST')
91
+ throw error;
92
+ process.stdout.write(`Kept ${file}\n`);
88
93
  }
89
94
  }
95
+ process.stdout.write('Commit uwright/ and review generated recordings for sensitive data. Local files are ignored.\n');
90
96
  }
91
97
  async function main() {
92
98
  const [cmd, ...args] = process.argv.slice(2);
package/dist/model.js CHANGED
@@ -1,5 +1,27 @@
1
1
  import { z } from 'zod';
2
2
  export const secretKey = z.string().regex(/^[A-Z][A-Z0-9_]*$/);
3
+ const aiConfigSchema = z
4
+ .object({
5
+ provider: z.literal('openai').default('openai'),
6
+ defaultModel: z.string().default('gpt-6-luna'),
7
+ compilerModel: z.string().optional(),
8
+ explorerModel: z.string().optional(),
9
+ judgeModel: z.string().optional(),
10
+ maxStepsPerExplore: z.number().int().positive().default(8),
11
+ maxModelCallsPerFlow: z.number().int().positive().default(30),
12
+ })
13
+ .default({
14
+ provider: 'openai',
15
+ defaultModel: 'gpt-6-luna',
16
+ maxStepsPerExplore: 8,
17
+ maxModelCallsPerFlow: 30,
18
+ })
19
+ .transform((ai) => ({
20
+ ...ai,
21
+ compilerModel: ai.compilerModel ?? ai.defaultModel,
22
+ explorerModel: ai.explorerModel ?? ai.defaultModel,
23
+ judgeModel: ai.judgeModel ?? ai.defaultModel,
24
+ }));
3
25
  export const configSchema = z.object({
4
26
  version: z.coerce.string().default('2'),
5
27
  flowsDir: z.string().default('./flows'),
@@ -12,23 +34,7 @@ export const configSchema = z.object({
12
34
  headless: z.boolean().default(true),
13
35
  viewport: z.object({ width: z.number(), height: z.number() }).default({ width: 1280, height: 800 }),
14
36
  }),
15
- ai: z
16
- .object({
17
- provider: z.literal('openai').default('openai'),
18
- compilerModel: z.string().default('gpt-6-luna'),
19
- explorerModel: z.string().default('gpt-6-luna'),
20
- judgeModel: z.string().default('gpt-6-luna'),
21
- maxStepsPerExplore: z.number().int().positive().default(8),
22
- maxModelCallsPerFlow: z.number().int().positive().default(30),
23
- })
24
- .default({
25
- provider: 'openai',
26
- compilerModel: 'gpt-6-luna',
27
- explorerModel: 'gpt-6-luna',
28
- judgeModel: 'gpt-6-luna',
29
- maxStepsPerExplore: 8,
30
- maxModelCallsPerFlow: 30,
31
- }),
37
+ ai: aiConfigSchema,
32
38
  execution: z
33
39
  .object({
34
40
  runtime: z.enum(['legacy', 'e2e']).default('e2e'),
@@ -262,7 +262,7 @@
262
262
  </div>
263
263
  </main>
264
264
  <script>
265
- const title = "__TEMPLATE_VALUE__";
265
+ const title = __UWRIGHT_TITLE_JSON__;
266
266
  document.querySelector("#title").textContent = title;
267
267
  const $ = (s) => document.querySelector(s);
268
268
  let paused = false,
package/dist/workspace.js CHANGED
@@ -63,16 +63,42 @@ export async function parseDocument(file) {
63
63
  return { path: file, source, frontmatter: fm.data, sections };
64
64
  }
65
65
  export async function loadWorkspace(root = process.cwd()) {
66
+ const legacyPath = path.join(root, 'uwright.config.yaml');
67
+ const newPath = path.join(root, 'uwright', 'config.yaml');
68
+ async function readConfig(file) {
69
+ try {
70
+ return await readFile(file, 'utf8');
71
+ }
72
+ catch (error) {
73
+ if (error.code === 'ENOENT')
74
+ return undefined;
75
+ throw error;
76
+ }
77
+ }
78
+ const [legacy, current] = await Promise.all([readConfig(legacyPath), readConfig(newPath)]);
79
+ if (legacy !== undefined && current !== undefined)
80
+ throw new FlowError('CONFIG_ERROR', 'Both uwright.config.yaml and uwright/config.yaml exist; remove the ambiguity.');
81
+ if (legacy === undefined && current === undefined)
82
+ throw new FlowError('CONFIG_ERROR', 'Cannot find uwright/config.yaml or uwright.config.yaml; run uwright init.');
66
83
  let raw;
67
84
  try {
68
- raw = parseYaml(await readFile(path.join(root, 'uwright.config.yaml'), 'utf8'));
85
+ raw = parseYaml(current ?? legacy ?? '');
69
86
  }
70
- catch (e) {
71
- throw new FlowError('CONFIG_ERROR', `Cannot read uwright.config.yaml: ${String(e)}`);
87
+ catch (error) {
88
+ throw new FlowError('CONFIG_ERROR', `Cannot parse configuration: ${String(error)}`);
72
89
  }
73
90
  const parsed = configSchema.safeParse(raw);
74
91
  if (!parsed.success)
75
92
  throw new FlowError('CONFIG_ERROR', parsed.error.message);
93
+ if (current !== undefined) {
94
+ const configured = raw && typeof raw === 'object' ? raw : {};
95
+ if (!('flowsDir' in configured))
96
+ parsed.data.flowsDir = './uwright/flows';
97
+ if (!('lockDir' in configured))
98
+ parsed.data.lockDir = './uwright/locks';
99
+ if (!('artifactsDir' in configured))
100
+ parsed.data.artifactsDir = './uwright/local/artifacts';
101
+ }
76
102
  const all = await files(path.resolve(root, parsed.data.flowsDir));
77
103
  const docs = await Promise.all(all
78
104
  .filter((f) => f.endsWith('.flow.md') || f.endsWith('.skill.md') || path.basename(f) === 'CONTEXT.md')
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "uwright",
3
- "version": "0.1.1",
3
+ "version": "0.1.4",
4
4
  "description": "Markdown-first UI end-to-end testing",
5
5
  "type": "module",
6
6
  "bin": {