tewip-ai 0.70.12 → 0.70.13
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/QUICKSTART.md +178 -178
- package/dist/engine/autofix/code-propose.js +8 -8
- package/dist/engine/build/build.js +22 -22
- package/dist/engine/llm/prompt.js +22 -22
- package/package.json +1 -1
package/QUICKSTART.md
CHANGED
|
@@ -1,179 +1,179 @@
|
|
|
1
|
-
# Quickstart: putting Tewip on one repository
|
|
2
|
-
|
|
3
|
-
For an engineer adding the agent to a project that already runs Playwright tests in GitHub Actions. It takes about ten minutes, and the first useful output arrives with the next failing run.
|
|
4
|
-
|
|
5
|
-
Start with **one** repository whose tests fail sometimes. A repository whose suite is always green has nothing to triage.
|
|
6
|
-
|
|
7
|
-
## What the agent does once it is installed
|
|
8
|
-
|
|
9
|
-
Every CI run, for every failed test, it decides the root cause — application bug, changed selector, race, environment, or test data — with a confidence, the evidence it used, and one concrete next action. It then delivers that to the people who need it: a comment on the pull request, the board in the job summary, one grouped issue for environment failures, and optionally a separate pull request with locator fixes that it re-ran and verified.
|
|
10
|
-
|
|
11
|
-
It never merges anything, never edits application code, and never opens a fix pull request for a change it has not proved by re-running the test.
|
|
12
|
-
|
|
13
|
-
## Step 1: make Playwright leave the evidence behind
|
|
14
|
-
|
|
15
|
-
The agent reads Playwright's own blob report and traces, so nothing from this project goes into your test config:
|
|
16
|
-
|
|
17
|
-
```ts
|
|
18
|
-
// playwright.config.ts
|
|
19
|
-
reporter: process.env.CI ? [['list'], ['blob']] : 'list',
|
|
20
|
-
use: { trace: 'retain-on-failure' },
|
|
21
|
-
```
|
|
22
|
-
|
|
23
|
-
If your config already uses a reporter list in CI, add `['blob']` to it.
|
|
24
|
-
|
|
25
|
-
## Step 2: add one step to the workflow that runs the tests
|
|
26
|
-
|
|
27
|
-
```yaml
|
|
28
|
-
permissions:
|
|
29
|
-
pull-requests: write # the diagnosis comment
|
|
1
|
+
# Quickstart: putting Tewip on one repository
|
|
2
|
+
|
|
3
|
+
For an engineer adding the agent to a project that already runs Playwright tests in GitHub Actions. It takes about ten minutes, and the first useful output arrives with the next failing run.
|
|
4
|
+
|
|
5
|
+
Start with **one** repository whose tests fail sometimes. A repository whose suite is always green has nothing to triage.
|
|
6
|
+
|
|
7
|
+
## What the agent does once it is installed
|
|
8
|
+
|
|
9
|
+
Every CI run, for every failed test, it decides the root cause — application bug, changed selector, race, environment, or test data — with a confidence, the evidence it used, and one concrete next action. It then delivers that to the people who need it: a comment on the pull request, the board in the job summary, one grouped issue for environment failures, and optionally a separate pull request with locator fixes that it re-ran and verified.
|
|
10
|
+
|
|
11
|
+
It never merges anything, never edits application code, and never opens a fix pull request for a change it has not proved by re-running the test.
|
|
12
|
+
|
|
13
|
+
## Step 1: make Playwright leave the evidence behind
|
|
14
|
+
|
|
15
|
+
The agent reads Playwright's own blob report and traces, so nothing from this project goes into your test config:
|
|
16
|
+
|
|
17
|
+
```ts
|
|
18
|
+
// playwright.config.ts
|
|
19
|
+
reporter: process.env.CI ? [['list'], ['blob']] : 'list',
|
|
20
|
+
use: { trace: 'retain-on-failure' },
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
If your config already uses a reporter list in CI, add `['blob']` to it.
|
|
24
|
+
|
|
25
|
+
## Step 2: add one step to the workflow that runs the tests
|
|
26
|
+
|
|
27
|
+
```yaml
|
|
28
|
+
permissions:
|
|
29
|
+
pull-requests: write # the diagnosis comment
|
|
30
30
|
issues: write
|
|
31
|
-
actions: read # so it can read a failed job's log when no report was written # the grouped environment issue
|
|
32
|
-
contents: write # only if you turn autofix on
|
|
33
|
-
|
|
34
|
-
steps:
|
|
35
|
-
# ... your existing checkout, install, and `npx playwright test` steps ...
|
|
36
|
-
|
|
37
|
-
- name: Tewip
|
|
38
|
-
if: always() # it must run even though the test step failed
|
|
39
|
-
uses: hmamut39/tewip@main
|
|
40
|
-
with:
|
|
41
|
-
openai-api-key: ${{ secrets.OPENAI_API_KEY }} # optional, see step 3
|
|
42
|
-
autofix: 'false' # start with this off
|
|
43
|
-
```
|
|
44
|
-
|
|
45
|
-
`if: always()` matters: without it the step is skipped exactly when there is something to triage.
|
|
46
|
-
|
|
47
|
-
Keep `autofix: 'false'` for the first week. Read what the agent says, decide whether you trust it, and turn fixing on afterwards.
|
|
48
|
-
|
|
49
|
-
## Step 3: decide whether to give it an API key
|
|
50
|
-
|
|
51
|
-
| Without a key | With `OPENAI_API_KEY` |
|
|
52
|
-
|---|---|
|
|
53
|
-
| Only the deterministic rules run | The rules run first, and only what they cannot settle goes to the model |
|
|
54
|
-
| Every answer is explainable from the error, the trace and the test's history | Adds a judgement on the rest, with its reasoning and evidence shown |
|
|
55
|
-
| Free | A few cents per run in practice, because the rules answer most failures |
|
|
56
|
-
|
|
57
|
-
On real projects the rules alone decide most failures and are right on 96–98% of what they decide, so starting without a key is a reasonable first week. To add one later: repository **Settings → Secrets and variables → Actions → New repository secret**, named `OPENAI_API_KEY`.
|
|
58
|
-
|
|
59
|
-
Every run prints what it cost, priced from OpenAI's published prices. One guard worth setting once the key is in place:
|
|
60
|
-
|
|
61
|
-
```yaml
|
|
62
|
-
env:
|
|
63
|
-
TRIAGE_LLM_MAX_CALLS: '80' # hard cap on model calls per run
|
|
64
|
-
# TRIAGE_LLM_PRICE_IN / _OUT: only if your price differs (per million tokens)
|
|
65
|
-
```
|
|
66
|
-
|
|
67
|
-
## Not using Playwright? Every stack works
|
|
68
|
-
|
|
69
|
-
Point the agent at your test runner's **JUnit XML** report (or .NET's **TRX**) instead of a Playwright blob report. Each runner marked *verified* was run for real in CI (`fixtures/polyglot`) and its report is checked by the test suite on every change.
|
|
70
|
-
|
|
71
|
-
| Stack | Runner | How to write the report | Status |
|
|
72
|
-
|---|---|---|---|
|
|
73
|
-
| **Node.js** | node:test (built in) | `node --test --test-reporter=junit --test-reporter-destination=report.xml` | verified |
|
|
74
|
-
| Node.js, React, Vue, Angular, Next.js, NestJS, Express | Jest | `jest --reporters=default --reporters=jest-junit` | verified |
|
|
75
|
-
| Vite, Vue, Svelte, Nuxt, React | Vitest | `vitest run --reporter=junit --outputFile=report.xml` | verified |
|
|
76
|
-
| Node.js, Express | Mocha | `mocha --reporter mocha-junit-reporter` | verified |
|
|
77
|
-
| **Python**, Django, Flask, FastAPI | pytest (also runs `unittest`) | `pytest --junitxml=report.xml` (retries: `pytest-rerunfailures`) | verified |
|
|
78
|
-
| **Java**, Spring, Kotlin | JUnit 4/5, TestNG via Maven Surefire | written by default to `target/surefire-reports/` (retries: `rerunFailingTestsCount`) | verified |
|
|
79
|
-
| Java, Kotlin, Android | Gradle | written by default to `build/test-results/test/` | same format as Surefire |
|
|
80
|
-
| **Go** | gotestsum | `gotestsum --junitfile report.xml` | verified |
|
|
81
|
-
| **.NET** (C#, F#), ASP.NET | xUnit, NUnit, MSTest | `dotnet test --logger trx` (native) or `--logger junit` | both verified |
|
|
82
|
-
| **Ruby**, Rails | RSpec | `rspec --format RspecJunitFormatter --out report.xml` | verified |
|
|
83
|
-
| **PHP**, Laravel, Symfony | PHPUnit | `phpunit --log-junit report.xml` | verified |
|
|
84
|
-
| **Rust** | cargo-nextest | `[profile.ci.junit]` in `.config/nextest.toml` | verified |
|
|
85
|
-
| End-to-end | **Selenium** (Java, Python, JavaScript, C#) | through the runner above it: Surefire, pytest, Jest/Mocha, `dotnet test` | JUnit format; error wording read |
|
|
86
|
-
| End-to-end | Cypress, WebdriverIO | `mocha-junit-reporter` / `@wdio/junit-reporter` | JUnit format; error wording read |
|
|
87
|
-
| End-to-end | **Playwright** | blob reporter (step 1) — adds traces, selector drift and verified fixes | verified on 5 real projects |
|
|
88
|
-
|
|
89
|
-
```yaml
|
|
90
|
-
- name: Tewip
|
|
91
|
-
if: always()
|
|
92
|
-
uses: hmamut39/tewip@main
|
|
93
|
-
with:
|
|
94
|
-
junit-report: report.xml # a file, or a directory of them (.xml and .trx)
|
|
95
|
-
suite: unit # only needed when one workflow triages several suites
|
|
96
|
-
```
|
|
97
|
-
|
|
98
|
-
What it reads from any of these: the failure text, retries, and each test's history. From that it tells apart a wrong value (a real bug once the test has a passing history), an unreachable service (environment), a data collision, and a test that failed then passed on a retry (timing), in the wording each language uses: `expected: <4> but was: <3>` in Java, `got 3, want 4` in Go, `AssertionError: 3 != 4` in Python, `Expected: 4 / Actual: 3` in .NET, and so on. It also reads each browser tool's own words for the same three problems: an element that was never found (Selenium's `NoSuchElementException`, WebdriverIO's `still not displayed`, Cypress's `Expected to find element`), a click another element received (Selenium's `Other element would receive the click`, Cypress's `is being covered by another element`), and an element the page replaced mid-test (Selenium's `StaleElementReferenceException`, Cypress's `the page updated while this command was executing`). No labelled Selenium or Cypress runs have measured those rules yet, so they report at a confidence the merge gate does not trust on its own. What it cannot do without Playwright's traces is look at the page, so selector drift and automatic fixes stay Playwright-only.
|
|
99
|
-
|
|
100
|
-
A wrong value on a test's **first** recorded failure stays undecided rather than guessed: one failure alone does not show whether the test was reliable before. It becomes a real-bug diagnosis once the test's history shows it passing and then failing the same way.
|
|
101
|
-
|
|
102
|
-
When one workflow triages several suites (say `unit` and `e2e`), give each a `suite` name: each then keeps its own history and its own comment, and corrections name the suite, as in `/triage TIMING unit#2 flaky on CI`.
|
|
103
|
-
|
|
104
|
-
## On your own machine, without CI
|
|
105
|
-
|
|
106
|
-
Install the command once from the release file, `npm install -g tewip-<version>.tgz` (Tewip is not on the npm registry yet; Node 22.18 or newer), run your tests with the report switched on (see the table above), then:
|
|
107
|
-
|
|
108
|
-
```bash
|
|
109
|
-
tewip explain report.xml # JUnit XML or .trx
|
|
110
|
-
tewip explain reports/ # a folder of them
|
|
111
|
-
tewip explain blob-report/ # Playwright
|
|
112
|
-
tewip ci owner/repo --pr 12 # what Tewip's GitHub Action said about a pull request
|
|
113
|
-
```
|
|
114
|
-
|
|
115
|
-
It prints the same triage board CI writes: each failure's cause, confidence, evidence and next action. Each run is kept in a `.tewip/` folder in your project (add it to `.gitignore`), so from the second run on, failures are judged against their history exactly as in CI. `--name` keeps separate histories for different projects.
|
|
116
|
-
|
|
117
|
-
## What you will see on the next failing run
|
|
118
|
-
|
|
119
|
-
- **On the pull request:** one comment listing each failing test, grouped by whether your change likely caused it, each with a cause, a confidence, the evidence and the next action. It updates in place rather than adding a comment per run.
|
|
120
|
-
- **In the job summary:** the same failures as a triage board.
|
|
121
|
-
- **As an issue:** environment failures (5xx responses, connection resets, outages) grouped into one issue instead of one per test.
|
|
122
|
-
- **As an artifact** named `tewip-report`: every role's view, including the engineering-quality view with the flaky tests ranked by the CI minutes they cost.
|
|
123
|
-
|
|
124
|
-
## Correcting it
|
|
125
|
-
|
|
126
|
-
When it gets one wrong, reply to its comment:
|
|
127
|
-
|
|
128
|
-
```
|
|
129
|
-
/triage TIMING #2 this one is flaky on our CI runners, not a bug
|
|
130
|
-
```
|
|
131
|
-
|
|
132
|
-
From the next run on, that failure of that test gets your answer, shown as "corrected by a person" with your name and reason. A correction settles the cause; it never makes the agent change code.
|
|
133
|
-
|
|
134
|
-
## Asking it questions from your editor
|
|
135
|
-
|
|
136
|
-
- **VS Code, Cursor, Windsurf, VSCodium:** install the Tewip extension (*Extensions → … → Install from VSIX*, `tewip-<version>.vsix`). It connects Tewip to the editor's AI assistant by itself and adds *Tewip: Explain a test report…* and *Tewip: Why did CI fail on this branch?*
|
|
137
|
-
- **JetBrains (2025.2+), Claude, and other MCP clients:** add one server whose command is `tewip mcp`.
|
|
138
|
-
|
|
139
|
-
Then ask, in plain language: "why did CI fail on my PR?", "which tests are flaky in checkout?", "is main safe to release?". Every tool is read-only, and it reads the report the Action already uploaded, so you do not need the other repository cloned.
|
|
140
|
-
|
|
141
|
-
## Stop flaky tests from blocking merges (optional)
|
|
142
|
-
|
|
143
|
-
Once you trust its answers, let the agent decide whether a failed run should block:
|
|
144
|
-
|
|
145
|
-
```yaml
|
|
146
|
-
- name: Tests
|
|
147
|
-
continue-on-error: true # the gate below decides
|
|
148
|
-
run: npx playwright test
|
|
149
|
-
- name: Tewip
|
|
150
|
-
if: always()
|
|
151
|
-
uses: hmamut39/tewip@main
|
|
152
|
-
with:
|
|
153
|
-
gate: real-failures
|
|
154
|
-
```
|
|
155
|
-
|
|
156
|
-
The build then fails only for real bugs, changed selectors, test-data problems and anything undecided. Failures a rule or a person classified as flaky or environment no longer block. On 2,296 real failures this unblocked 84% of the flaky and environment ones without letting a real bug through.
|
|
157
|
-
|
|
158
|
-
## Turning fixing on, once you trust it
|
|
159
|
-
|
|
160
|
-
```yaml
|
|
161
|
-
autofix: 'true'
|
|
162
|
-
```
|
|
163
|
-
|
|
164
|
-
It then rewrites a drifted locator, re-runs that single test, and opens a **separate** pull request only with the changes that passed. Review it like any other pull request: an intended UI change and a regression can look identical from the outside, which is exactly why a human merges it.
|
|
165
|
-
|
|
166
|
-
On real WordPress CI data it would have fixed 14 drifted locators with none wrong, and every locator it suggested matched what the developers themselves wrote.
|
|
167
|
-
|
|
168
|
-
## If something does not appear
|
|
169
|
-
|
|
170
|
-
| Symptom | Cause |
|
|
171
|
-
|---|---|
|
|
172
|
-
| The step ran but says "no blob report" | The blob reporter is not on in CI, or the tests step did not run |
|
|
173
|
-
| No comment on the pull request | The run was not triggered by a pull request, or `pull-requests: write` is missing |
|
|
174
|
-
| "Resource not accessible by integration" | The workflow's permissions block is missing an entry |
|
|
175
|
-
| Diagnoses look thin on the first day | The agent judges each failure against that test's history, which it builds from your runs; it gets better as runs accumulate |
|
|
176
|
-
|
|
177
|
-
## What it costs, and what it keeps
|
|
178
|
-
|
|
179
|
-
The agent stores the run history in the Actions cache, never in your repository. Collected failure data and traces stay in CI. The only thing it writes to your repository is a pull request branch, and only when you turn fixing on.
|
|
31
|
+
actions: read # so it can read a failed job's log when no report was written # the grouped environment issue
|
|
32
|
+
contents: write # only if you turn autofix on
|
|
33
|
+
|
|
34
|
+
steps:
|
|
35
|
+
# ... your existing checkout, install, and `npx playwright test` steps ...
|
|
36
|
+
|
|
37
|
+
- name: Tewip
|
|
38
|
+
if: always() # it must run even though the test step failed
|
|
39
|
+
uses: hmamut39/tewip@main
|
|
40
|
+
with:
|
|
41
|
+
openai-api-key: ${{ secrets.OPENAI_API_KEY }} # optional, see step 3
|
|
42
|
+
autofix: 'false' # start with this off
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
`if: always()` matters: without it the step is skipped exactly when there is something to triage.
|
|
46
|
+
|
|
47
|
+
Keep `autofix: 'false'` for the first week. Read what the agent says, decide whether you trust it, and turn fixing on afterwards.
|
|
48
|
+
|
|
49
|
+
## Step 3: decide whether to give it an API key
|
|
50
|
+
|
|
51
|
+
| Without a key | With `OPENAI_API_KEY` |
|
|
52
|
+
|---|---|
|
|
53
|
+
| Only the deterministic rules run | The rules run first, and only what they cannot settle goes to the model |
|
|
54
|
+
| Every answer is explainable from the error, the trace and the test's history | Adds a judgement on the rest, with its reasoning and evidence shown |
|
|
55
|
+
| Free | A few cents per run in practice, because the rules answer most failures |
|
|
56
|
+
|
|
57
|
+
On real projects the rules alone decide most failures and are right on 96–98% of what they decide, so starting without a key is a reasonable first week. To add one later: repository **Settings → Secrets and variables → Actions → New repository secret**, named `OPENAI_API_KEY`.
|
|
58
|
+
|
|
59
|
+
Every run prints what it cost, priced from OpenAI's published prices. One guard worth setting once the key is in place:
|
|
60
|
+
|
|
61
|
+
```yaml
|
|
62
|
+
env:
|
|
63
|
+
TRIAGE_LLM_MAX_CALLS: '80' # hard cap on model calls per run
|
|
64
|
+
# TRIAGE_LLM_PRICE_IN / _OUT: only if your price differs (per million tokens)
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
## Not using Playwright? Every stack works
|
|
68
|
+
|
|
69
|
+
Point the agent at your test runner's **JUnit XML** report (or .NET's **TRX**) instead of a Playwright blob report. Each runner marked *verified* was run for real in CI (`fixtures/polyglot`) and its report is checked by the test suite on every change.
|
|
70
|
+
|
|
71
|
+
| Stack | Runner | How to write the report | Status |
|
|
72
|
+
|---|---|---|---|
|
|
73
|
+
| **Node.js** | node:test (built in) | `node --test --test-reporter=junit --test-reporter-destination=report.xml` | verified |
|
|
74
|
+
| Node.js, React, Vue, Angular, Next.js, NestJS, Express | Jest | `jest --reporters=default --reporters=jest-junit` | verified |
|
|
75
|
+
| Vite, Vue, Svelte, Nuxt, React | Vitest | `vitest run --reporter=junit --outputFile=report.xml` | verified |
|
|
76
|
+
| Node.js, Express | Mocha | `mocha --reporter mocha-junit-reporter` | verified |
|
|
77
|
+
| **Python**, Django, Flask, FastAPI | pytest (also runs `unittest`) | `pytest --junitxml=report.xml` (retries: `pytest-rerunfailures`) | verified |
|
|
78
|
+
| **Java**, Spring, Kotlin | JUnit 4/5, TestNG via Maven Surefire | written by default to `target/surefire-reports/` (retries: `rerunFailingTestsCount`) | verified |
|
|
79
|
+
| Java, Kotlin, Android | Gradle | written by default to `build/test-results/test/` | same format as Surefire |
|
|
80
|
+
| **Go** | gotestsum | `gotestsum --junitfile report.xml` | verified |
|
|
81
|
+
| **.NET** (C#, F#), ASP.NET | xUnit, NUnit, MSTest | `dotnet test --logger trx` (native) or `--logger junit` | both verified |
|
|
82
|
+
| **Ruby**, Rails | RSpec | `rspec --format RspecJunitFormatter --out report.xml` | verified |
|
|
83
|
+
| **PHP**, Laravel, Symfony | PHPUnit | `phpunit --log-junit report.xml` | verified |
|
|
84
|
+
| **Rust** | cargo-nextest | `[profile.ci.junit]` in `.config/nextest.toml` | verified |
|
|
85
|
+
| End-to-end | **Selenium** (Java, Python, JavaScript, C#) | through the runner above it: Surefire, pytest, Jest/Mocha, `dotnet test` | JUnit format; error wording read |
|
|
86
|
+
| End-to-end | Cypress, WebdriverIO | `mocha-junit-reporter` / `@wdio/junit-reporter` | JUnit format; error wording read |
|
|
87
|
+
| End-to-end | **Playwright** | blob reporter (step 1) — adds traces, selector drift and verified fixes | verified on 5 real projects |
|
|
88
|
+
|
|
89
|
+
```yaml
|
|
90
|
+
- name: Tewip
|
|
91
|
+
if: always()
|
|
92
|
+
uses: hmamut39/tewip@main
|
|
93
|
+
with:
|
|
94
|
+
junit-report: report.xml # a file, or a directory of them (.xml and .trx)
|
|
95
|
+
suite: unit # only needed when one workflow triages several suites
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
What it reads from any of these: the failure text, retries, and each test's history. From that it tells apart a wrong value (a real bug once the test has a passing history), an unreachable service (environment), a data collision, and a test that failed then passed on a retry (timing), in the wording each language uses: `expected: <4> but was: <3>` in Java, `got 3, want 4` in Go, `AssertionError: 3 != 4` in Python, `Expected: 4 / Actual: 3` in .NET, and so on. It also reads each browser tool's own words for the same three problems: an element that was never found (Selenium's `NoSuchElementException`, WebdriverIO's `still not displayed`, Cypress's `Expected to find element`), a click another element received (Selenium's `Other element would receive the click`, Cypress's `is being covered by another element`), and an element the page replaced mid-test (Selenium's `StaleElementReferenceException`, Cypress's `the page updated while this command was executing`). No labelled Selenium or Cypress runs have measured those rules yet, so they report at a confidence the merge gate does not trust on its own. What it cannot do without Playwright's traces is look at the page, so selector drift and automatic fixes stay Playwright-only.
|
|
99
|
+
|
|
100
|
+
A wrong value on a test's **first** recorded failure stays undecided rather than guessed: one failure alone does not show whether the test was reliable before. It becomes a real-bug diagnosis once the test's history shows it passing and then failing the same way.
|
|
101
|
+
|
|
102
|
+
When one workflow triages several suites (say `unit` and `e2e`), give each a `suite` name: each then keeps its own history and its own comment, and corrections name the suite, as in `/triage TIMING unit#2 flaky on CI`.
|
|
103
|
+
|
|
104
|
+
## On your own machine, without CI
|
|
105
|
+
|
|
106
|
+
Install the command once from the release file, `npm install -g tewip-<version>.tgz` (Tewip is not on the npm registry yet; Node 22.18 or newer), run your tests with the report switched on (see the table above), then:
|
|
107
|
+
|
|
108
|
+
```bash
|
|
109
|
+
tewip explain report.xml # JUnit XML or .trx
|
|
110
|
+
tewip explain reports/ # a folder of them
|
|
111
|
+
tewip explain blob-report/ # Playwright
|
|
112
|
+
tewip ci owner/repo --pr 12 # what Tewip's GitHub Action said about a pull request
|
|
113
|
+
```
|
|
114
|
+
|
|
115
|
+
It prints the same triage board CI writes: each failure's cause, confidence, evidence and next action. Each run is kept in a `.tewip/` folder in your project (add it to `.gitignore`), so from the second run on, failures are judged against their history exactly as in CI. `--name` keeps separate histories for different projects.
|
|
116
|
+
|
|
117
|
+
## What you will see on the next failing run
|
|
118
|
+
|
|
119
|
+
- **On the pull request:** one comment listing each failing test, grouped by whether your change likely caused it, each with a cause, a confidence, the evidence and the next action. It updates in place rather than adding a comment per run.
|
|
120
|
+
- **In the job summary:** the same failures as a triage board.
|
|
121
|
+
- **As an issue:** environment failures (5xx responses, connection resets, outages) grouped into one issue instead of one per test.
|
|
122
|
+
- **As an artifact** named `tewip-report`: every role's view, including the engineering-quality view with the flaky tests ranked by the CI minutes they cost.
|
|
123
|
+
|
|
124
|
+
## Correcting it
|
|
125
|
+
|
|
126
|
+
When it gets one wrong, reply to its comment:
|
|
127
|
+
|
|
128
|
+
```
|
|
129
|
+
/triage TIMING #2 this one is flaky on our CI runners, not a bug
|
|
130
|
+
```
|
|
131
|
+
|
|
132
|
+
From the next run on, that failure of that test gets your answer, shown as "corrected by a person" with your name and reason. A correction settles the cause; it never makes the agent change code.
|
|
133
|
+
|
|
134
|
+
## Asking it questions from your editor
|
|
135
|
+
|
|
136
|
+
- **VS Code, Cursor, Windsurf, VSCodium:** install the Tewip extension (*Extensions → … → Install from VSIX*, `tewip-<version>.vsix`). It connects Tewip to the editor's AI assistant by itself and adds *Tewip: Explain a test report…* and *Tewip: Why did CI fail on this branch?*
|
|
137
|
+
- **JetBrains (2025.2+), Claude, and other MCP clients:** add one server whose command is `tewip mcp`.
|
|
138
|
+
|
|
139
|
+
Then ask, in plain language: "why did CI fail on my PR?", "which tests are flaky in checkout?", "is main safe to release?". Every tool is read-only, and it reads the report the Action already uploaded, so you do not need the other repository cloned.
|
|
140
|
+
|
|
141
|
+
## Stop flaky tests from blocking merges (optional)
|
|
142
|
+
|
|
143
|
+
Once you trust its answers, let the agent decide whether a failed run should block:
|
|
144
|
+
|
|
145
|
+
```yaml
|
|
146
|
+
- name: Tests
|
|
147
|
+
continue-on-error: true # the gate below decides
|
|
148
|
+
run: npx playwright test
|
|
149
|
+
- name: Tewip
|
|
150
|
+
if: always()
|
|
151
|
+
uses: hmamut39/tewip@main
|
|
152
|
+
with:
|
|
153
|
+
gate: real-failures
|
|
154
|
+
```
|
|
155
|
+
|
|
156
|
+
The build then fails only for real bugs, changed selectors, test-data problems and anything undecided. Failures a rule or a person classified as flaky or environment no longer block. On 2,296 real failures this unblocked 84% of the flaky and environment ones without letting a real bug through.
|
|
157
|
+
|
|
158
|
+
## Turning fixing on, once you trust it
|
|
159
|
+
|
|
160
|
+
```yaml
|
|
161
|
+
autofix: 'true'
|
|
162
|
+
```
|
|
163
|
+
|
|
164
|
+
It then rewrites a drifted locator, re-runs that single test, and opens a **separate** pull request only with the changes that passed. Review it like any other pull request: an intended UI change and a regression can look identical from the outside, which is exactly why a human merges it.
|
|
165
|
+
|
|
166
|
+
On real WordPress CI data it would have fixed 14 drifted locators with none wrong, and every locator it suggested matched what the developers themselves wrote.
|
|
167
|
+
|
|
168
|
+
## If something does not appear
|
|
169
|
+
|
|
170
|
+
| Symptom | Cause |
|
|
171
|
+
|---|---|
|
|
172
|
+
| The step ran but says "no blob report" | The blob reporter is not on in CI, or the tests step did not run |
|
|
173
|
+
| No comment on the pull request | The run was not triggered by a pull request, or `pull-requests: write` is missing |
|
|
174
|
+
| "Resource not accessible by integration" | The workflow's permissions block is missing an entry |
|
|
175
|
+
| Diagnoses look thin on the first day | The agent judges each failure against that test's history, which it builds from your runs; it gets better as runs accumulate |
|
|
176
|
+
|
|
177
|
+
## What it costs, and what it keeps
|
|
178
|
+
|
|
179
|
+
The agent stores the run history in the Actions cache, never in your repository. Collected failure data and traces stay in CI. The only thing it writes to your repository is a pull request branch, and only when you turn fixing on.
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
export const CODE_FIX_PROMPT_VERSION = 'code-fix-1';
|
|
2
|
-
const SYSTEM = `You are Tewip's fixer. A test is failing against this code. Find the smallest change to the APPLICATION code that makes the test pass because the bug is gone, not because the check was avoided.
|
|
3
|
-
|
|
4
|
-
Rules:
|
|
5
|
-
- Change application code only. Never suggest changing the test, the expected values in it, configuration, or anything that silences the failure.
|
|
6
|
-
- The change must be minimal and local: the fewest lines that fix the cause. Do not refactor, rename, reformat, add logging, or "improve" anything nearby.
|
|
7
|
-
- before must be copied character for character from the file you were given, including indentation, and must appear in it exactly once. Include enough surrounding lines to be unique. Copy only what is in the file: nothing is added to it, so do not add line numbers or markers.
|
|
8
|
-
- after must keep the file valid in its language and keep the behaviour every other test relies on.
|
|
9
|
-
- If the code is right and the test is wrong, or if you cannot see the cause in the file you were given, set fault to "test" and return before and after as empty strings. Saying "I cannot see it" is a correct answer; a guess is not.
|
|
2
|
+
const SYSTEM = `You are Tewip's fixer. A test is failing against this code. Find the smallest change to the APPLICATION code that makes the test pass because the bug is gone, not because the check was avoided.
|
|
3
|
+
|
|
4
|
+
Rules:
|
|
5
|
+
- Change application code only. Never suggest changing the test, the expected values in it, configuration, or anything that silences the failure.
|
|
6
|
+
- The change must be minimal and local: the fewest lines that fix the cause. Do not refactor, rename, reformat, add logging, or "improve" anything nearby.
|
|
7
|
+
- before must be copied character for character from the file you were given, including indentation, and must appear in it exactly once. Include enough surrounding lines to be unique. Copy only what is in the file: nothing is added to it, so do not add line numbers or markers.
|
|
8
|
+
- after must keep the file valid in its language and keep the behaviour every other test relies on.
|
|
9
|
+
- If the code is right and the test is wrong, or if you cannot see the cause in the file you were given, set fault to "test" and return before and after as empty strings. Saying "I cannot see it" is a correct answer; a guess is not.
|
|
10
10
|
- why is for a reviewer: what was wrong and why this fixes it.`;
|
|
11
11
|
const SCHEMA = {
|
|
12
12
|
type: 'object',
|
|
@@ -1,29 +1,29 @@
|
|
|
1
1
|
export const BUILD_PROMPT_VERSION = 'build-1';
|
|
2
|
-
const RULES = `Rules that do not bend:
|
|
3
|
-
- Use only what the project already has: its framework, its style, its helpers, its way of importing. Copy the shape of the example test and the example source given.
|
|
4
|
-
- Never weaken or delete an existing test, and never change what one asserts.
|
|
5
|
-
- Keep the change small and local. Add a file when the project's own layout calls for one; do not reorganise anything.
|
|
6
|
-
- Write no comments that restate the code, no logging, no defensive try/catch around things that cannot fail.
|
|
2
|
+
const RULES = `Rules that do not bend:
|
|
3
|
+
- Use only what the project already has: its framework, its style, its helpers, its way of importing. Copy the shape of the example test and the example source given.
|
|
4
|
+
- Never weaken or delete an existing test, and never change what one asserts.
|
|
5
|
+
- Keep the change small and local. Add a file when the project's own layout calls for one; do not reorganise anything.
|
|
6
|
+
- Write no comments that restate the code, no logging, no defensive try/catch around things that cannot fail.
|
|
7
7
|
- before must be copied character for character from the file given and appear in it exactly once. For a new file, before is empty and after is the whole file.`;
|
|
8
|
-
const TEST_SYSTEM = `You are Tewip, writing the test for a feature that does not exist yet.
|
|
9
|
-
|
|
10
|
-
Write ONE test that checks the described behaviour, in the project's own framework and style. It must fail when run now, and fail for the right reason: the behaviour is missing, not because of a typo, a missing import or a file that does not exist. Use only functions, files and exports that already exist, or the one new export the feature obviously needs - name it as the project would.
|
|
11
|
-
|
|
12
|
-
checks is one sentence naming the behaviour the test asserts ("a full URL keeps its query when the trailing slash is removed"). It is not advice about file names or where to put things.
|
|
13
|
-
failsBecause is the behaviour that is missing today, in one sentence.
|
|
14
|
-
|
|
8
|
+
const TEST_SYSTEM = `You are Tewip, writing the test for a feature that does not exist yet.
|
|
9
|
+
|
|
10
|
+
Write ONE test that checks the described behaviour, in the project's own framework and style. It must fail when run now, and fail for the right reason: the behaviour is missing, not because of a typo, a missing import or a file that does not exist. Use only functions, files and exports that already exist, or the one new export the feature obviously needs - name it as the project would.
|
|
11
|
+
|
|
12
|
+
checks is one sentence naming the behaviour the test asserts ("a full URL keeps its query when the trailing slash is removed"). It is not advice about file names or where to put things.
|
|
13
|
+
failsBecause is the behaviour that is missing today, in one sentence.
|
|
14
|
+
|
|
15
15
|
${RULES}`;
|
|
16
|
-
const CODE_SYSTEM = `You are Tewip, writing the code that makes a failing test pass.
|
|
17
|
-
|
|
18
|
-
You are given the feature, the test, the real error it produced, and the project's relevant source. Write the smallest change that makes that test pass because the behaviour now exists - never by weakening the test, never by special-casing the test's own values.
|
|
19
|
-
|
|
20
|
-
If the feature cannot be built from what you were given - the code you need is not here, or the request is ambiguous in a way that changes the answer - set outcome to "cannot" and return no edits. Saying "I cannot" is a correct answer; a guess that happens to pass one test is not.
|
|
21
|
-
|
|
16
|
+
const CODE_SYSTEM = `You are Tewip, writing the code that makes a failing test pass.
|
|
17
|
+
|
|
18
|
+
You are given the feature, the test, the real error it produced, and the project's relevant source. Write the smallest change that makes that test pass because the behaviour now exists - never by weakening the test, never by special-casing the test's own values.
|
|
19
|
+
|
|
20
|
+
If the feature cannot be built from what you were given - the code you need is not here, or the request is ambiguous in a way that changes the answer - set outcome to "cannot" and return no edits. Saying "I cannot" is a correct answer; a guess that happens to pass one test is not.
|
|
21
|
+
|
|
22
22
|
${RULES}`;
|
|
23
|
-
const REPAIR_SYSTEM = `You are Tewip, fixing code you just wrote. The test still fails, or other tests broke. You are given what you changed and the real output.
|
|
24
|
-
|
|
25
|
-
Change your own code so the failing test passes and everything that was passing still passes. Never change the test. If you cannot, set outcome to "cannot".
|
|
26
|
-
|
|
23
|
+
const REPAIR_SYSTEM = `You are Tewip, fixing code you just wrote. The test still fails, or other tests broke. You are given what you changed and the real output.
|
|
24
|
+
|
|
25
|
+
Change your own code so the failing test passes and everything that was passing still passes. Never change the test. If you cannot, set outcome to "cannot".
|
|
26
|
+
|
|
27
27
|
${RULES}`;
|
|
28
28
|
const TEST_SCHEMA = {
|
|
29
29
|
type: 'object',
|
|
@@ -3,28 +3,28 @@
|
|
|
3
3
|
import { ROOT_CAUSES } from '../../reporters/types.js';
|
|
4
4
|
/** Bump whenever the prompt, schema or context format changes; it is part of the cache key. */
|
|
5
5
|
export const PROMPT_VERSION = 'llm-6';
|
|
6
|
-
export const SYSTEM_PROMPT = `You are the root-cause classifier of a Playwright test-failure triage agent.
|
|
7
|
-
You receive a structured summary of ONE failed test: the error, the test's run history, what the deterministic rules already checked, the test steps, the page at failure time (accessibility snapshot + notable DOM elements), failed network requests and console errors.
|
|
8
|
-
|
|
9
|
-
Classify the root cause into exactly one of these categories:
|
|
10
|
-
- REAL_BUG: the application under test behaves incorrectly. Examples: a wrong value is displayed; a feature or element the test needs is absent from the page and nothing equivalent exists; the app never reaches the expected state even though nothing external failed; uncaught page errors from application code.
|
|
11
|
-
- LOCATOR_DRIFT: the element the test wants is on the page, but the selector no longer matches it (renamed id, class, test id or text). The page summary must show an element with the same purpose.
|
|
12
|
-
- TIMING: the expected element or state does arrive, but not in time, or a race makes the result vary between attempts or runs. Signs: another attempt of the same code passed, intermittent history with varying errors, hard-coded waits, the element resolved but was not yet visible, stable or enabled.
|
|
13
|
-
- ENV: something outside the app code and the test broke: failed or 5xx/502/503 responses from a backend or third-party service, connection or DNS errors, expired auth or credentials, or many tests in the same run failing the same way.
|
|
14
|
-
- TEST_DATA: the test's preconditions or fixture data are wrong: missing or stale seeded data, a user or account in the wrong state, an expected value that depends on data the test did not set up, a 404 for a record the test assumed exists.
|
|
15
|
-
|
|
16
|
-
How to decide:
|
|
17
|
-
- Use only facts present in the summary. Do not invent page content, requests or history.
|
|
18
|
-
- Prefer the category the evidence directly shows over one that is merely possible.
|
|
19
|
-
- An element that is missing with no similar element on the page is not LOCATOR_DRIFT.
|
|
20
|
-
- Playwright matches accessible names by substring, so a locator can match several elements at once ("strict mode violation"). That is LOCATOR_DRIFT only when one of the matched elements is the one the test means, which usually carries the locator's name as a whole word ("Edit" -> "Edit link"). When every match only contains the text inside a longer word or phrase ("Edit" -> "Editor canvas", "Gift" -> "Gifting options"), the element the test means is absent: judge it as REAL_BUG, TIMING or TEST_DATA on the other evidence, not LOCATOR_DRIFT.
|
|
21
|
-
- A failed request or server error is only ENV evidence if the test did not provoke it. When "test.exercisesErrorHandling" is set, the test deliberately triggers failures (rejections, server errors, retries), so a failed request is the scenario under test: judge whether the app handled it as the test expects. If it did not, that is REAL_BUG, not ENV. A real environment outage also tends to hit unrelated tests and to pass on retry, rather than failing every attempt on one commit while other commits pass.
|
|
22
|
-
- Check "thisRun" first. If anotherAttemptPassed is true, the same code both failed and passed, so the cause is not deterministic: a real bug or a drifted locator would fail every attempt. Choose among TIMING, ENV and TEST_DATA.
|
|
23
|
-
- Then read "history.pattern", which compares this commit's attempts with other commits. If every attempt on this commit failed while other commits passed, something in this commit changed behaviour: choose among REAL_BUG, LOCATOR_DRIFT and TEST_DATA using the page summary, not TIMING. An overall failure rate that mixes different commits is not evidence of flakiness; only failing and passing on the same code is.
|
|
24
|
-
- The "rules" section lists what the deterministic rules already examined and why they declined; treat those as checked facts.
|
|
25
|
-
|
|
26
|
-
Confidence (0 to 1): 0.9 or higher only when the summary directly shows the cause; 0.6-0.8 when it is the most likely reading but another category remains plausible; below 0.5 when you are mostly guessing. Low confidence routes the failure to a human, so do not inflate it.
|
|
27
|
-
|
|
6
|
+
export const SYSTEM_PROMPT = `You are the root-cause classifier of a Playwright test-failure triage agent.
|
|
7
|
+
You receive a structured summary of ONE failed test: the error, the test's run history, what the deterministic rules already checked, the test steps, the page at failure time (accessibility snapshot + notable DOM elements), failed network requests and console errors.
|
|
8
|
+
|
|
9
|
+
Classify the root cause into exactly one of these categories:
|
|
10
|
+
- REAL_BUG: the application under test behaves incorrectly. Examples: a wrong value is displayed; a feature or element the test needs is absent from the page and nothing equivalent exists; the app never reaches the expected state even though nothing external failed; uncaught page errors from application code.
|
|
11
|
+
- LOCATOR_DRIFT: the element the test wants is on the page, but the selector no longer matches it (renamed id, class, test id or text). The page summary must show an element with the same purpose.
|
|
12
|
+
- TIMING: the expected element or state does arrive, but not in time, or a race makes the result vary between attempts or runs. Signs: another attempt of the same code passed, intermittent history with varying errors, hard-coded waits, the element resolved but was not yet visible, stable or enabled.
|
|
13
|
+
- ENV: something outside the app code and the test broke: failed or 5xx/502/503 responses from a backend or third-party service, connection or DNS errors, expired auth or credentials, or many tests in the same run failing the same way.
|
|
14
|
+
- TEST_DATA: the test's preconditions or fixture data are wrong: missing or stale seeded data, a user or account in the wrong state, an expected value that depends on data the test did not set up, a 404 for a record the test assumed exists.
|
|
15
|
+
|
|
16
|
+
How to decide:
|
|
17
|
+
- Use only facts present in the summary. Do not invent page content, requests or history.
|
|
18
|
+
- Prefer the category the evidence directly shows over one that is merely possible.
|
|
19
|
+
- An element that is missing with no similar element on the page is not LOCATOR_DRIFT.
|
|
20
|
+
- Playwright matches accessible names by substring, so a locator can match several elements at once ("strict mode violation"). That is LOCATOR_DRIFT only when one of the matched elements is the one the test means, which usually carries the locator's name as a whole word ("Edit" -> "Edit link"). When every match only contains the text inside a longer word or phrase ("Edit" -> "Editor canvas", "Gift" -> "Gifting options"), the element the test means is absent: judge it as REAL_BUG, TIMING or TEST_DATA on the other evidence, not LOCATOR_DRIFT.
|
|
21
|
+
- A failed request or server error is only ENV evidence if the test did not provoke it. When "test.exercisesErrorHandling" is set, the test deliberately triggers failures (rejections, server errors, retries), so a failed request is the scenario under test: judge whether the app handled it as the test expects. If it did not, that is REAL_BUG, not ENV. A real environment outage also tends to hit unrelated tests and to pass on retry, rather than failing every attempt on one commit while other commits pass.
|
|
22
|
+
- Check "thisRun" first. If anotherAttemptPassed is true, the same code both failed and passed, so the cause is not deterministic: a real bug or a drifted locator would fail every attempt. Choose among TIMING, ENV and TEST_DATA.
|
|
23
|
+
- Then read "history.pattern", which compares this commit's attempts with other commits. If every attempt on this commit failed while other commits passed, something in this commit changed behaviour: choose among REAL_BUG, LOCATOR_DRIFT and TEST_DATA using the page summary, not TIMING. An overall failure rate that mixes different commits is not evidence of flakiness; only failing and passing on the same code is.
|
|
24
|
+
- The "rules" section lists what the deterministic rules already examined and why they declined; treat those as checked facts.
|
|
25
|
+
|
|
26
|
+
Confidence (0 to 1): 0.9 or higher only when the summary directly shows the cause; 0.6-0.8 when it is the most likely reading but another category remains plausible; below 0.5 when you are mostly guessing. Low confidence routes the failure to a human, so do not inflate it.
|
|
27
|
+
|
|
28
28
|
Return JSON only: the category, the confidence, a short reasoning (at most 3 sentences), and 1-4 evidence items quoting or pointing at specific facts from the summary.`;
|
|
29
29
|
export const OUTPUT_SCHEMA_NAME = 'triage_diagnosis';
|
|
30
30
|
export const OUTPUT_SCHEMA = {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "tewip-ai",
|
|
3
|
-
"version": "0.70.
|
|
3
|
+
"version": "0.70.13",
|
|
4
4
|
"mcpName": "io.github.hmamut39/tewip",
|
|
5
5
|
"description": "Tewip finds why each failing test failed - real bug, flaky test, environment, test data or changed selector - for any stack, from the command line, CI, or your editor.",
|
|
6
6
|
"keywords": [
|