@sun-asterisk/sungen 3.2.11 → 3.2.12-beta.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.
Files changed (51) hide show
  1. package/dist/capabilities/discover.d.ts.map +1 -1
  2. package/dist/capabilities/discover.js +5 -2
  3. package/dist/capabilities/discover.js.map +1 -1
  4. package/dist/cli/commands/capability.d.ts.map +1 -1
  5. package/dist/cli/commands/capability.js +44 -2
  6. package/dist/cli/commands/capability.js.map +1 -1
  7. package/dist/dashboard/templates/index.html +1 -1
  8. package/dist/exporters/csv-exporter.d.ts.map +1 -1
  9. package/dist/exporters/csv-exporter.js +7 -2
  10. package/dist/exporters/csv-exporter.js.map +1 -1
  11. package/dist/exporters/feature-parser.d.ts.map +1 -1
  12. package/dist/exporters/feature-parser.js +15 -2
  13. package/dist/exporters/feature-parser.js.map +1 -1
  14. package/dist/exporters/json-exporter.d.ts.map +1 -1
  15. package/dist/exporters/json-exporter.js +10 -5
  16. package/dist/exporters/json-exporter.js.map +1 -1
  17. package/dist/exporters/result-variants.d.ts +23 -5
  18. package/dist/exporters/result-variants.d.ts.map +1 -1
  19. package/dist/exporters/result-variants.js +65 -9
  20. package/dist/exporters/result-variants.js.map +1 -1
  21. package/dist/exporters/test-data-resolver.d.ts.map +1 -1
  22. package/dist/exporters/test-data-resolver.js.map +1 -1
  23. package/dist/harness/capability.d.ts +1 -0
  24. package/dist/harness/capability.d.ts.map +1 -1
  25. package/dist/harness/capability.js.map +1 -1
  26. package/dist/harness/catalog/drivers.yaml +2 -1
  27. package/dist/orchestrator/templates/ai-src/commands/create-data-test.md +99 -0
  28. package/dist/orchestrator/templates/ai-src/commands/create-test.md +3 -0
  29. package/dist/orchestrator/templates/ai-src/commands/run-test.md +1 -0
  30. package/dist/orchestrator/templates/ai-src/config/claude.md +3 -1
  31. package/dist/orchestrator/templates/ai-src/config/copilot.md +3 -1
  32. package/dist/orchestrator/templates/ai-src/skills/sungen-data-factory/SKILL.md +116 -0
  33. package/dist/orchestrator/templates/ai-src/skills/sungen-tc-generation/SKILL.md +1 -0
  34. package/package.json +3 -2
  35. package/src/capabilities/discover.ts +5 -2
  36. package/src/cli/commands/capability.ts +40 -2
  37. package/src/dashboard/templates/index.html +1 -1
  38. package/src/exporters/csv-exporter.ts +7 -3
  39. package/src/exporters/feature-parser.ts +15 -2
  40. package/src/exporters/json-exporter.ts +10 -6
  41. package/src/exporters/result-variants.ts +68 -9
  42. package/src/exporters/test-data-resolver.ts +1 -0
  43. package/src/harness/capability.ts +1 -0
  44. package/src/harness/catalog/drivers.yaml +2 -1
  45. package/src/orchestrator/templates/ai-src/commands/create-data-test.md +99 -0
  46. package/src/orchestrator/templates/ai-src/commands/create-test.md +3 -0
  47. package/src/orchestrator/templates/ai-src/commands/run-test.md +1 -0
  48. package/src/orchestrator/templates/ai-src/config/claude.md +3 -1
  49. package/src/orchestrator/templates/ai-src/config/copilot.md +3 -1
  50. package/src/orchestrator/templates/ai-src/skills/sungen-data-factory/SKILL.md +116 -0
  51. package/src/orchestrator/templates/ai-src/skills/sungen-tc-generation/SKILL.md +1 -0
@@ -167,6 +167,8 @@ If the unit is **api-first** (`qa/api/<name>/` or `qa/api/flows/<name>/`), the d
167
167
 
168
168
  **5d. Sequential fallback.** Use the single-context incremental path (Step 2: tier-by-tier `Write`/`Edit` batches) when: only **one** shard applies, **Copilot / no sub-agents**, or a constrained setup. Same output, just no speedup. **For flows**: `[Screen:Element]` namespace refs, test-data namespaced by phase, `@flow` tag.
169
169
 
170
+ 5.3. **Standardize field test-data — Data Factory (when the unit has input fields).** Don't hand-invent per-field values — make them **standard**. For each input field, author the field-map `qa/data-factory/<name>.fields.yaml` (field → catalog `type` + the spec's real `constraints` + `errorMap` placeholder→real code), then run (Bash, local-first) `[ -x ./bin/sungen.js ] && ./bin/sungen.js data lint --screen <name> || npx sungen data lint --screen <name>` and `… data gen --screen <name>`, per the **`sungen-data-factory`** skill. `data gen` **MERGES** into `test-data.yaml` (replaces only its field keys, preserves your scenario/namespaced data), so it is safe to run here. Weave the standardized **boundary/invalid** sets into `@cases` (`Scenario Outline` + `Examples`) with `CHK-*` trace; keep the map's `errorMap`/`constraints` aligned to the spec. **This is the same standard as `/sungen:create-data-test`, applied inline — so you do NOT run that command separately afterwards.** A unit with **no input fields** (navigation / list / capture-compare) → **skip this step** (nothing to standardize).
171
+
170
172
  5.4. **Depth self-check (deterministic — run BEFORE the audit).** Run `sungen depth-lint --screen <name>` (Bash). It reuses the audit's businessDepth classifier and splits every shallow business-critical scenario into two actionable buckets — act on them now so the audit/repair loop doesn't burn rounds on depth:
171
173
  - **DEEPEN IN PLACE** — add a real value assertion to each (`User see all [X] contain {{v}}`, `User remember [X] as {{v}}` + `… with {{v}}`). The printed `template` is a **hint** keyed off the theme — apply judgment to the scenario's actual claim; do NOT paste a value assertion that doesn't fit (e.g. a carousel-visibility scenario should assert the product SET, not a price). If a flagged scenario is genuinely visibility/behavior (not data-correctness), that's an over-count — leave it and note it, never fake an assertion.
172
174
  - **CROSS-SCREEN** — route to a flow (`/sungen:add-flow`) or tag `@manual:Mx` + reason; do NOT fake an on-screen data assertion. This removes it from the screen's depth denominator honestly.
@@ -194,6 +196,7 @@ If the unit is **api-first** (`qa/api/<name>/` or `qa/api/flows/<name>/`), the d
194
196
  4. Follow the `sungen-tc-generation` skill for section identification, viewpoint generation, and output format. **For flows**, use the "Flow Test Generation" section in the skill. When requirements exist, use the "Requirements-Driven Generation" strategy. **For Tier 1**, apply the **Lightweight Guard** — verify required fields, validation rules, business rules, security checks, and key state transitions all have TCs after generation. **For Tier 2+**, **MUST** apply the full **Mapping Contract** — walk every `spec.md` section top-to-bottom and produce the indicated TCs per Table 1; handle `test-viewpoint.md` per Table 2. Do not silently skip sections. Present sections as a numbered list and let user pick.
195
197
  5. Generate or update `.feature` + `test-data.yaml` following `sungen-gherkin-syntax` and `sungen-tc-generation` skills. Generate **group-by-group** (one viewpoint group at a time, tier-by-tier `Write`/`Edit` batches) to stay under the output-token cap. **For flows**: use `[Screen:Element]` namespace format, namespace test-data by phase, add `@flow` tag. **If a scenario needs `@query` DB verification**, check the datasource `engine` first — unsupported engine → follow `sungen-gherkin-syntax` § "Unsupported DB engine — fallback" instead of authoring `@query` steps.
196
198
  > **No parallel fan-out here.** Copilot has no sub-agents, so generation is sequential (the Claude Code variant fans out one `sungen-generator` per viewpoint group and merges). Same output, no speedup.
199
+ 5.3. **Standardize field test-data — Data Factory (when the unit has input fields).** For each input field, author the field-map `qa/data-factory/<name>.fields.yaml` (field → catalog `type` + real `constraints` + `errorMap`), then run `sungen data lint --screen ${input:name}` and `sungen data gen --screen ${input:name}` per the **`sungen-data-factory`** skill. `data gen` **MERGES** into `test-data.yaml` (replaces only its field keys, preserves the rest), so it is safe here. Weave the standardized boundary/invalid sets into `@cases` with `CHK-*` trace. **Same standard as `/sungen:create-data-test`, applied inline — do NOT run that command separately afterwards.** No input fields (navigation/list) → skip.
197
200
  5.4. **Depth self-check (deterministic — BEFORE the audit).** Run `sungen depth-lint --screen ${input:name}`. It splits every shallow business-critical scenario into **DEEPEN IN PLACE** (add a real value assertion — the printed `template` is a theme-keyed hint, apply judgment to the actual claim; never fake one onto a visibility/behavior scenario) and **CROSS-SCREEN** (route to a flow / tag `@manual:Mx` + reason — removes it from the depth denominator honestly). Act on both, re-run until `deepen` is empty (or only honest over-counts remain), THEN gate. Lifts first-pass `businessDepth` mechanically instead of via 2–3 repair rounds.
198
201
  5.5. **Quality gate & repair (harness — always run).** Per `sungen-harness-audit`: run `sungen audit --screen ${input:name}` (structural), THEN do an **independent semantic review inline** using the `sungen-reviewer` criteria (does each scenario's steps PROVE its title/viewpoint? observable Thens? business-critical assertion depth?). Merge both sets of issues; if gate FAILs / findings exist, repair (budget 3) and re-audit — GATE missing theme → generate it (cross-screen → **automate it in the flow** via `/sungen:add-flow`, NOT a full `@manual` screen duplicate — `sungen audit` flags an automatable `@manual` as `MANUAL-AUTOMATABLE`; reserve `@manual:Mx` for true judgment/missing-capability); DEPTH → add data assertions; BALANCE → add business-core first; TRACE → align VP ids. Never fake a pass.
199
202
  5.6. **Record.** `sungen manifest --screen ${input:name}`. Ledger **each phase** (not just repair) — pick one `runId` at the start and pass it so `trace`/`ledger report` show THIS run, not a mix: `sungen ledger record --screen ${input:name} --run <runId> --step <discovery|viewpoint|gherkin|audit|repair:N> --ms <elapsed>`. On re-run, start with `sungen manifest --screen ${input:name} --diff` and only regenerate changed sections.
@@ -127,6 +127,7 @@ If the unit is **api-first**, skip every selector/capture phase (an API test has
127
127
  ## Pre-run (phased — per `sungen-selector-fix` skill)
128
128
 
129
129
  1. Verify `<base>/<name>/` has `.feature` + `test-data.yaml`. **If the feature has `@query` steps**, check the resolved datasource `engine` in `qa/datasources.yaml` — unsupported engine → follow the `sungen-gherkin-syntax` skill § "Unsupported DB engine — fallback" before compiling (do not attempt a direct connect).
130
+ 1.5. **Data Factory pre-check (before running)** — Data Factory is bundled with core, so whenever a field-map exists (`qa/data-factory/<name>.fields.yaml`), confirm the test-data is standardized and covers each field before you run: `[ -x ./bin/sungen.js ] && ./bin/sungen.js data lint --screen <name> || npx sungen data lint --screen <name>`. If it reports coverage gaps (missing boundary/invalid, unresolved values, unmapped error codes) or the field-map is newer than `test-data/<name>.yaml`, refresh via `/sungen:create-data-test <name>` (or `sungen data gen --screen <name>`) — then compile. Blind spots (a `type` not in the catalog) are for the QA to answer, not to invent. No field-map / driver disabled → skip this step.
130
131
  2. **Phase 0 — Selector Pre-gen**: if `selectors.yaml` is missing/empty or doesn't cover the feature file's `[Reference]`s, apply the following decision tree before running Phase 0 from `sungen-selector-fix`:
131
132
 
132
133
  ```
@@ -18,14 +18,16 @@ You generate 3 files for sungen — a Gherkin compiler that produces Playwright
18
18
  | `sungen-delivery` | Export Gherkin + Playwright results → CSV test case deliverable |
19
19
  | `sungen-capture` | Acquire visual/design context — one skill, 4 modes: figma-mcp (Dev Mode MCP), figma-pat (URL → spec_figma.md), live (Playwright MCP scan), local (images in `requirements/ui/`) |
20
20
  | `sungen-locale` | Bootstrap i18n — audit selectors, detect locale switch mechanism, generate test-data overlay |
21
+ | `sungen-data-factory` | Standardized test-data — field-type/security catalog, 4-source method, `.overwrite`, blind-spot prompts |
21
22
 
22
- ## Workflow (7 AI commands)
23
+ ## Workflow (8 AI commands)
23
24
 
24
25
  | Command | What it does |
25
26
  |---|---|
26
27
  | `/sungen:add-screen <name> <path>` | Scaffold `qa/screens/<name>/` directories |
27
28
  | `/sungen:add-flow <name> [--path <url>]` | Scaffold `qa/flows/<name>/` directories for E2E cross-screen testing |
28
29
  | `/sungen:create-test <name>` | Generate `.feature` + `test-data.yaml` (auto-detects screen or flow) |
30
+ | `/sungen:create-data-test <name>` | Generate standardized test-data (valid/boundary/invalid + CHK trace) from the Data Factory catalog; no name = all units (asks to confirm) |
29
31
  | `/sungen:review <name>` | Score syntax, coverage, viewpoint quality (auto-detects screen or flow) |
30
32
  | `/sungen:run-test <name>` | Generate `selectors.yaml`, compile, run, auto-fix (auto-detects screen or flow) |
31
33
  | `/sungen:delivery [name...]` | Export test cases → CSV for QA delivery (all screens if no arg) |
@@ -18,14 +18,16 @@ You generate 3 files for sungen — a Gherkin compiler that produces Playwright
18
18
  | `sungen-delivery` | Export Gherkin + Playwright results → CSV test case deliverable |
19
19
  | `sungen-capture` | Acquire visual/design context — one skill, 4 modes: figma-mcp (Dev Mode MCP), figma-pat (URL → spec_figma.md), live (Playwright MCP scan), local (images in `requirements/ui/`) |
20
20
  | `sungen-locale` | Bootstrap i18n — audit selectors, detect locale switch mechanism, generate test-data overlay |
21
+ | `sungen-data-factory` | Standardized test-data — field-type/security catalog, 4-source method, `.overwrite`, blind-spot prompts |
21
22
 
22
- ## Workflow (7 AI commands)
23
+ ## Workflow (8 AI commands)
23
24
 
24
25
  | Command | What it does |
25
26
  |---|---|
26
27
  | `/sungen-add-screen <name> <path>` | Scaffold `qa/screens/<name>/` directories |
27
28
  | `/sungen-add-flow <name> [--path <url>]` | Scaffold `qa/flows/<name>/` directories for E2E cross-screen testing |
28
29
  | `/sungen-create-test <name>` | Generate `.feature` + `test-data.yaml` (auto-detects screen or flow) |
30
+ | `/sungen-create-data-test <name>` | Generate standardized test-data (valid/boundary/invalid + CHK trace) from the Data Factory catalog; no name = all units (asks to confirm) |
29
31
  | `/sungen-review <name>` | Score syntax, coverage, viewpoint quality (auto-detects screen or flow) |
30
32
  | `/sungen-run-test <name>` | Generate `selectors.yaml`, compile, run, auto-fix (auto-detects screen or flow) |
31
33
  | `/sungen-delivery [name...]` | Export test cases → CSV for QA delivery (all screens if no arg) |
@@ -0,0 +1,116 @@
1
+ ---
2
+ name: sungen-data-factory
3
+ description: 'Use when create-data-test (or create-test) needs standardized TEST DATA — valid/boundary/invalid values for input fields with CHK-* traceability. Drives the Data Factory catalog + the 4-source method. Invoke after reading spec.md, when authoring the field-map or filling test-data.'
4
+ user-invocable: false
5
+ ---
6
+
7
+ ## What this skill does
8
+
9
+ Turn a screen/flow's fields into **standardized test data** — not guessed values. You author a
10
+ **field-map**; the deterministic `sungen data gen` expands it from the Data Factory **catalog**
11
+ (field-type + security + technique library) into valid / boundary / invalid values, each carrying a
12
+ `CHK-*` id that traces to the spec. Your judgment goes into *reading the spec correctly* and
13
+ *answering blind spots* — never into inventing values the catalog or the QA should own.
14
+
15
+ Data Factory is **bundled with core** (runtime-free) — no `capability add` needed; the `sungen data …`
16
+ CLI is available out of the box.
17
+
18
+ ## The 4-source method (phuong-phap-tao-test-data.md)
19
+
20
+ Never invent values from memory. Cross-reference four sources — each covers the previous one's gap:
21
+
22
+ 1. **Spec validate rules** — required, format, min/max, business rules, and the **error/message code**
23
+ per rule. Defines the legal/illegal boundary. (Says the *law*, not every way to *break* it.)
24
+ 2. **Field-type catalog** — the accumulated "how this type breaks" knowledge (email/password/phone/
25
+ number/…). This is the Data Factory `common/` — it fills the "spec doesn't list every break" gap.
26
+ 3. **Design technique** — Boundary Value Analysis / Equivalence Partitioning / Decision Table / State
27
+ Transition — reduces the rule + candidates to a *minimal-but-sufficient* representative set.
28
+ 4. **DB mapping** — unique constraints, cross-entity dependency, real backend limits → precondition
29
+ data, not just a single input value.
30
+
31
+ Then classify every value into **Valid / Boundary / Invalid** (each invalid tagged with its error
32
+ code) and give it a `CHK-*` id for traceability.
33
+
34
+ ## The field-map — `qa/data-factory/<name>.fields.yaml`
35
+
36
+ Your main artifact. One entry per input field; the generator expands it:
37
+
38
+ ```yaml
39
+ screen: login # or flow: <name>
40
+ fields:
41
+ - name: email
42
+ type: email # a catalog field-type (see list below)
43
+ required: true
44
+ constraints: { maxLocal: 64, maxTotal: 254 } # the project's REAL limits from spec
45
+ errorMap: { M13: E1042, M02: E1001 } # catalog placeholder code → project's real code
46
+ - name: password
47
+ type: password
48
+ constraints: { minLength: 8, maxLength: 32 }
49
+ ```
50
+
51
+ **Catalog field-types** (P1): `email` · `password` · `phone` · `string` · `number-integer` ·
52
+ `number-float` · `currency` · `postcode` · `katakana` (JP). Security payload banks auto-append to a
53
+ field's invalid group via the type's `uses_security` (`sqli`, `xss`, `idor`, `broken-auth`, `upload`,
54
+ `input-validation`).
55
+
56
+ Rules:
57
+ - Pick the closest `type`; put the project's real numbers in `constraints` (they override the
58
+ catalog defaults).
59
+ - Map every `errorRef` placeholder (`M13`, `M39`, …) to the spec's real code via `errorMap`. Leave
60
+ one unmapped **only** if the spec has none — the lint flags it as an open point to confirm.
61
+ - **Complex forms:** a **group** field takes nested **`fields:`** (recursive; no `type` on the group → renders a nested object like `address.city`). A field whose rule depends on another takes **`dependsOn: { field, value }`** — recorded as a `_depends_on` note (the generator doesn't resolve the runtime condition; weave it into the scenario/`@cases`).
62
+ - Set **`unique: true`** on a field that must be fresh every run (register email/username, anything
63
+ that would clash with a record a previous run left behind). Its valid value then carries a runtime
64
+ `{{$timestamp}}` (email → `user+{{$timestamp}}@…`) so each run is unique — no cross-run cache
65
+ (which would make tests order-dependent/flaky). Prefer this over caching prior-run values. For
66
+ reusing a value produced earlier **within the same run** (register → then log in with it), bind it
67
+ via the scenario (`@dataFactory` recipe / `testData.bind`), not a cross-run cache.
68
+
69
+ ## No input fields → nothing to generate
70
+
71
+ Data Factory standardizes **field-level input data**. If a unit has no user-input fields or
72
+ parameters — a pure navigation, listing, or capture-compare flow — there is nothing to generate.
73
+ Report *"no input fields → nothing to generate"* and skip it; do **not** write an empty field-map.
74
+ Those scenarios are covered by the data create-test already produced, not by field-level test data.
75
+ (This is a correct outcome, not a gap — don't force a field-map to make the unit "processed".)
76
+
77
+ ## Blind spots — ask, never fabricate
78
+
79
+ If a field's type is **not** in the catalog — a business enum, a cross-entity constraint, a
80
+ project-specific data model — do **not** guess. Ask the QA (via `AskUserQuestion`) for: (1) the valid
81
+ set, (2) invalid / non-existent values, (3) the error code when wrong, (4) dependencies on other
82
+ fields. Record it in `qa/data-factory/project/<entity>.yaml` so it becomes reusable project catalog.
83
+ This is the core discipline: *common is never enough; when blind, think and ask — don't invent.*
84
+
85
+ ## Customizing the catalog — `.overwrite` (survives `sungen update`)
86
+
87
+ The shipped `common/` is a floor. Project rules go in `qa/data-factory/common.overwrite.yaml`,
88
+ deep-merged over the common (**later-wins**, keyed by `type` + data-point `id`): same `id` replaces,
89
+ new `id` appends, `constraints` merge key-by-key. `sungen update` refreshes `common/` but never
90
+ touches your overlay. If an update makes an overlay entry stale (references a bank/constraint that no
91
+ longer exists), the loader **warns you to prune it** — it never edits your file. Prefer a targeted
92
+ `errorMap`/`constraints` in the field-map for per-screen tweaks; use `.overwrite` only for rules that
93
+ apply project-wide.
94
+
95
+ ## Bulk-import fixtures (CSV)
96
+
97
+ For CSV/Excel import or bulk-upload testing, `sungen data fixture --screen <name> [--rows N] [--invalid]`
98
+ turns the field-map into a fixture FILE under `qa/fixtures/`: `<name>.csv` (N valid rows; nested groups
99
+ → dotted headers; `unique` fields row-indexed) that should import cleanly, and — with `--invalid` —
100
+ `<name>.invalid.csv` (one seeded-bad row per field + a `_violation` column) for row-level rejection
101
+ tests. Reference it from an `@api` upload (`files:`) or a UI file input.
102
+
103
+ ## Verify before done — the phuong-phap §6 checklist
104
+
105
+ Run `sungen data lint` and clear it: every required field has **≥1 valid**, **boundary present**
106
+ (exact min/max, not only over-boundary) for bounded types, **≥1 invalid per rule** (not one generic
107
+ "wrong" value for many rules), no `UNRESOLVED` values, error codes mapped or explicitly left open.
108
+ Then `sungen data gen` writes the standardized `test-data/<name>.yaml`. Do not hand-edit the
109
+ generated values — change the field-map or `.overwrite` and re-run (determinism: same input → same
110
+ data).
111
+
112
+ ## Weaving into scenarios
113
+
114
+ When a `.feature` exists, express invalid/boundary sets as data-driven `Scenario Outline` + `Examples`
115
+ (`@cases`) referencing the values — see `sungen-gherkin-syntax`. This keeps one logic + many values
116
+ instead of copy-pasted scenarios, and each row carries its `CHK-*` id for traceability.
@@ -6,6 +6,7 @@ user-invocable: false
6
6
 
7
7
  ## ⚠️ Gotchas — read before generating
8
8
 
9
+ - **Field-level test-data follows the Data Factory standard — don't hand-invent values.** When the unit has input fields, the field values (valid / boundary / invalid + error codes) come from the **`sungen-data-factory`** catalog via a field-map + `sungen data gen` (create-test step 5.3), not free-form guessing. Weave the standardized boundary/invalid sets into `@cases` with `CHK-*` trace. This skill still owns scenario structure, viewpoints, and non-field oracles.
9
10
  - **Write incrementally — never emit the whole suite in one response.** Build the `.feature` in batches via successive `Write`/`Edit` (≈10–15 scenarios per call). For **Full coverage**, write tier-by-tier: `Write` Tier 1 → `Edit` append Tier 2 → `Edit` append Tier 3.
10
11
  → One huge `Write` can exceed the model's output-token cap → `API Error: Claude's response exceeded the N output token maximum`. Single-pass full coverage only fits when `CLAUDE_CODE_MAX_OUTPUT_TOKENS ≥ 64000`; otherwise batch. Batching also lets the audit/reviewer run per batch — higher quality.
11
12
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sun-asterisk/sungen",
3
- "version": "3.2.11",
3
+ "version": "3.2.12-beta.2",
4
4
  "description": "Deterministic E2E Test Compiler - Gherkin + Selectors → Playwright tests",
5
5
  "main": "src/index.ts",
6
6
  "types": "src/index.ts",
@@ -39,7 +39,8 @@
39
39
  "@babel/types": "^7.28.5",
40
40
  "@cucumber/gherkin": "^37.0.0",
41
41
  "@cucumber/messages": "^31.0.0",
42
- "@sungen/driver-ui": "3.2.11",
42
+ "@sungen/driver-data-factory": "3.2.12-beta.2",
43
+ "@sungen/driver-ui": "3.2.12-beta.2",
43
44
  "chalk": "^5.6.2",
44
45
  "commander": "^14.0.2",
45
46
  "dotenv": "^17.2.3",
@@ -27,7 +27,7 @@ import { LOCAL_DRIVERS, registerCoreCapability } from './builtins';
27
27
  * move to their packages (R5.5/R5.6) they join this list and leave `LOCAL_DRIVERS`; eventually this
28
28
  * becomes a scan of installed `@sungen/driver-*` packages (R5.7).
29
29
  */
30
- const EXTERNAL_DRIVERS = ['@sungen/driver-ui', '@sungen/driver-db', '@sungen/driver-api', '@sungen/driver-mobile'];
30
+ const EXTERNAL_DRIVERS = ['@sungen/driver-ui', '@sungen/driver-db', '@sungen/driver-api', '@sungen/driver-mobile', '@sungen/driver-data-factory'];
31
31
 
32
32
  /**
33
33
  * Bundled (non-opt-in) drivers: shipped as a core dependency (`drivers.yaml` `bundled: true`), so the
@@ -36,7 +36,10 @@ const EXTERNAL_DRIVERS = ['@sungen/driver-ui', '@sungen/driver-db', '@sungen/dri
36
36
  * symlink for the package is missing). Surface it LOUDLY: otherwise the entire UI step vocabulary is
37
37
  * absent and every step silently compiles to "Unrecognized step pattern" with no clue why.
38
38
  */
39
- const BUNDLED_DRIVERS = new Set(['@sungen/driver-ui']);
39
+ // `@sungen/driver-data-factory` is bundled too — but it is RUNTIME-FREE (only a knowledge catalog +
40
+ // codegen), so shipping it by default adds no runtime, unlike ui/db/api/mobile. It makes standardized
41
+ // test-data available out of the box (no `capability add` needed); inert until a field-map/recipe exists.
42
+ const BUNDLED_DRIVERS = new Set(['@sungen/driver-ui', '@sungen/driver-data-factory']);
40
43
 
41
44
  function loadExternalDriver(name: string): void {
42
45
  // Resolve from the user's PROJECT first, then from core's own location. Opt-in drivers
@@ -15,6 +15,36 @@ function coreVersion(): string {
15
15
  try { return require('../../../package.json').version || 'latest'; } catch { return 'latest'; }
16
16
  }
17
17
 
18
+ /**
19
+ * Resolve the driver version to install for the running core `core`.
20
+ *
21
+ * Lockstep wants the EXACT `core` version. But the beta channel publishes `<core>-beta.N` before a
22
+ * stable `<core>` ever exists — so a released core (e.g. 3.2.10) asking for `@3.2.10` hits ETARGET
23
+ * out-of-the-box when npm only has `3.2.10-beta.2` (`sungen capability add` then fails for a fresh
24
+ * user). Fall back on the SAME version line: prefer exact `core`, else the highest `core-beta.N`,
25
+ * else the `beta` dist-tag as a last resort. Keeps the driver's pinned core-dep on the same line.
26
+ */
27
+ function resolveDriverVersion(pkg: string, core: string): string {
28
+ if (core === 'latest') return 'beta';
29
+ try {
30
+ const out = spawnSync('npm', ['view', pkg, 'versions', '--json'], { encoding: 'utf-8', shell: true });
31
+ if (out.status !== 0 || !out.stdout) return core; // can't query → let the exact install try/fail
32
+ let versions: string[] = [];
33
+ const parsed = JSON.parse(out.stdout);
34
+ versions = Array.isArray(parsed) ? parsed : [parsed];
35
+ if (versions.includes(core)) return core; // exact exists → lockstep
36
+ const prefix = `${core}-beta.`;
37
+ const betas = versions
38
+ .filter((v) => typeof v === 'string' && v.startsWith(prefix))
39
+ .map((v) => parseInt(v.slice(prefix.length), 10))
40
+ .filter((n) => Number.isInteger(n));
41
+ if (betas.length) return `${core}-beta.${Math.max(...betas)}`; // highest same-line prerelease
42
+ return 'beta'; // nothing on this line → newest beta dist-tag
43
+ } catch {
44
+ return core;
45
+ }
46
+ }
47
+
18
48
  /**
19
49
  * Add `test:mobile` to the project's package.json scripts (if absent).
20
50
  * Idempotent — skips if the script is already set.
@@ -187,14 +217,22 @@ export function registerCapabilityCommand(program: Command): void {
187
217
  }
188
218
 
189
219
  const adapterName = meta.adapter || meta.id;
190
- const bundled = adapterRegistry.hasAdapter(adapterName); // e.g. `web` is bundled in Phase 2a
220
+ // Bundled = a platform adapter baked into core (e.g. `web`), OR a capability driver shipped
221
+ // as a core dependency (`drivers.yaml` bundled: true, e.g. data-factory) — present already,
222
+ // so no install/verify: `capability add` on it just records it in the profile.
223
+ const bundled = adapterRegistry.hasAdapter(adapterName) || meta.bundled === true;
191
224
 
192
225
  if (!bundled && !o.skipInstall) {
193
226
  // Pin the driver to the RUNNING core's exact version (lockstep). Without this, plain
194
227
  // `npm install @sungen/driver-x` resolves the package's `latest` dist-tag — which on a
195
228
  // beta channel can lag (e.g. a prerelease first-published-as-latest), pulling a driver
196
229
  // whose core dep resolves to the wrong @sun-asterisk/sungen and fails to load.
197
- const spec = `${meta.package}@${coreVersion()}`;
230
+ const core = coreVersion();
231
+ const target = resolveDriverVersion(meta.package, core); // exact core, else same-line beta, else 'beta' tag
232
+ const spec = `${meta.package}@${target}`;
233
+ if (target !== core) {
234
+ console.log(`ℹ ${meta.package}@${core} is not published yet — installing ${spec} (closest on the ${core} line).`);
235
+ }
198
236
  console.log(`📦 Installing ${spec} (dev dependency)...`);
199
237
  const r = spawnSync('npm', ['install', '-D', spec], { stdio: 'inherit', shell: true });
200
238
  if (r.status !== 0) throw new Error(`npm install -D ${spec} failed.`);