@sungen/driver-ui 3.1.2-beta.100

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/package.json ADDED
@@ -0,0 +1,25 @@
1
+ {
2
+ "name": "@sungen/driver-ui",
3
+ "version": "3.1.2-beta.100",
4
+ "description": "Sungen UI capability (Playwright) — step patterns, viewpoint gate, and phase hooks. Plugs into @sun-asterisk/sungen via the capability SPI.",
5
+ "main": "src/index.ts",
6
+ "types": "src/index.ts",
7
+ "sungen": {
8
+ "capability": "ui"
9
+ },
10
+ "scripts": {
11
+ "build": "rm -rf dist && tsc -p tsconfig.json"
12
+ },
13
+ "author": "eqe team (engineer & quality) — Sun Asterisk",
14
+ "license": "MIT",
15
+ "dependencies": {
16
+ "@sun-asterisk/sungen": "3.1.2-beta.100"
17
+ },
18
+ "peerDependencies": {
19
+ "@playwright/test": "^1.57.0"
20
+ },
21
+ "files": [
22
+ "dist",
23
+ "src"
24
+ ]
25
+ }
package/src/index.ts ADDED
@@ -0,0 +1,119 @@
1
+ /**
2
+ * @sungen/driver-ui — Sungen UI capability (Playwright).
3
+ *
4
+ * The default/implicit capability: a scenario with no capability tag is UI. Owns the step-pattern
5
+ * vocabulary, the universal viewpoint catalog, the coverage-gate + assertion-depth computation, and
6
+ * the screen/flow discovery + context hooks. Plugs into core via the capability SPI; core discovers
7
+ * and calls `register()` at runtime (core never imports this package).
8
+ *
9
+ * Relocated from core in R5.4 (was `src/capabilities/builtins.ts` + the in-core pattern files).
10
+ * Note: the base Playwright spec templates (`specs-base`/`specs-locale`) remain in core for now —
11
+ * they're emitted by the core generator/initializer, not through this capability; disentangling them
12
+ * needs the generator abstraction (Orchestration Engine, #287).
13
+ */
14
+ import type {
15
+ CapabilityRegistry,
16
+ Sensor,
17
+ GateInput,
18
+ DiscoveryProvider,
19
+ ContextMapper,
20
+ GenerationUnit,
21
+ ScenarioInfo,
22
+ ViewpointEntry,
23
+ Catalog,
24
+ GateResult,
25
+ DepthResult,
26
+ } from '@sun-asterisk/sungen';
27
+ import { loadCatalog, viewpointGate, assertionDepth, dataThemesFor } from '@sun-asterisk/sungen';
28
+
29
+ import { setupPatterns } from './patterns/setup-patterns';
30
+ import { navigationPatterns } from './patterns/navigation-patterns';
31
+ import { formPatterns } from './patterns/form-patterns';
32
+ import { interactionPatterns } from './patterns/interaction-patterns';
33
+ import { assertionPatterns } from './patterns/assertion-patterns';
34
+ import { keyboardPatterns } from './patterns/keyboard-patterns';
35
+ import { scrollPatterns } from './patterns/scroll-patterns';
36
+ import { scopePatterns } from './patterns/scope-patterns';
37
+ import { tablePatterns } from './patterns/table-patterns';
38
+ import { capturePatterns } from './patterns/capture-patterns';
39
+
40
+ /** Inputs the UI gate computation needs (passed by the audit engine via `gateProvider`). */
41
+ export interface UiGateInput {
42
+ scenarios: ScenarioInfo[];
43
+ viewpoints: ViewpointEntry[];
44
+ catalog: Catalog;
45
+ focus: Parameters<typeof assertionDepth>[2];
46
+ }
47
+ export interface UiGateResult {
48
+ gate: GateResult;
49
+ depth: DepthResult;
50
+ }
51
+
52
+ /**
53
+ * UI score-bearing gate computation: viewpoint coverage + assertion depth. Wraps the shared sensor
54
+ * functions verbatim, so the produced gate/depth (and therefore the score) are byte-identical.
55
+ */
56
+ const uiGateProvider = (input: UiGateInput): UiGateResult => {
57
+ const gate = viewpointGate(input.scenarios, input.viewpoints, input.catalog);
58
+ const depth = assertionDepth(input.scenarios, dataThemesFor(input.catalog, gate.pageType), input.focus);
59
+ return { gate, depth };
60
+ };
61
+
62
+ /**
63
+ * UI viewpoint gate sensor: surfaces the universal-viewpoint theme gaps the coverage gate found
64
+ * (a low-priority reminder — does NOT affect the score or gate verdict).
65
+ */
66
+ const uiViewpointGateSensor: Sensor<GateInput> = {
67
+ id: 'ui-viewpoint',
68
+ capability: 'ui',
69
+ kind: 'gate',
70
+ run: ({ universalGaps }) =>
71
+ universalGaps && universalGaps.length
72
+ ? [{ sensorId: 'ui-viewpoint', capability: 'ui', message: `UNIVERSAL: missing theme(s): ${universalGaps.join(', ')} (low priority reminder).`, severity: 'info' }]
73
+ : [],
74
+ };
75
+
76
+ // UI phase hooks (the pipeline consumes these incrementally; full capture-mode wiring lands later).
77
+ const uiDiscovery: DiscoveryProvider = {
78
+ appliesTo: (t) => t.kind === 'screen' || t.kind === 'flow',
79
+ discover: async (target) => ({ target: { ...target, capability: 'ui' }, sources: {}, facts: {} }),
80
+ };
81
+
82
+ const uiContextMapper: ContextMapper = {
83
+ decompose: (ctx) => {
84
+ const f = (ctx.facts || {}) as { screens?: unknown[]; flows?: unknown[] };
85
+ const units: GenerationUnit[] = [];
86
+ for (const s of f.screens ?? []) units.push({ mode: 'screen', targetSlice: s });
87
+ for (const fl of f.flows ?? []) units.push({ mode: 'flow', targetSlice: fl });
88
+ if (!units.length) units.push({ mode: ctx.target.kind === 'flow' ? 'flow' : 'screen', targetSlice: ctx.target });
89
+ return units;
90
+ },
91
+ };
92
+
93
+ /** Register the UI capability — the default/implicit capability. */
94
+ export function register(registry: CapabilityRegistry): void {
95
+ registry.register({
96
+ id: 'ui',
97
+ default: true,
98
+ annotations: [],
99
+ patterns: [
100
+ ...setupPatterns,
101
+ ...navigationPatterns,
102
+ ...formPatterns,
103
+ ...interactionPatterns,
104
+ ...assertionPatterns,
105
+ ...keyboardPatterns,
106
+ ...scrollPatterns,
107
+ ...scopePatterns,
108
+ ...tablePatterns,
109
+ ...capturePatterns,
110
+ ],
111
+ discovery: uiDiscovery,
112
+ contextMapper: uiContextMapper,
113
+ viewpoints: loadCatalog, // UI owns the 17-pattern universal viewpoint catalog
114
+ gateProvider: uiGateProvider as (i: unknown) => unknown, // viewpoint coverage + depth
115
+ sensors: [uiViewpointGateSensor],
116
+ });
117
+ }
118
+
119
+ export const sungenDriver = { capability: 'ui', register } as const;