@qa-gentic/stlc-agents 1.0.0

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 (36) hide show
  1. package/README.md +310 -0
  2. package/bin/postinstall.js +78 -0
  3. package/bin/qa-stlc.js +89 -0
  4. package/package.json +48 -0
  5. package/skills/qa-stlc/AGENT-BEHAVIOR.md +383 -0
  6. package/skills/qa-stlc/deduplication-protocol.md +303 -0
  7. package/skills/qa-stlc/generate-gherkin.md +550 -0
  8. package/skills/qa-stlc/generate-playwright-code.md +464 -0
  9. package/skills/qa-stlc/generate-test-cases.md +176 -0
  10. package/skills/qa-stlc/write-helix-files.md +374 -0
  11. package/src/boilerplate-bundle.js +66 -0
  12. package/src/cmd-init.js +92 -0
  13. package/src/cmd-mcp-config.js +177 -0
  14. package/src/cmd-scaffold.js +130 -0
  15. package/src/cmd-skills.js +124 -0
  16. package/src/cmd-verify.js +129 -0
  17. package/src/stlc_agents/__init__.py +0 -0
  18. package/src/stlc_agents/agent_gherkin_generator/__init__.py +0 -0
  19. package/src/stlc_agents/agent_gherkin_generator/server.py +502 -0
  20. package/src/stlc_agents/agent_gherkin_generator/tools/__init__.py +0 -0
  21. package/src/stlc_agents/agent_gherkin_generator/tools/ado_gherkin.py +854 -0
  22. package/src/stlc_agents/agent_helix_writer/__init__.py +0 -0
  23. package/src/stlc_agents/agent_helix_writer/server.py +529 -0
  24. package/src/stlc_agents/agent_helix_writer/tools/__init__.py +0 -0
  25. package/src/stlc_agents/agent_helix_writer/tools/boilerplate.py +70 -0
  26. package/src/stlc_agents/agent_helix_writer/tools/helix_write.py +796 -0
  27. package/src/stlc_agents/agent_playwright_generator/__init__.py +0 -0
  28. package/src/stlc_agents/agent_playwright_generator/server.py +2610 -0
  29. package/src/stlc_agents/agent_playwright_generator/tools/__init__.py +0 -0
  30. package/src/stlc_agents/agent_playwright_generator/tools/ado_attach.py +62 -0
  31. package/src/stlc_agents/agent_test_case_manager/__init__.py +0 -0
  32. package/src/stlc_agents/agent_test_case_manager/server.py +483 -0
  33. package/src/stlc_agents/agent_test_case_manager/tools/__init__.py +0 -0
  34. package/src/stlc_agents/agent_test_case_manager/tools/ado_workitem.py +302 -0
  35. package/src/stlc_agents/shared/__init__.py +0 -0
  36. package/src/stlc_agents/shared/auth.py +119 -0
@@ -0,0 +1,374 @@
1
+ ---
2
+ name: write-helix-files
3
+ description: >
4
+ Use this skill whenever generated Playwright TypeScript files (locators,
5
+ page objects, step definitions, feature files, healing infrastructure) need
6
+ to be placed into a local Helix-QA project on disk. Triggers after
7
+ generate-playwright-code or scaffold_locator_repository has produced a
8
+ 'files' dict. Always calls inspect_helix_project first to determine whether
9
+ the framework exists, then picks the correct write mode automatically.
10
+ compatibility:
11
+ tools:
12
+ - qa-helix-writer:inspect_helix_project
13
+ - qa-helix-writer:list_helix_tree
14
+ - qa-helix-writer:read_helix_file
15
+ - qa-helix-writer:write_helix_files
16
+ - qa-helix-writer:update_helix_file
17
+ - qa-playwright-generator:generate_playwright_code
18
+ - qa-playwright-generator:scaffold_locator_repository
19
+ - qa-playwright-generator:pre_validate_cucumber_steps
20
+ ---
21
+
22
+ # Write Helix Files Skill
23
+
24
+ ## 🚨 HARD STOP RULES — Read Before Anything Else
25
+
26
+ **HARD STOP 1 — NEVER use `create_file` as a fallback.**
27
+ `create_file` bypasses deduplication, interface-adaptation rewrites, and file routing.
28
+ If `write_helix_files` returns an error, diagnose and fix the payload — do NOT route
29
+ around the tool. If the error cannot be resolved, surface it to the user verbatim.
30
+
31
+ **HARD STOP 2 — NEVER create a new locator or step file when one already exists.**
32
+ Before writing, call `list_helix_tree` to check what files are already on disk.
33
+ If `src/locators/<foo>.locators.ts` already exists → it is the only correct target.
34
+ Do NOT create `src/locators/<foo>-bar.locators.ts` or any variant filename.
35
+ `write_helix_files` will merge new keys into the existing file automatically.
36
+
37
+ **HARD STOP 3 — Step definitions MUST use Cucumber expressions, not regex.**
38
+ `write_helix_files` runs a parenthesis-balance validator on every `*.steps.ts` file.
39
+ Regex step patterns (e.g. `/^I click "([^"]*)"$/`) contain un-paired parentheses and
40
+ will fail this check. Before submitting, verify every `When/Then/Given` block matches
41
+ the Cucumber expression format:
42
+
43
+ ```typescript
44
+ // ✅ Correct — Cucumber expression
45
+ When('the user enters {string} in the username field', async function (value: string) {
46
+ ```
47
+
48
+ ```typescript
49
+ // ❌ Rejected — regex pattern
50
+ When(/^the user enters "([^"]*)" in the username field$/, async function (value: string) {
51
+ ```
52
+
53
+ If `generate_playwright_code` produced regex patterns, use `pre_validate_cucumber_steps`
54
+ to identify them, then convert to Cucumber expressions before calling `write_helix_files`.
55
+
56
+ ---
57
+
58
+ Place files produced by `qa-playwright-generator` into a local Helix-QA
59
+ project. The skill handles two situations automatically:
60
+
61
+ | Situation | What happens |
62
+ |---|---|
63
+ | Framework does not exist yet | Scaffold infrastructure + write test files |
64
+ | Framework already exists | Merge only the new work item's test files; never touch infrastructure |
65
+
66
+ ---
67
+
68
+ ## Helix-QA Directory Layout
69
+
70
+ ```
71
+ <helix_root>/
72
+ ├── src/
73
+ │ ├── locators/ ← <kebab>.locators.ts (merged per file)
74
+ │ ├── pages/ ← <Page>.page.ts (merged per file)
75
+ │ ├── test/
76
+ │ │ ├── features/ ← <feature>.feature (overwritten)
77
+ │ │ └── steps/ ← <feature>.steps.ts (merged per file)
78
+ │ ├── utils/
79
+ │ │ └── locators/ ← LocatorHealer.ts etc. (protected)
80
+ │ └── config/
81
+ │ └── cucumber.config.ts ← profile blocks appended (deduplicated)
82
+ └── package.json
83
+ ```
84
+
85
+ ---
86
+
87
+ ## Decision Flow
88
+
89
+ ```
90
+ inspect_helix_project(helix_root)
91
+
92
+ ├─ framework_state: "absent" or "partial"
93
+ │ │
94
+ │ └─ scaffold_locator_repository(...)
95
+ │ │
96
+ │ └─ write_helix_files(..., mode="scaffold_and_tests")
97
+ │ Writes infra files that don't exist + test files
98
+
99
+ └─ framework_state: "present"
100
+
101
+ └─ write_helix_files(..., mode="tests_only")
102
+ Merges only locators / page / steps / feature
103
+ Infrastructure files are NEVER touched
104
+ ```
105
+
106
+ ---
107
+
108
+ ## Step-by-Step Workflow
109
+
110
+ ### Step 1 — Confirm helix_root
111
+
112
+ Ask the user for the absolute path to the Helix-QA project root if not provided.
113
+ This is the directory containing `package.json` and `src/`.
114
+
115
+ ---
116
+
117
+ ### Step 2 — Inspect framework state
118
+
119
+ ```
120
+ qa-helix-writer:inspect_helix_project(helix_root)
121
+ ```
122
+
123
+ Read the response:
124
+
125
+ ```json
126
+ {
127
+ "framework_state": "present",
128
+ "existing_infra": ["LocatorHealer.ts", "LocatorRepository.ts", ...],
129
+ "missing_infra": [],
130
+ "recommendation": "tests_only",
131
+ "message": "Helix-QA framework is present. ..."
132
+ }
133
+ ```
134
+
135
+ **Act on `recommendation` directly — do not ask the user to choose the mode.**
136
+
137
+ ---
138
+
139
+ ### Step 3A — Framework absent or partial → scaffold first
140
+
141
+ Only when `recommendation` is `"scaffold_and_tests"`:
142
+
143
+ ```
144
+ # Generate infrastructure
145
+ qa-playwright-generator:scaffold_locator_repository(
146
+ output_dir = "src/utils/locators",
147
+ enable_ai_vision = true,
148
+ repository_path = "test-results/locator-repository.json",
149
+ dashboard_port = 7890,
150
+ enable_timing_healing = true,
151
+ enable_visual_regression = true,
152
+ enable_devtools_healer = true
153
+ )
154
+ ```
155
+
156
+ Then proceed to Step 4 with `mode="scaffold_and_tests"`.
157
+
158
+ ---
159
+
160
+ ### Step 3B — Framework present → skip scaffold
161
+
162
+ When `recommendation` is `"tests_only"`, skip Step 3A entirely.
163
+ Proceed to Step 4 with `mode="tests_only"`.
164
+
165
+ ---
166
+
167
+ ### Step 4 — Read existing feature file before generating
168
+
169
+ **MANDATORY before calling `generate_playwright_code`.**
170
+
171
+ If a `.feature` file already exists on disk for this work item, read it first:
172
+
173
+ ```
174
+ qa-helix-writer:read_helix_file(
175
+ helix_root = "<helix_root>",
176
+ relative_path = "src/test/features/<feature>.feature"
177
+ )
178
+ ```
179
+
180
+ If `exists: true`, extract the following from the response and pass as generation context:
181
+
182
+ 1. **Existing scenario titles** — the generator MUST use these verbatim for any scenario it generates that covers the same test intent. Never produce a title that differs only by a word ("all 6" vs "all available") — that creates a phantom duplicate.
183
+ 2. **Existing step phrasings** — for steps the generator would otherwise write in a slightly different form (e.g. `the user logs in with "X" and "Y"` vs `the user logs in with username "X" and password "Y"`), use the existing phrasing exactly. Semantic equivalence is not enough; step text must match character-for-character for deduplication to work.
184
+ 3. **Scenarios to skip** — if the generator would produce a scenario whose steps are semantically equivalent to an existing one (same action, same data, same assertions — just different wording), omit it entirely from the generated output. Do not generate it at all; the helix writer cannot perform semantic reasoning.
185
+
186
+ If `exists: false`, skip this step — the file will be created fresh.
187
+
188
+ ---
189
+
190
+ ### Step 5 — Generate test files
191
+
192
+ Run `generate_playwright_code` for the work item's Gherkin feature:
193
+
194
+ ```
195
+ qa-playwright-generator:generate_playwright_code(
196
+ gherkin_content = <validated .feature file content>,
197
+ page_class_name = "<PageClass>",
198
+ app_name = "<app>",
199
+ healing_strategy = "role-label-text-ai",
200
+ enable_visual_regression = true,
201
+ enable_timing_healing = true
202
+ )
203
+ ```
204
+
205
+ ---
206
+
207
+ ### Step 6 — Write files
208
+
209
+ ```
210
+ qa-helix-writer:write_helix_files(
211
+ helix_root = "<helix_root>",
212
+ files = <files dict from generate_playwright_code>,
213
+ mode = "<recommendation from Step 2>"
214
+ )
215
+ ```
216
+
217
+ The tool handles everything automatically:
218
+
219
+ **File routing:**
220
+
221
+ | Generator key | Helix destination |
222
+ |---|---|
223
+ | `src/pages/<k>/locators.ts` | `src/locators/<k>.locators.ts` |
224
+ | `src/pages/<k>/<k>.page.ts` | `src/pages/<k>.page.ts` |
225
+ | `src/test/steps/<k>.steps.ts` | `src/test/steps/<k>.steps.ts` |
226
+ | `*.feature` | `src/test/features/<k>.feature` |
227
+ | `config/cucumber.js (add this profile)` | `src/config/cucumber.config.ts` (appended) |
228
+ | `src/utils/locators/Locator*.ts` | `src/utils/locators/<file>` |
229
+
230
+ **Deduplication per file type:**
231
+
232
+ | File | Behaviour when file already exists |
233
+ |---|---|
234
+ | `locators.ts` | New const-object keys appended; existing keys skipped |
235
+ | `*.steps.ts` | New step blocks appended; steps with matching regex skipped |
236
+ | `*.page.ts` | New async methods appended; existing method names skipped |
237
+ | `*.feature` | New scenario blocks appended; scenarios with matching titles skipped (existing step wording preserved) |
238
+ | `cucumber.config.ts` | Profile block appended; duplicate profile names skipped |
239
+ | Infrastructure `*.ts` | Protected in `tests_only`; written-if-absent in `scaffold_and_tests` |
240
+
241
+ **Interface adaptation (applied automatically):**
242
+
243
+ | Generated code | Rewritten to |
244
+ |---|---|
245
+ | `repo.updateHealed(k, s, …)` | `repo.setHealed(k, s)` |
246
+ | `repo.getBBox(key)` | `null` |
247
+ | `repo.incrementSuccess/Failure(…)` | removed |
248
+ | `repo.queueSuggestion(…)` | removed |
249
+ | `repo.updateBoundingBox(…)` | removed |
250
+ | `fixture().logger` | `this.logger` |
251
+ | `fixture().locatorRepository` | `this.repo` |
252
+ | `fixture().page` | `this.page` |
253
+ | `import { Logger } from "winston"` | `import { HealerLogger }` |
254
+ | `EnvironmentManager` | Helix `environment` singleton |
255
+
256
+ ---
257
+
258
+ ### Step 7 — Verify the response
259
+
260
+ ```json
261
+ {
262
+ "summary": { "requested": 4, "written": 4, "skipped": 0 },
263
+ "deduplication": {
264
+ "src/locators/checkout.locators.ts": {
265
+ "type": "locators",
266
+ "added_keys": ["checkoutBtn", "summaryTotal"],
267
+ "skipped_keys": ["submitBtn", "cancelBtn"]
268
+ },
269
+ "src/test/steps/checkout.steps.ts": {
270
+ "type": "steps",
271
+ "added_patterns": ["user completes checkout"],
272
+ "skipped_patterns": ["user logs in"]
273
+ }
274
+ }
275
+ }
276
+ ```
277
+
278
+ Report the `deduplication` summary to the user so they can confirm which
279
+ symbols were added vs skipped.
280
+
281
+ **Skipped reasons to handle:**
282
+
283
+ | Reason | Action |
284
+ |---|---|
285
+ | `"empty content"` | Normal — generator produced no content for that file |
286
+ | `"profile '…' already exists"` | Normal — no action needed |
287
+ | `"infrastructure file already exists"` | Normal in `tests_only` mode |
288
+ | `"infrastructure file — skipped in tests_only mode"` | Normal |
289
+ | Any `OSError` | Report path and error to user |
290
+
291
+ ---
292
+
293
+ ## Scaffold vs Regenerate Infrastructure
294
+
295
+ **First-time setup** (`framework_state` is `"absent"` or `"partial"`):
296
+
297
+ ```
298
+ scaffold_locator_repository(...) # generate 6 infra files
299
+ write_helix_files(..., mode="scaffold_and_tests")
300
+ # Writes missing infra files + test files
301
+ ```
302
+
303
+ **Intentional infrastructure regeneration** (user explicitly requests it):
304
+
305
+ ```
306
+ write_helix_files(..., mode="scaffold_and_tests", force_scaffold=true)
307
+ # Overwrites ALL infra files — use deliberately
308
+ ```
309
+
310
+ **Never** call with `force_scaffold=true` unless the user has explicitly asked
311
+ to regenerate the healing infrastructure.
312
+
313
+ ---
314
+
315
+ ## Quality Gates
316
+
317
+ Before calling `write_helix_files`:
318
+
319
+ - [ ] `inspect_helix_project` has been called and `recommendation` noted.
320
+ - [ ] `list_helix_tree` has been called — existing file names recorded to prevent new-file creation.
321
+ - [ ] **Existing `*.feature` file read** (`read_helix_file`) and its scenario titles + step phrasings were passed to the generator as context (Step 4 above). If this was skipped, STOP — regenerate with the existing file as context before writing.
322
+ - [ ] **`pre_validate_cucumber_steps` called with `existing_steps_ts_contents`** — read every existing `*.steps.ts` in `src/test/steps/` via `read_helix_file` and pass as the `existing_steps_ts_contents` map. This enables check 6 (cross-file duplicate detection). Skipping this is the most common source of redundant step definitions across files.
323
+ - [ ] `pre_validate_cucumber_steps` returned `valid: true` and `errors` is empty.
324
+ - [ ] Every `*.steps.ts` in the `files` dict uses Cucumber expression syntax (not regex).
325
+ - [ ] `mode` matches `recommendation` — never override without user instruction.
326
+ - [ ] `force_scaffold` is `false` unless the user explicitly asked to regenerate.
327
+ - [ ] The `files` dict comes directly from `generate_playwright_code` or
328
+ `scaffold_locator_repository` — never manually constructed.
329
+ - [ ] After writing, the `deduplication` field has been reviewed and reported.
330
+
331
+ ---
332
+
333
+ ## Failure Recovery Procedure
334
+
335
+ When `write_helix_files` returns an error:
336
+
337
+ ### 1 — Parenthesis / bracket balance error in a steps file
338
+
339
+ **Symptom:** Tool returns a message about parenthesis balance, bracket imbalance,
340
+ or validator failure on a `*.steps.ts` file.
341
+
342
+ **Root cause:** The step definitions contain regex patterns. Regex uses un-paired
343
+ parentheses (`(`, `)`) that the file validator counts as unbalanced.
344
+
345
+ **Fix:**
346
+ 1. Call `pre_validate_cucumber_steps` on the failing steps file content — it identifies
347
+ every offending pattern and provides a ready-to-paste Cucumber expression replacement.
348
+ 2. Convert any regex patterns to Cucumber expressions:
349
+ - `"([^"]*)"` → `{string}`
350
+ - `(\d+)` → `{int}`
351
+ - `/^…$/` wrapper → plain quoted string
352
+ 3. Retry `write_helix_files` with the corrected `files` dict.
353
+ 4. Do NOT call `create_file` at any point.
354
+
355
+ ### 2 — `OSError` / path error
356
+
357
+ **Symptom:** Tool returns an `OSError`, `FileNotFoundError`, or similar path message.
358
+
359
+ **Fix:** Report the exact path and error to the user. Do not attempt to create the
360
+ directory or file manually unless the user explicitly instructs it.
361
+
362
+ ### 3 — Any other tool error
363
+
364
+ **Fix:** Report the raw error text to the user verbatim. Ask: "How would you like
365
+ to proceed?" Do not attempt any workaround autonomously.
366
+
367
+ ---
368
+
369
+ ## Known Tool Limitations (Document These for Future Agent Runs)
370
+
371
+ | Limitation | Description | Workaround |
372
+ |---|---|---|
373
+ | Parenthesis validator | Rejects step files with regex step patterns; error message names regex preprocessor as cause and prescribes Cucumber expressions | Use `pre_validate_cucumber_steps` before submitting to catch and fix offending patterns |
374
+ | `update_helix_file` for single-file edits | Use `qa-helix-writer:update_helix_file` for targeted single-file changes instead of re-submitting the full `files` dict | Pass `relative_path` and the new content directly; set `force_overwrite=true` only when replacing existing content |