@docsxai/engine 0.3.0-rc.3 → 0.3.0-rc.5
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 +44 -34
- package/dist/atomic-write.d.ts +19 -0
- package/dist/atomic-write.js +127 -0
- package/dist/auth/api-login.d.ts +9 -51
- package/dist/auth/api-login.js +3 -3
- package/dist/auth/browser-session.js +1 -1
- package/dist/auth/cookie-jar.d.ts +4 -4
- package/dist/auth/cookie-jar.js +4 -4
- package/dist/auth/email-otp.d.ts +11 -147
- package/dist/auth/email-otp.js +4 -4
- package/dist/auth/http-basic.js +1 -1
- package/dist/auth/index.js +3 -3
- package/dist/auth/jwt-injection.d.ts +7 -131
- package/dist/auth/jwt-injection.js +5 -5
- package/dist/auth/manual-capture.d.ts +3 -3
- package/dist/auth/manual-capture.js +2 -2
- package/dist/auth/mtls.d.ts +1 -6
- package/dist/auth/mtls.js +1 -1
- package/dist/auth/pat-header.d.ts +1 -9
- package/dist/auth/pat-header.js +1 -1
- package/dist/auth/storage-state-cache.d.ts +16 -6
- package/dist/auth/storage-state-cache.js +65 -15
- package/dist/auth/test-backdoor.d.ts +2 -13
- package/dist/auth/test-backdoor.js +3 -3
- package/dist/auth/totp.d.ts +1 -1
- package/dist/auth/totp.js +4 -4
- package/dist/auth/types.d.ts +3 -3
- package/dist/auth/types.js +4 -4
- package/dist/auth/ui-form.d.ts +24 -153
- package/dist/auth/ui-form.js +3 -3
- package/dist/auth/webauthn.d.ts +7 -67
- package/dist/auth/webauthn.js +3 -3
- package/dist/auth.js +1 -1
- package/dist/backend-client-contracts.d.ts +1 -1
- package/dist/backend-client-contracts.js +2 -2
- package/dist/backend-client-oauth-login.js +1 -1
- package/dist/backend-client-state-cache.d.ts +2 -2
- package/dist/backend-client-state-cache.js +8 -8
- package/dist/backend-client-token.js +4 -4
- package/dist/backend-client-transport.d.ts +2 -2
- package/dist/backend-client-transport.js +3 -3
- package/dist/backend-client.js +6 -6
- package/dist/browser-build.d.ts +6 -0
- package/dist/browser-build.js +12 -0
- package/dist/browser-launch-error.d.ts +18 -0
- package/dist/browser-launch-error.js +63 -0
- package/dist/browser-wait.d.ts +7 -0
- package/dist/browser-wait.js +12 -0
- package/dist/calibrate.d.ts +6 -2
- package/dist/calibrate.js +20 -13
- package/dist/cli-backend-errors.d.ts +5 -0
- package/dist/cli-backend-errors.js +24 -3
- package/dist/cli-commands-auth.d.ts +1 -0
- package/dist/cli-commands-auth.js +114 -0
- package/dist/cli-commands-authoring.d.ts +0 -1
- package/dist/cli-commands-authoring.js +124 -101
- package/dist/cli-commands-backend.d.ts +1 -1
- package/dist/cli-commands-backend.js +76 -21
- package/dist/cli-commands-docpack.d.ts +3 -1
- package/dist/cli-commands-docpack.js +145 -39
- package/dist/cli-commands-init.d.ts +1 -0
- package/dist/cli-commands-init.js +100 -0
- package/dist/cli-commands-pack.d.ts +1 -1
- package/dist/cli-commands-pack.js +6 -4
- package/dist/cli-commands-session.d.ts +1 -3
- package/dist/cli-commands-session.js +109 -180
- package/dist/cli-commands-site.d.ts +2 -0
- package/dist/cli-commands-site.js +77 -0
- package/dist/cli-commands-style.d.ts +1 -0
- package/dist/cli-commands-style.js +85 -0
- package/dist/cli-flags.d.ts +18 -0
- package/dist/cli-flags.js +77 -0
- package/dist/cli-help.d.ts +30 -0
- package/dist/cli-help.js +174 -0
- package/dist/cli-messages.d.ts +30 -0
- package/dist/cli-messages.js +97 -0
- package/dist/cli-node-guard.d.ts +1 -0
- package/dist/cli-node-guard.js +8 -0
- package/dist/cli-retired.js +6 -0
- package/dist/cli-run-stale.d.ts +2 -0
- package/dist/cli-run-stale.js +13 -0
- package/dist/cli-run-summary.js +7 -3
- package/dist/cli-shared.d.ts +30 -1
- package/dist/cli-shared.js +112 -12
- package/dist/cli-unexpected.d.ts +12 -2
- package/dist/cli-unexpected.js +50 -4
- package/dist/cli-usage.d.ts +1 -1
- package/dist/cli-usage.js +115 -66
- package/dist/cli-value-flags.d.ts +8 -0
- package/dist/cli-value-flags.js +34 -0
- package/dist/cli-version.d.ts +6 -0
- package/dist/cli-version.js +25 -0
- package/dist/cli.d.ts +1 -0
- package/dist/cli.js +42 -19
- package/dist/deprecation.d.ts +2 -0
- package/dist/deprecation.js +2 -0
- package/dist/device-scale-factor.d.ts +14 -0
- package/dist/device-scale-factor.js +38 -0
- package/dist/diagnose.js +14 -13
- package/dist/diff-compute.js +22 -8
- package/dist/diff-report.js +3 -3
- package/dist/diff-types.js +1 -1
- package/dist/diff.js +3 -3
- package/dist/doc-pack-io.js +62 -47
- package/dist/doc-pack.d.ts +567 -3487
- package/dist/doc-pack.js +47 -33
- package/dist/doctor-checks-config.d.ts +12 -0
- package/dist/doctor-checks-config.js +229 -0
- package/dist/doctor-checks-plugins.js +2 -2
- package/dist/doctor-checks-site.d.ts +3 -0
- package/dist/doctor-checks-site.js +21 -0
- package/dist/doctor-checks.d.ts +13 -2
- package/dist/doctor-checks.js +94 -79
- package/dist/doctor-next.d.ts +5 -0
- package/dist/doctor-next.js +52 -0
- package/dist/doctor.d.ts +36 -2
- package/dist/doctor.js +88 -29
- package/dist/environment-spec.d.ts +36 -44
- package/dist/environment-spec.js +31 -3
- package/dist/export/adf.d.ts +1 -1
- package/dist/export/adf.js +16 -27
- package/dist/export/playwright-test.d.ts +1 -1
- package/dist/export/playwright-test.js +13 -15
- package/dist/flow-file.d.ts +1 -1
- package/dist/flow-file.js +22 -4
- package/dist/flow-halt.d.ts +1 -1
- package/dist/flow-halt.js +15 -3
- package/dist/flow-lint.d.ts +3 -1
- package/dist/flow-lint.js +39 -26
- package/dist/flow-matrix-lint.js +2 -2
- package/dist/flow-runtime.d.ts +17 -6
- package/dist/flow-runtime.js +48 -17
- package/dist/flow-success.js +4 -4
- package/dist/flow-tree.js +2 -2
- package/dist/index.d.ts +2 -0
- package/dist/index.js +2 -0
- package/dist/main-module.d.ts +1 -0
- package/dist/main-module.js +17 -0
- package/dist/matrix-spec.d.ts +33 -106
- package/dist/matrix-spec.js +12 -3
- package/dist/node-floor.d.ts +4 -0
- package/dist/node-floor.js +14 -0
- package/dist/obstacles.js +1 -1
- package/dist/open-in-browser.d.ts +22 -0
- package/dist/open-in-browser.js +37 -0
- package/dist/playwright-driver.d.ts +8 -12
- package/dist/playwright-driver.js +75 -70
- package/dist/playwright-instrumented-browser.d.ts +10 -7
- package/dist/playwright-instrumented-browser.js +35 -12
- package/dist/plugins/load.d.ts +1 -1
- package/dist/plugins/load.js +4 -4
- package/dist/plugins/lock.js +11 -8
- package/dist/plugins/manifest.d.ts +16 -35
- package/dist/plugins/manifest.js +5 -5
- package/dist/plugins/plan.d.ts +3 -3
- package/dist/plugins/plan.js +14 -14
- package/dist/plugins/registry.d.ts +1 -1
- package/dist/plugins/registry.js +1 -1
- package/dist/plugins/runtime.js +3 -3
- package/dist/plugins/types.d.ts +1 -1
- package/dist/plugins-cli.js +36 -28
- package/dist/posix-path.d.ts +2 -0
- package/dist/posix-path.js +7 -0
- package/dist/redact.js +2 -2
- package/dist/run-flows.d.ts +7 -0
- package/dist/run-flows.js +75 -27
- package/dist/style.d.ts +2 -2
- package/dist/style.js +13 -11
- package/dist/verify-determinism.js +2 -1
- package/dist/verify-next-step.d.ts +2 -0
- package/dist/verify-next-step.js +24 -0
- package/dist/verify-report.js +3 -2
- package/dist/viewer-bin.d.ts +9 -3
- package/dist/viewer-bin.js +35 -12
- package/dist/workspace-templates.d.ts +15 -0
- package/dist/workspace-templates.js +88 -0
- package/dist/workspace.d.ts +78 -5
- package/dist/workspace.js +47 -28
- package/dist/zip.d.ts +1 -1
- package/dist/zip.js +23 -6
- package/package.json +6 -6
|
@@ -2,21 +2,22 @@ import { z } from "zod";
|
|
|
2
2
|
export declare const ViewportSize: z.ZodObject<{
|
|
3
3
|
width: z.ZodNumber;
|
|
4
4
|
height: z.ZodNumber;
|
|
5
|
-
},
|
|
6
|
-
width: number;
|
|
7
|
-
height: number;
|
|
8
|
-
}, {
|
|
9
|
-
width: number;
|
|
10
|
-
height: number;
|
|
11
|
-
}>;
|
|
5
|
+
}, z.core.$strict>;
|
|
12
6
|
export type ViewportSize = z.infer<typeof ViewportSize>;
|
|
13
|
-
export declare const ViewportPreset: z.ZodEnum<
|
|
7
|
+
export declare const ViewportPreset: z.ZodEnum<{
|
|
8
|
+
desktop: "desktop";
|
|
9
|
+
tablet: "tablet";
|
|
10
|
+
mobile: "mobile";
|
|
11
|
+
}>;
|
|
14
12
|
export type ViewportPreset = z.infer<typeof ViewportPreset>;
|
|
15
|
-
/** Named viewport presets
|
|
13
|
+
/** Named viewport presets, `desktop` 1440×900, `tablet` 834×1112, `mobile` 390×844. */
|
|
16
14
|
export declare const VIEWPORT_PRESETS: Record<ViewportPreset, ViewportSize>;
|
|
17
15
|
/** BCP-47 language tag (e.g. `en-GB`); shared by `environment.locale`, matrix locales and `copy_by_locale` keys. */
|
|
18
16
|
export declare const LocaleTag: z.ZodString;
|
|
19
|
-
export declare const ColorScheme: z.ZodEnum<
|
|
17
|
+
export declare const ColorScheme: z.ZodEnum<{
|
|
18
|
+
light: "light";
|
|
19
|
+
dark: "dark";
|
|
20
|
+
}>;
|
|
20
21
|
export type ColorScheme = z.infer<typeof ColorScheme>;
|
|
21
22
|
/**
|
|
22
23
|
* Deterministic execution environment for a flow. All fields optional; applied at browser-context
|
|
@@ -24,44 +25,35 @@ export type ColorScheme = z.infer<typeof ColorScheme>;
|
|
|
24
25
|
* wins per-key over the parent's (a child can pin just `viewport` and inherit the parent's clock).
|
|
25
26
|
*/
|
|
26
27
|
export declare const EnvironmentSpec: z.ZodObject<{
|
|
27
|
-
/** ISO-8601 instant the page clock is frozen at — `new Date()` etc. return this for the whole run. */
|
|
28
28
|
clock: z.ZodOptional<z.ZodString>;
|
|
29
|
-
/** BCP-47 language tag (e.g. `en-GB`). */
|
|
30
29
|
locale: z.ZodOptional<z.ZodString>;
|
|
31
|
-
/** IANA timezone (e.g. `Europe/Amsterdam`). */
|
|
32
30
|
timezone: z.ZodOptional<z.ZodString>;
|
|
33
|
-
|
|
34
|
-
|
|
31
|
+
viewport: z.ZodOptional<z.ZodUnion<readonly [z.ZodEnum<{
|
|
32
|
+
desktop: "desktop";
|
|
33
|
+
tablet: "tablet";
|
|
34
|
+
mobile: "mobile";
|
|
35
|
+
}>, z.ZodObject<{
|
|
35
36
|
width: z.ZodNumber;
|
|
36
37
|
height: z.ZodNumber;
|
|
37
|
-
},
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
height: number;
|
|
43
|
-
}>]>>;
|
|
44
|
-
color_scheme: z.ZodOptional<z.ZodEnum<["light", "dark"]>>;
|
|
38
|
+
}, z.core.$strict>]>>;
|
|
39
|
+
color_scheme: z.ZodOptional<z.ZodEnum<{
|
|
40
|
+
light: "light";
|
|
41
|
+
dark: "dark";
|
|
42
|
+
}>>;
|
|
45
43
|
reduced_motion: z.ZodOptional<z.ZodBoolean>;
|
|
46
|
-
},
|
|
47
|
-
clock?: string | undefined;
|
|
48
|
-
locale?: string | undefined;
|
|
49
|
-
timezone?: string | undefined;
|
|
50
|
-
viewport?: {
|
|
51
|
-
width: number;
|
|
52
|
-
height: number;
|
|
53
|
-
} | "desktop" | "tablet" | "mobile" | undefined;
|
|
54
|
-
color_scheme?: "light" | "dark" | undefined;
|
|
55
|
-
reduced_motion?: boolean | undefined;
|
|
56
|
-
}, {
|
|
57
|
-
clock?: string | undefined;
|
|
58
|
-
locale?: string | undefined;
|
|
59
|
-
timezone?: string | undefined;
|
|
60
|
-
viewport?: {
|
|
61
|
-
width: number;
|
|
62
|
-
height: number;
|
|
63
|
-
} | "desktop" | "tablet" | "mobile" | undefined;
|
|
64
|
-
color_scheme?: "light" | "dark" | undefined;
|
|
65
|
-
reduced_motion?: boolean | undefined;
|
|
66
|
-
}>;
|
|
44
|
+
}, z.core.$strict>;
|
|
67
45
|
export type EnvironmentSpec = z.infer<typeof EnvironmentSpec>;
|
|
46
|
+
/**
|
|
47
|
+
* The stderr line for a CDP attach, which cannot apply context-level settings to a context the
|
|
48
|
+
* operator owns: names every `environment` field and the `contextOptions` that were skipped.
|
|
49
|
+
* `undefined` when nothing was skipped. The clock is a page-level install, so it still applies.
|
|
50
|
+
*/
|
|
51
|
+
export declare function attachSkipNotice(env: EnvironmentSpec | undefined, hasContextOptions: boolean): string | undefined;
|
|
52
|
+
/** Map an {@link EnvironmentSpec} to the Playwright context options it pins (clock excluded, that's a page-level install). */
|
|
53
|
+
export declare function environmentContextOptions(env: EnvironmentSpec): {
|
|
54
|
+
locale?: string;
|
|
55
|
+
timezoneId?: string;
|
|
56
|
+
viewport?: ViewportSize;
|
|
57
|
+
colorScheme?: "light" | "dark";
|
|
58
|
+
reducedMotion?: "reduce" | "no-preference";
|
|
59
|
+
};
|
package/dist/environment-spec.js
CHANGED
|
@@ -6,7 +6,7 @@ export const ViewportSize = z
|
|
|
6
6
|
.object({ width: z.number().int().positive(), height: z.number().int().positive() })
|
|
7
7
|
.strict();
|
|
8
8
|
export const ViewportPreset = z.enum(["desktop", "tablet", "mobile"]);
|
|
9
|
-
/** Named viewport presets
|
|
9
|
+
/** Named viewport presets, `desktop` 1440×900, `tablet` 834×1112, `mobile` 390×844. */
|
|
10
10
|
export const VIEWPORT_PRESETS = {
|
|
11
11
|
desktop: { width: 1440, height: 900 },
|
|
12
12
|
tablet: { width: 834, height: 1112 },
|
|
@@ -24,15 +24,43 @@ export const ColorScheme = z.enum(["light", "dark"]);
|
|
|
24
24
|
*/
|
|
25
25
|
export const EnvironmentSpec = z
|
|
26
26
|
.object({
|
|
27
|
-
/** ISO-8601 instant the page clock is frozen at
|
|
27
|
+
/** ISO-8601 instant the page clock is frozen at, `new Date()` etc. return this for the whole run. */
|
|
28
28
|
clock: z.string().datetime({ offset: true, local: true }).optional(),
|
|
29
29
|
/** BCP-47 language tag (e.g. `en-GB`). */
|
|
30
30
|
locale: LocaleTag.optional(),
|
|
31
31
|
/** IANA timezone (e.g. `Europe/Amsterdam`). */
|
|
32
32
|
timezone: z.string().min(1).optional(),
|
|
33
|
-
/** `{ width, height }` in CSS pixels, or a named preset
|
|
33
|
+
/** `{ width, height }` in CSS pixels, or a named preset, see {@link VIEWPORT_PRESETS}. */
|
|
34
34
|
viewport: z.union([ViewportPreset, ViewportSize]).optional(),
|
|
35
35
|
color_scheme: ColorScheme.optional(),
|
|
36
36
|
reduced_motion: z.boolean().optional(),
|
|
37
37
|
})
|
|
38
38
|
.strict();
|
|
39
|
+
/**
|
|
40
|
+
* The stderr line for a CDP attach, which cannot apply context-level settings to a context the
|
|
41
|
+
* operator owns: names every `environment` field and the `contextOptions` that were skipped.
|
|
42
|
+
* `undefined` when nothing was skipped. The clock is a page-level install, so it still applies.
|
|
43
|
+
*/
|
|
44
|
+
export function attachSkipNotice(env, hasContextOptions) {
|
|
45
|
+
const fields = ["locale", "timezone", "viewport", "color_scheme", "reduced_motion"]
|
|
46
|
+
.filter((k) => env?.[k] !== undefined)
|
|
47
|
+
.map((k) => `environment.${k}`);
|
|
48
|
+
if (hasContextOptions)
|
|
49
|
+
fields.push("contextOptions");
|
|
50
|
+
return fields.length
|
|
51
|
+
? `launchPlaywrightSession: attached over CDP, where the browser context is externally owned; skipped: ${fields.join(", ")}\n`
|
|
52
|
+
: undefined;
|
|
53
|
+
}
|
|
54
|
+
/** Map an {@link EnvironmentSpec} to the Playwright context options it pins (clock excluded, that's a page-level install). */
|
|
55
|
+
export function environmentContextOptions(env) {
|
|
56
|
+
const viewport = typeof env.viewport === "string" ? VIEWPORT_PRESETS[env.viewport] : env.viewport;
|
|
57
|
+
return {
|
|
58
|
+
...(env.locale ? { locale: env.locale } : {}),
|
|
59
|
+
...(env.timezone ? { timezoneId: env.timezone } : {}),
|
|
60
|
+
...(viewport ? { viewport } : {}),
|
|
61
|
+
...(env.color_scheme ? { colorScheme: env.color_scheme } : {}),
|
|
62
|
+
...(env.reduced_motion !== undefined
|
|
63
|
+
? { reducedMotion: env.reduced_motion ? "reduce" : "no-preference" }
|
|
64
|
+
: {}),
|
|
65
|
+
};
|
|
66
|
+
}
|
package/dist/export/adf.d.ts
CHANGED
|
@@ -20,7 +20,7 @@ export interface AdfAttachment {
|
|
|
20
20
|
fileName: string;
|
|
21
21
|
/** Absolute path of the source PNG inside the workspace. */
|
|
22
22
|
sourcePath: string;
|
|
23
|
-
/** sha256 (hex) of the source bytes
|
|
23
|
+
/** sha256 (hex) of the source bytes, the publisher's skip-unchanged key. */
|
|
24
24
|
sha256: string;
|
|
25
25
|
}
|
|
26
26
|
export interface AdfDocument {
|
package/dist/export/adf.js
CHANGED
|
@@ -1,28 +1,27 @@
|
|
|
1
|
-
// ADF (Atlassian Document Format) projection of a doc pack
|
|
1
|
+
// ADF (Atlassian Document Format) projection of a doc pack, pure, deterministic, zero HTTP.
|
|
2
2
|
//
|
|
3
3
|
// The engine emits projections only; all Confluence egress lives in the capability-declared
|
|
4
4
|
// publisher plugin (`@docsxai/plugin-confluence`). This module turns a workspace's
|
|
5
5
|
// doc pack (flow-files + step write-ups + burned screenshots) into Confluence Cloud REST v2
|
|
6
6
|
// `atlas_doc_format` documents plus an attachments manifest, in one of two shapes:
|
|
7
7
|
//
|
|
8
|
-
// - `single` (default): ONE consolidated document for the whole project
|
|
9
|
-
// anchored H2 section, every step an H3
|
|
8
|
+
// - `single` (default): ONE consolidated document for the whole project, every flow is an
|
|
9
|
+
// anchored H2 section, every step an H3, published as one page.
|
|
10
10
|
// - `page-tree`: a parent overview document (section "project") plus one child document per
|
|
11
11
|
// flow (section = flow name).
|
|
12
12
|
//
|
|
13
|
-
// Media nodes reference attachments by `alt` file name with empty `id`/`collection
|
|
13
|
+
// Media nodes reference attachments by `alt` file name with empty `id`/`collection`, the
|
|
14
14
|
// publisher (or a host agent handing the projection to the Atlassian MCP) fills the file ids
|
|
15
15
|
// in after upload. Attachment file names are `<flow>--<step>.png`, unique per document and
|
|
16
16
|
// stable across modes.
|
|
17
17
|
import { createHash } from "node:crypto";
|
|
18
|
-
import { promises as fs } from "node:fs";
|
|
19
18
|
import { parseFlowFile, resolveFlowExtends } from "../flow-file.js";
|
|
20
|
-
import { resolveWorkspacePath } from "../workspace.js";
|
|
19
|
+
import { listFlowNamesInside, readFileInside, resolveWorkspacePath } from "../workspace.js";
|
|
21
20
|
// ---------------------------------------------------------------------------
|
|
22
21
|
// markdown → ADF (subset converter)
|
|
23
22
|
// ---------------------------------------------------------------------------
|
|
24
23
|
// Supported: paragraphs, fenced code blocks, bullet/ordered lists, `code`, **bold**, *em* /
|
|
25
|
-
// _em_, [links](url). Anything else
|
|
24
|
+
// _em_, [links](url). Anything else, raw HTML included, stays literal text inside an ADF
|
|
26
25
|
// text node (ADF text is plain text, so markup can never be smuggled through).
|
|
27
26
|
function text(value, marks) {
|
|
28
27
|
return marks.length > 0 ? { type: "text", text: value, marks } : { type: "text", text: value };
|
|
@@ -87,7 +86,7 @@ export function inlineMarkdownToAdf(source, marks = []) {
|
|
|
87
86
|
if (token.start > 0)
|
|
88
87
|
out.push(text(rest.slice(0, token.start), marks));
|
|
89
88
|
if (token.kind === "code") {
|
|
90
|
-
// Code spans take no nested marks
|
|
89
|
+
// Code spans take no nested marks, literal content.
|
|
91
90
|
out.push(text(token.inner, [...marks, { type: "code" }]));
|
|
92
91
|
}
|
|
93
92
|
else if (token.kind === "link") {
|
|
@@ -184,32 +183,23 @@ function mediaSingle(fileName) {
|
|
|
184
183
|
],
|
|
185
184
|
};
|
|
186
185
|
}
|
|
187
|
-
async function readIfExists(p) {
|
|
188
|
-
try {
|
|
189
|
-
return await fs.readFile(p);
|
|
190
|
-
}
|
|
191
|
-
catch {
|
|
192
|
-
return null;
|
|
193
|
-
}
|
|
194
|
-
}
|
|
195
186
|
async function projectFlow(workspaceDir, flowName, flow, warnings) {
|
|
196
187
|
const nodes = [heading(2, flow.name)];
|
|
197
188
|
const attachments = [];
|
|
198
189
|
for (const step of flow.steps) {
|
|
199
|
-
const
|
|
200
|
-
const md = await readIfExists(mdPath);
|
|
190
|
+
const md = await readFileInside(workspaceDir, "docs", flowName, `${step.id}.md`);
|
|
201
191
|
const burnedPath = resolveWorkspacePath(workspaceDir, "docs", flowName, "burned", `${step.id}.png`);
|
|
202
192
|
const cleanPath = resolveWorkspacePath(workspaceDir, "docs", flowName, "screenshots", `${step.id}.png`);
|
|
203
193
|
let shotPath = null;
|
|
204
|
-
let shot = await
|
|
194
|
+
let shot = await readFileInside(workspaceDir, "docs", flowName, "burned", `${step.id}.png`);
|
|
205
195
|
if (shot) {
|
|
206
196
|
shotPath = burnedPath;
|
|
207
197
|
}
|
|
208
198
|
else {
|
|
209
|
-
shot = await
|
|
199
|
+
shot = await readFileInside(workspaceDir, "docs", flowName, "screenshots", `${step.id}.png`);
|
|
210
200
|
if (shot) {
|
|
211
201
|
shotPath = cleanPath;
|
|
212
|
-
warnings.push(`flow "${flowName}" step "${step.id}": burned screenshot missing
|
|
202
|
+
warnings.push(`flow "${flowName}" step "${step.id}": burned screenshot missing, falling back to the clean screenshot`);
|
|
213
203
|
}
|
|
214
204
|
}
|
|
215
205
|
if (md === null && shot === null)
|
|
@@ -234,11 +224,7 @@ async function projectFlow(workspaceDir, flowName, flow, warnings) {
|
|
|
234
224
|
}
|
|
235
225
|
async function loadFlows(workspaceDir, only) {
|
|
236
226
|
const flowsDir = resolveWorkspacePath(workspaceDir, "flows");
|
|
237
|
-
const
|
|
238
|
-
const names = entries
|
|
239
|
-
.filter((e) => e.endsWith(".flow.yaml"))
|
|
240
|
-
.map((e) => e.slice(0, -".flow.yaml".length))
|
|
241
|
-
.sort();
|
|
227
|
+
const names = await listFlowNamesInside(workspaceDir);
|
|
242
228
|
const wanted = only && only.length > 0 ? names.filter((n) => only.includes(n)) : names;
|
|
243
229
|
if (only) {
|
|
244
230
|
for (const o of only) {
|
|
@@ -248,7 +234,10 @@ async function loadFlows(workspaceDir, only) {
|
|
|
248
234
|
}
|
|
249
235
|
const load = async (name) => {
|
|
250
236
|
const p = resolveWorkspacePath(workspaceDir, "flows", `${name}.flow.yaml`);
|
|
251
|
-
|
|
237
|
+
const text = await readFileInside(workspaceDir, "flows", `${name}.flow.yaml`);
|
|
238
|
+
if (text === null)
|
|
239
|
+
throw new Error(`no flow named "${name}" at ${p}`);
|
|
240
|
+
return parseFlowFile(text.toString("utf8"), p);
|
|
252
241
|
};
|
|
253
242
|
const out = [];
|
|
254
243
|
for (const name of wanted) {
|
|
@@ -6,7 +6,7 @@ export interface PlaywrightExportOptions {
|
|
|
6
6
|
/**
|
|
7
7
|
* Render a flow as a self-contained Playwright `.spec.ts`. The flow must have its `extends`
|
|
8
8
|
* chain resolved first (see `resolveFlowExtends`) so the emitted spec carries the merged steps.
|
|
9
|
-
* Pure string transform
|
|
9
|
+
* Pure string transform, deterministic for a given flow.
|
|
10
10
|
*/
|
|
11
11
|
export declare function exportFlowAsPlaywrightTest(flow: FlowFile, options?: PlaywrightExportOptions): string;
|
|
12
12
|
export interface ExportedSpec {
|
|
@@ -1,16 +1,15 @@
|
|
|
1
|
-
// Flow-file → Playwright test export
|
|
1
|
+
// Flow-file → Playwright test export, pure, deterministic, zero HTTP.
|
|
2
2
|
//
|
|
3
3
|
// Each flow becomes one self-contained `.spec.ts`: locator const declarations from the flow's
|
|
4
4
|
// `locators` map, steps translated to Playwright actions, `wait_for` to waits, `success` to
|
|
5
5
|
// `expect(...)` assertions, the `environment` block to `test.use({...})` (+ `page.clock` for a
|
|
6
|
-
// frozen clock), and `optional: true` steps wrapped in try/catch (conditionally-present UI
|
|
6
|
+
// frozen clock), and `optional: true` steps wrapped in try/catch (conditionally-present UI, a
|
|
7
7
|
// miss is tolerated, mirroring the runtime). The flow-file stays the source of truth: generated
|
|
8
8
|
// specs carry a "regenerate, don't hand-edit" header and are meant to live in the consumer's
|
|
9
9
|
// Playwright suite as a drift tripwire between docs and reality.
|
|
10
|
-
import { promises as fs } from "node:fs";
|
|
11
10
|
import { VIEWPORT_PRESETS, } from "../doc-pack.js";
|
|
12
11
|
import { locatorRefName, parseFlowFile, resolveFlowExtends } from "../flow-file.js";
|
|
13
|
-
import { resolveWorkspacePath } from "../workspace.js";
|
|
12
|
+
import { listFlowNamesInside, readFileInside, resolveWorkspacePath } from "../workspace.js";
|
|
14
13
|
const RESERVED = new Set([
|
|
15
14
|
// ES reserved words + the identifiers the generated scaffold itself uses.
|
|
16
15
|
...`await break case catch class const continue debugger default delete do else enum export
|
|
@@ -67,7 +66,7 @@ function actionLines(step, ids) {
|
|
|
67
66
|
const target = step.target !== undefined ? locatorExpr(step.target, ids) : null;
|
|
68
67
|
const value = step.value;
|
|
69
68
|
const missing = (what) => [
|
|
70
|
-
`// step "${step.id}": ${step.action} without ${what}
|
|
69
|
+
`// step "${step.id}": ${step.action} without ${what}, nothing to emit`,
|
|
71
70
|
];
|
|
72
71
|
// A step's `timeout_ms` becomes Playwright's per-call `{ timeout }`; absent, the call is unchanged.
|
|
73
72
|
const callOpts = step.timeout_ms !== undefined ? `{ timeout: ${step.timeout_ms} }` : null;
|
|
@@ -143,7 +142,7 @@ function waitLines(wait, step, ids) {
|
|
|
143
142
|
// visibility wait on the step target when there is one.
|
|
144
143
|
return step.target !== undefined
|
|
145
144
|
? [`await ${locatorExpr(step.target, ids)}.waitFor({ state: "visible" }); // element_stable`]
|
|
146
|
-
: [`// wait_for: element_stable
|
|
145
|
+
: [`// wait_for: element_stable. Playwright auto-waits on the next action`];
|
|
147
146
|
}
|
|
148
147
|
if ("selector" in wait) {
|
|
149
148
|
const opts = wait.timeout_ms !== undefined
|
|
@@ -179,14 +178,14 @@ function stepLines(step, ids) {
|
|
|
179
178
|
"try {",
|
|
180
179
|
...body.map((l) => ` ${l}`),
|
|
181
180
|
"} catch {",
|
|
182
|
-
" // optional step
|
|
181
|
+
" // optional step: conditionally-present UI; a miss is tolerated",
|
|
183
182
|
"}",
|
|
184
183
|
];
|
|
185
184
|
}
|
|
186
185
|
/**
|
|
187
186
|
* Render a flow as a self-contained Playwright `.spec.ts`. The flow must have its `extends`
|
|
188
187
|
* chain resolved first (see `resolveFlowExtends`) so the emitted spec carries the merged steps.
|
|
189
|
-
* Pure string transform
|
|
188
|
+
* Pure string transform, deterministic for a given flow.
|
|
190
189
|
*/
|
|
191
190
|
export function exportFlowAsPlaywrightTest(flow, options = {}) {
|
|
192
191
|
if (flow.extends) {
|
|
@@ -198,7 +197,7 @@ export function exportFlowAsPlaywrightTest(flow, options = {}) {
|
|
|
198
197
|
const fileName = options.flowFileName ?? flow.name;
|
|
199
198
|
const ids = locatorIdentifiers(flow);
|
|
200
199
|
const lines = [
|
|
201
|
-
`// generated from ${fileName}.flow.yaml
|
|
200
|
+
`// generated from ${fileName}.flow.yaml. Regenerate, don't hand-edit`,
|
|
202
201
|
`import { expect, test } from "@playwright/test";`,
|
|
203
202
|
"",
|
|
204
203
|
];
|
|
@@ -226,11 +225,7 @@ export function exportFlowAsPlaywrightTest(flow, options = {}) {
|
|
|
226
225
|
*/
|
|
227
226
|
export async function exportWorkspaceFlowsAsPlaywrightTests(opts) {
|
|
228
227
|
const flowsDir = resolveWorkspacePath(opts.workspaceDir, "flows");
|
|
229
|
-
const
|
|
230
|
-
const names = entries
|
|
231
|
-
.filter((e) => e.endsWith(".flow.yaml"))
|
|
232
|
-
.map((e) => e.slice(0, -".flow.yaml".length))
|
|
233
|
-
.sort();
|
|
228
|
+
const names = await listFlowNamesInside(opts.workspaceDir);
|
|
234
229
|
const wanted = opts.flows && opts.flows.length > 0 ? opts.flows : names;
|
|
235
230
|
for (const w of wanted) {
|
|
236
231
|
if (!names.includes(w))
|
|
@@ -238,7 +233,10 @@ export async function exportWorkspaceFlowsAsPlaywrightTests(opts) {
|
|
|
238
233
|
}
|
|
239
234
|
const load = async (name) => {
|
|
240
235
|
const p = resolveWorkspacePath(opts.workspaceDir, "flows", `${name}.flow.yaml`);
|
|
241
|
-
|
|
236
|
+
const text = await readFileInside(opts.workspaceDir, "flows", `${name}.flow.yaml`);
|
|
237
|
+
if (text === null)
|
|
238
|
+
throw new Error(`no flow named "${name}" at ${p}`);
|
|
239
|
+
return parseFlowFile(text.toString("utf8"), p);
|
|
242
240
|
};
|
|
243
241
|
const out = [];
|
|
244
242
|
for (const name of wanted) {
|
package/dist/flow-file.d.ts
CHANGED
|
@@ -22,6 +22,6 @@ export declare function referencedLocatorNames(flow: FlowFile): Set<string>;
|
|
|
22
22
|
* `prerequisites` are merged (this flow wins on locator-name collisions); `environment` merges per-key with
|
|
23
23
|
* this flow's keys winning; `redactions` concatenate (parent's first); step ids must be unique across the
|
|
24
24
|
* merge. `matrix` is the child's own (never inherited). Chains are followed recursively; cycles throw. `loadFlowFile(name)` parses `flows/<name>.flow.yaml`
|
|
25
|
-
* (a flow with its own `extends` un-resolved
|
|
25
|
+
* (a flow with its own `extends` un-resolved, this function recurses). The result has no `extends`.
|
|
26
26
|
*/
|
|
27
27
|
export declare function resolveFlowExtends(flow: FlowFile, loadFlowFile: (name: string) => Promise<FlowFile> | FlowFile, visited?: Set<string>): Promise<FlowFile>;
|
package/dist/flow-file.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
//
|
|
3
3
|
// A flow-file is the source of truth for execution: declarative YAML, hand-editable,
|
|
4
4
|
// translated to Playwright at run time (see flow-runtime, to come). This module is the
|
|
5
|
-
// parse/validate/serialize boundary
|
|
5
|
+
// parse/validate/serialize boundary, everything downstream works with the validated
|
|
6
6
|
// `FlowFile` value, never raw YAML.
|
|
7
7
|
import { parse as parseYaml, stringify as stringifyYaml } from "yaml";
|
|
8
8
|
import { FlowFile } from "./doc-pack.js";
|
|
@@ -15,8 +15,23 @@ export class FlowFileError extends Error {
|
|
|
15
15
|
this.name = "FlowFileError";
|
|
16
16
|
}
|
|
17
17
|
}
|
|
18
|
+
/** The issues to print for `issue`: a union failure is replaced by the issues of its closest branch. */
|
|
19
|
+
function expandIssue(issue) {
|
|
20
|
+
if (issue.code !== "invalid_union")
|
|
21
|
+
return [issue];
|
|
22
|
+
// Zod 4 keeps the issues of each branch in `errors`, with paths relative to the union.
|
|
23
|
+
const branches = issue.errors;
|
|
24
|
+
if (branches.length === 0)
|
|
25
|
+
return [issue];
|
|
26
|
+
// The branch that got deepest into the value is the one the author meant; ties go to fewer issues.
|
|
27
|
+
const depth = (b) => Math.max(0, ...b.map((i) => i.path.length));
|
|
28
|
+
const best = branches.reduce((a, b) => depth(b) > depth(a) || (depth(b) === depth(a) && b.length < a.length) ? b : a);
|
|
29
|
+
const inPlace = best.map((i) => ({ ...i, path: [...issue.path, ...i.path] }));
|
|
30
|
+
return inPlace.length > 0 ? inPlace.flatMap(expandIssue) : [issue];
|
|
31
|
+
}
|
|
18
32
|
function formatZodIssues(err) {
|
|
19
33
|
return err.issues
|
|
34
|
+
.flatMap(expandIssue)
|
|
20
35
|
.map((i) => {
|
|
21
36
|
const path = i.path.length ? i.path.join(".") : "(root)";
|
|
22
37
|
return ` • ${path}: ${i.message}`;
|
|
@@ -30,14 +45,14 @@ export function parseFlowFile(yamlText, source = "<flow-file>") {
|
|
|
30
45
|
raw = parseYaml(yamlText);
|
|
31
46
|
}
|
|
32
47
|
catch (e) {
|
|
33
|
-
throw new FlowFileError(`${source}: not valid YAML
|
|
48
|
+
throw new FlowFileError(`${source}: not valid YAML: ${e.message}`, e);
|
|
34
49
|
}
|
|
35
50
|
const result = FlowFile.safeParse(raw);
|
|
36
51
|
if (!result.success) {
|
|
37
52
|
throw new FlowFileError(`${source}: invalid flow-file:\n${formatZodIssues(result.error)}`, result.error);
|
|
38
53
|
}
|
|
39
54
|
const flow = result.data;
|
|
40
|
-
// A flow with `extends` may reference locators it inherits from the parent
|
|
55
|
+
// A flow with `extends` may reference locators it inherits from the parent, defer the ref check to
|
|
41
56
|
// `resolveFlowExtends`, which runs it on the merged flow.
|
|
42
57
|
if (!flow.extends)
|
|
43
58
|
assertLocatorRefsResolve(flow, source);
|
|
@@ -157,7 +172,7 @@ function assertStepIdsUnique(flow, source) {
|
|
|
157
172
|
* `prerequisites` are merged (this flow wins on locator-name collisions); `environment` merges per-key with
|
|
158
173
|
* this flow's keys winning; `redactions` concatenate (parent's first); step ids must be unique across the
|
|
159
174
|
* merge. `matrix` is the child's own (never inherited). Chains are followed recursively; cycles throw. `loadFlowFile(name)` parses `flows/<name>.flow.yaml`
|
|
160
|
-
* (a flow with its own `extends` un-resolved
|
|
175
|
+
* (a flow with its own `extends` un-resolved, this function recurses). The result has no `extends`.
|
|
161
176
|
*/
|
|
162
177
|
export async function resolveFlowExtends(flow, loadFlowFile, visited = new Set()) {
|
|
163
178
|
if (!flow.extends)
|
|
@@ -171,6 +186,9 @@ export async function resolveFlowExtends(flow, loadFlowFile, visited = new Set()
|
|
|
171
186
|
parentRaw = await loadFlowFile(flow.extends);
|
|
172
187
|
}
|
|
173
188
|
catch (e) {
|
|
189
|
+
if (e?.code === "ENOENT") {
|
|
190
|
+
throw new FlowFileError(`flow "${flow.name}" extends "${flow.extends}", but flows/${flow.extends}.flow.yaml does not exist`, e);
|
|
191
|
+
}
|
|
174
192
|
throw e instanceof FlowFileError
|
|
175
193
|
? e
|
|
176
194
|
: new FlowFileError(`flow "${flow.name}": cannot load \`extends\` target "${flow.extends}": ${e.message}`, e);
|
package/dist/flow-halt.d.ts
CHANGED
|
@@ -9,7 +9,7 @@ export declare class FlowExecutionError extends Error {
|
|
|
9
9
|
}
|
|
10
10
|
/**
|
|
11
11
|
* Best-effort 1-line cause extracted from a Playwright actionability log (or similar driver
|
|
12
|
-
* error). Returns undefined when nothing matches
|
|
12
|
+
* error). Returns undefined when nothing matches, keeps the halt message short rather than
|
|
13
13
|
* guessing. Surfaced as a `[cause]` prefix on the halt message so the agent doesn't have to
|
|
14
14
|
* scan the multi-line actionability log.
|
|
15
15
|
*/
|
package/dist/flow-halt.js
CHANGED
|
@@ -17,7 +17,7 @@ export class FlowExecutionError extends Error {
|
|
|
17
17
|
}
|
|
18
18
|
/**
|
|
19
19
|
* Best-effort 1-line cause extracted from a Playwright actionability log (or similar driver
|
|
20
|
-
* error). Returns undefined when nothing matches
|
|
20
|
+
* error). Returns undefined when nothing matches, keeps the halt message short rather than
|
|
21
21
|
* guessing. Surfaced as a `[cause]` prefix on the halt message so the agent doesn't have to
|
|
22
22
|
* scan the multi-line actionability log.
|
|
23
23
|
*/
|
|
@@ -27,6 +27,18 @@ export function inferHaltCause(rawError) {
|
|
|
27
27
|
/docsxai: cannot hide/i,
|
|
28
28
|
"the browser can't apply the hide rule (no constructable stylesheets), so the element would stay visible",
|
|
29
29
|
],
|
|
30
|
+
[
|
|
31
|
+
/net::ERR_(?:CONNECTION_REFUSED|CONNECTION_RESET|CONNECTION_TIMED_OUT|NAME_NOT_RESOLVED|ADDRESS_UNREACHABLE|INTERNET_DISCONNECTED)\b/i,
|
|
32
|
+
"the app did not answer: start it, then check app_url in .docsxai.json or pass --base-url",
|
|
33
|
+
],
|
|
34
|
+
[
|
|
35
|
+
/net::ERR_(?:CERT|SSL)_\w+/i,
|
|
36
|
+
"the app's TLS certificate was rejected: pass --ignore-https-errors, or set ignore_https_errors in .docsxai.json",
|
|
37
|
+
],
|
|
38
|
+
[
|
|
39
|
+
/Cannot navigate to invalid URL/i,
|
|
40
|
+
"a relative path has no app_url to resolve against: set app_url in .docsxai.json or pass --base-url",
|
|
41
|
+
],
|
|
30
42
|
[/element is disabled\b/i, "target is disabled"],
|
|
31
43
|
[/element is not enabled\b/i, "target is not enabled"],
|
|
32
44
|
[
|
|
@@ -58,11 +70,11 @@ export function inferHaltCause(rawError) {
|
|
|
58
70
|
[/intercepts? pointer events\b/i, "target is covered by another element"],
|
|
59
71
|
[
|
|
60
72
|
/strict mode violation\b/i,
|
|
61
|
-
"selector matched multiple elements (strict-mode violation)
|
|
73
|
+
"selector matched multiple elements (strict-mode violation); scope with :visible / :nth-match",
|
|
62
74
|
],
|
|
63
75
|
[
|
|
64
76
|
/timeout .* exceeded.*waiting for/is,
|
|
65
|
-
"timeout waiting for selector
|
|
77
|
+
"timeout waiting for selector: element didn't appear in time (consider raising timeout_ms or revisiting the locator)",
|
|
66
78
|
],
|
|
67
79
|
];
|
|
68
80
|
for (const [re, msg] of hints) {
|
package/dist/flow-lint.d.ts
CHANGED
|
@@ -8,7 +8,7 @@ export type LintIssue = {
|
|
|
8
8
|
message: string;
|
|
9
9
|
suggestion?: string;
|
|
10
10
|
};
|
|
11
|
-
/** An injectable lint rule
|
|
11
|
+
/** An injectable lint rule, the open hinge for the plugins runtime. Runs after the built-ins. */
|
|
12
12
|
export type LintRule = {
|
|
13
13
|
/** Stable diagnostic code (the built-ins use `RNNN`; injected rules should pick another prefix). */
|
|
14
14
|
code: string;
|
|
@@ -19,6 +19,8 @@ export type LintOptions = {
|
|
|
19
19
|
loadFlow?: (name: string) => Promise<FlowFile> | FlowFile;
|
|
20
20
|
/** Additional rules run after the built-ins (same flow, same options). */
|
|
21
21
|
extraRules?: LintRule[];
|
|
22
|
+
/** The flow's file name (`checkout.flow.yaml`), for the rules that compare it with the flow's name. */
|
|
23
|
+
fileName?: string;
|
|
22
24
|
};
|
|
23
25
|
export declare function lintFlow(flow: FlowFile, opts?: LintOptions): Promise<LintIssue[]>;
|
|
24
26
|
export declare function formatIssuesText(issues: LintIssue[]): string;
|