@jeffawe/understudy 0.4.0 → 0.5.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.
- package/CHANGELOG.md +127 -0
- package/README.md +69 -172
- package/REASONER.md +76 -86
- package/dist/adapters/recorder/script.d.ts +25 -2
- package/dist/adapters/recorder/script.js +126 -31
- package/dist/core/outline.d.ts +43 -0
- package/dist/core/outline.js +121 -0
- package/dist/core/recording.d.ts +19 -1
- package/dist/core/recording.js +38 -2
- package/dist/core/replay.d.ts +62 -1
- package/dist/core/replay.js +162 -106
- package/dist/entry/cli.js +110 -29
- package/dist/entry/mcp.d.ts +1 -0
- package/dist/entry/mcp.js +114 -23
- package/dist/flows/destructive.js +1 -1
- package/dist/flows/distill.js +11 -6
- package/dist/flows/emit.d.ts +7 -0
- package/dist/flows/emit.js +26 -10
- package/dist/flows/execute.d.ts +12 -0
- package/dist/flows/execute.js +23 -16
- package/dist/flows/runs.d.ts +2 -0
- package/dist/flows/runs.js +7 -3
- package/dist/flows/save.d.ts +5 -2
- package/dist/flows/save.js +38 -23
- package/dist/flows/session.d.ts +176 -0
- package/dist/flows/session.js +383 -0
- package/dist/flows/variants.d.ts +81 -0
- package/dist/flows/variants.js +139 -0
- package/dist/memory/calibrate.js +3 -1
- package/dist/memory/pages.d.ts +34 -0
- package/dist/memory/pages.js +60 -0
- package/dist/memory/recall.d.ts +56 -2
- package/dist/memory/recall.js +194 -30
- package/dist/plan/planner.d.ts +11 -1
- package/dist/plan/planner.js +36 -19
- package/dist/store/app-settings.d.ts +26 -0
- package/dist/store/app-settings.js +49 -0
- package/dist/store/db.js +8 -1
- package/dist/store/types.d.ts +18 -0
- package/package.json +3 -2
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
What changed in each release of `@jeffawe/understudy`. Newest first.
|
|
4
|
+
|
|
5
|
+
## 0.5.0 — 2026-12-01
|
|
6
|
+
|
|
7
|
+
**Upgrade every machine that shares a database.** The flows index changes so a
|
|
8
|
+
flow can have branch variants, and older versions don't know about them.
|
|
9
|
+
|
|
10
|
+
### Added
|
|
11
|
+
- **Agent sessions.** `understudy_session` lets an agent explore an app in a
|
|
12
|
+
browser Understudy drives, instead of writing throwaway scripts. `step` runs
|
|
13
|
+
one step and says what changed: controls that appeared, went or changed
|
|
14
|
+
state, the address, API calls and errors. `look` lists the page's controls
|
|
15
|
+
with no field values. `save` keeps the steps that worked, proven by a
|
|
16
|
+
replay in a fresh browser. Starting along a saved flow (`flow`, `upTo`)
|
|
17
|
+
stops at the step that fails, which is how a stale flow gets repaired.
|
|
18
|
+
- **Branch variants.** Pass `variant` (e.g. a branch name) to recall, run,
|
|
19
|
+
save and sessions. A variant gets its own copy of the flows it changes,
|
|
20
|
+
beside the main ones, and uses the main flow wherever it has no copy.
|
|
21
|
+
Saving to a variant never touches the main flow, and its run history is
|
|
22
|
+
its own. `promote` (`understudy_save { flow, variant, promote: true }`,
|
|
23
|
+
`understudy promote`) makes a variant the main flow once the branch merges,
|
|
24
|
+
and `drop` (`understudy_save { flow, variant, drop: true }`,
|
|
25
|
+
`understudy drop`) deletes a copy so the variant uses the main flow again.
|
|
26
|
+
Recall and `understudy flows` show how a variant's steps differ from the
|
|
27
|
+
main flow's.
|
|
28
|
+
`baseUrl` / `--base-url` runs flows against the app at another address,
|
|
29
|
+
such as a preview deploy.
|
|
30
|
+
- **Page-ready checks.** `toBeEnabled`, `toBeDisabled`, `toBeEditable` and
|
|
31
|
+
`toBeFocused` are kept from scripts and replayed, and can be added to a
|
|
32
|
+
saved flow. A `{ timeout }` on a check or a wait lets that one step wait
|
|
33
|
+
longer than the rest: the way to wait for a slow login, instead of a sleep.
|
|
34
|
+
- **What changed on a page.** Runs and sessions keep each page's controls
|
|
35
|
+
(never field values). A session says how a page differs from the last time
|
|
36
|
+
it looked otherwise (`sinceLastSeen`). Recall warns when one of the best
|
|
37
|
+
flow's pages has looked different since it last passed (`pagesChanged`).
|
|
38
|
+
- **Suggestions when a session saves.** Waits for steps that worked only on
|
|
39
|
+
the second try or ran slow, facts for follow-up questions it revealed, and
|
|
40
|
+
controls that stayed disabled (maybe an app state the flow needs). They are
|
|
41
|
+
for the user to approve; nothing is written by itself.
|
|
42
|
+
- **Save from code.** `understudy_save { code }` takes Playwright code as
|
|
43
|
+
text, with no file and no test wrapper needed: for example, the lines
|
|
44
|
+
Playwright MCP printed while an agent explored, pasted as they came.
|
|
45
|
+
- **Run up to the commit.** `understudy_run { stopBeforeCommit: true }` and
|
|
46
|
+
`--until-commit` run a flow or plan that would buy or book something, up to
|
|
47
|
+
that step. The step's control is checked, and never pressed.
|
|
48
|
+
- **Stale-flow warnings in recall.** Each flow shows when it last passed and
|
|
49
|
+
last failed. When the best match's last run failed, or its last pass took a
|
|
50
|
+
path nobody accepted yet, recall says so in `why`. The CLI marks these
|
|
51
|
+
`LAST RUN FAILED` and `path not accepted`.
|
|
52
|
+
- **Step timeout setting.** `UNDERSTUDY_TIMEOUT_MS` sets it for every app.
|
|
53
|
+
`understudy app <app> --timeout <ms>` or `understudy_app { timeoutMs }`
|
|
54
|
+
sets it for one app. The default is still 10 s.
|
|
55
|
+
- **Fuller steps in recall.** An agent driving a flow itself now gets each
|
|
56
|
+
step's lookup type, scope, text filter, frame, `exact`, `force`, what an
|
|
57
|
+
assert checks, and when a human step is done. `recall --steps` shows them.
|
|
58
|
+
- Script import keeps `locator.waitFor()` as a check, and
|
|
59
|
+
`waitForResponse(/regex/)` as a response wait.
|
|
60
|
+
|
|
61
|
+
### Changed
|
|
62
|
+
- **A wait that can't be kept now stops the save**, instead of being dropped.
|
|
63
|
+
This covers a predicate `waitForURL`, `waitForRequest`, `waitForEvent`, and
|
|
64
|
+
a `waitForResponse` that's never awaited. Without the wait, the next step
|
|
65
|
+
runs too early. Checks that can't be kept (`toHaveCount`…) are still only
|
|
66
|
+
reported. `waitForLoadState('networkidle')` is now reported as not kept.
|
|
67
|
+
- Clicking a control named "Book" now counts as committing something, like
|
|
68
|
+
"Pay" and "Place order".
|
|
69
|
+
|
|
70
|
+
### Fixed
|
|
71
|
+
- `understudy emit` reads a login value a script got from `process.env.X`
|
|
72
|
+
from `X` again. It used to read `UNDERSTUDY_ENV_X`, which nobody sets.
|
|
73
|
+
- An imported `press('Enter')` in a password field was stored as the
|
|
74
|
+
password, so replay pressed the password instead of Enter. Re-save flows
|
|
75
|
+
imported that way.
|
|
76
|
+
- A click written as a role selector, `locator('role=button[name="Book"]')`
|
|
77
|
+
(as Playwright MCP prints it), is now read as that role and name. It used
|
|
78
|
+
to be stored as CSS with no name, so a commit button written this way
|
|
79
|
+
wasn't seen as one, and saving pressed it.
|
|
80
|
+
- Old select steps saved from `selectOption({ label: … })` no longer ask for a
|
|
81
|
+
login value named after the option. They pick it, with no re-saving needed.
|
|
82
|
+
- Some old forced clicks no longer appear to need a login value called
|
|
83
|
+
`{ force: true }` in recall.
|
|
84
|
+
|
|
85
|
+
## 0.4.0 — 2026-11-25
|
|
86
|
+
|
|
87
|
+
- `understudy calibrate` / `understudy_calibrate` fits when recall calls a
|
|
88
|
+
goal known, per app and embedding model. `reembed` re-fits every app that
|
|
89
|
+
has kept goals.
|
|
90
|
+
- `reembed` no longer leaves a database half-switched when it fails.
|
|
91
|
+
|
|
92
|
+
## 0.3.0 — 2026-11-25
|
|
93
|
+
|
|
94
|
+
- A flow that buys something is proven up to its commit step when saved.
|
|
95
|
+
`understudy prove` / `understudy_save { flow }` proves a saved one the same
|
|
96
|
+
way.
|
|
97
|
+
- Human steps (`human('…', { untilText | untilUrl | untilResponse })`),
|
|
98
|
+
server response waits (`wait_response`), app-state preconditions
|
|
99
|
+
(`requires` / `establishes`), and adding steps to a saved flow
|
|
100
|
+
(`understudy edit`, `understudy_save { flow, add }`).
|
|
101
|
+
- Accept a changed path by triaging its `flow_drift` finding as `expected`.
|
|
102
|
+
- Saving offers end checks: headings, ticked boxes and status messages seen
|
|
103
|
+
when the flow ended.
|
|
104
|
+
- On a tie, recall ranks a person's recording ahead of an agent's.
|
|
105
|
+
- Fixed: script import options, and the addresses steps record.
|
|
106
|
+
|
|
107
|
+
## 0.2.2 — 2026-11-23
|
|
108
|
+
|
|
109
|
+
- Script import keeps assertions instead of dropping them.
|
|
110
|
+
- Fixed placeholder and label lookups.
|
|
111
|
+
- Data now lives under `~/.understudy`.
|
|
112
|
+
- A failed assertion says what it saw, and every failed step names its
|
|
113
|
+
locator. Console warnings are no longer findings.
|
|
114
|
+
|
|
115
|
+
## 0.2.1 — 2026-11-21
|
|
116
|
+
|
|
117
|
+
- Links to the recorder on the Chrome Web Store, and uses npm's preferred bin
|
|
118
|
+
paths.
|
|
119
|
+
- Exits quietly when output is piped into `head`.
|
|
120
|
+
|
|
121
|
+
## 0.2.0 — 2026-11-20
|
|
122
|
+
|
|
123
|
+
- First published release. It has the MongoDB memory, the Chrome, Edge and
|
|
124
|
+
Firefox recorder extension, and the MCP server.
|
|
125
|
+
- Flows can be saved unproven, and recall warns about them.
|
|
126
|
+
- Login values that are missing are asked for in the terminal, and agents are
|
|
127
|
+
told which env line to add.
|
package/README.md
CHANGED
|
@@ -5,193 +5,82 @@
|
|
|
5
5
|
[](https://www.npmjs.com/package/@jeffawe/understudy)
|
|
6
6
|
|
|
7
7
|
End-to-end tests for your own web apps, without clicking through every flow by
|
|
8
|
-
hand. Record a flow once
|
|
9
|
-
when the app changes, and can run goals you describe in words
|
|
10
|
-
that need pieces of several recordings.
|
|
8
|
+
hand. Record a flow once. Understudy remembers it, replays it as a test,
|
|
9
|
+
notices when the app changes, and can run goals you describe in words, even
|
|
10
|
+
goals that need pieces of several recordings.
|
|
11
11
|
|
|
12
|
-
It
|
|
12
|
+
It works on its own from the command line, and plugs into an AI agent (Claude
|
|
13
|
+
Code, Codex, Cursor) over MCP. With an agent, Understudy never calls a model
|
|
14
|
+
itself: the agent is the model.
|
|
13
15
|
|
|
14
|
-
|
|
15
|
-
npm install -g @jeffawe/understudy
|
|
16
|
-
```
|
|
17
|
-
|
|
18
|
-
It works on its own from the command line, and it plugs into an AI agent
|
|
19
|
-
(Claude Code, Codex, Cursor) over MCP. The agent is optional; with one,
|
|
20
|
-
Understudy never calls a model itself — the agent is the model.
|
|
16
|
+
## How it works
|
|
21
17
|
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
```
|
|
18
|
+
```text
|
|
25
19
|
record → save → replay / run → findings
|
|
26
20
|
```
|
|
27
21
|
|
|
28
|
-
- **record
|
|
29
|
-
[Understudy recorder](https://chromewebstore.google.com/detail/understudy-recorder/mdobdjogkgimabdpmbmhhcdeoahoapjf)
|
|
30
|
-
|
|
31
|
-
a
|
|
32
|
-
- **save
|
|
33
|
-
step passes, so memory only
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
does a goal you describe ("go to my basket") and runs it. Matching is by
|
|
39
|
-
meaning if you configure an embedding model, by name if you don't.
|
|
40
|
-
- **findings** — every run checks for console errors, failed requests, error
|
|
41
|
-
responses, values that didn't stick, and whether the flow took a different
|
|
42
|
-
path through the app than last time. Each problem is reported once, with a
|
|
43
|
-
count, not once per run. A run that passes on a changed path is flagged until
|
|
44
|
-
you say the change is meant to be there — then that path is the normal one.
|
|
45
|
-
|
|
46
|
-
With an agent attached it also splits recordings into reusable segments (a
|
|
47
|
-
login cut out of a checkout, say), plans a goal across segments of different
|
|
48
|
-
recordings, and writes down what it learns as facts and lessons that apply to
|
|
49
|
-
every future run.
|
|
50
|
-
|
|
51
|
-
## More than clicks
|
|
52
|
-
|
|
53
|
-
A flow is a list of steps. Besides clicking and typing, a step can:
|
|
54
|
-
|
|
55
|
-
- **wait for a person** — something only you can do, like accepting a visit in
|
|
56
|
-
another system or typing a code from your phone. The run pauses, asks, and
|
|
57
|
-
carries on when you say it's done (or when the page shows it).
|
|
58
|
-
- **wait for the server** — a response, its status, and one field of its JSON:
|
|
59
|
-
"`POST /api/visits` returned 201 and `commission.amount` is above 0".
|
|
60
|
-
- **check how it ended** — after a save, Understudy offers what the last page
|
|
61
|
-
showed (headings, ticked boxes, status messages) as checks. You choose which
|
|
62
|
-
mean "it ended right".
|
|
63
|
-
- **need an app state** — "member has an active bundle". A plan runs the flow
|
|
64
|
-
that makes it true first, or takes your word that it already is.
|
|
65
|
-
|
|
66
|
-
These come from a Playwright script (`page.waitForResponse`,
|
|
67
|
-
`human('what to do', { untilText: '…' })`), or can be added to a flow you've
|
|
68
|
-
already saved with `understudy edit`.
|
|
69
|
-
|
|
70
|
-
## Set up (about five minutes)
|
|
71
|
-
|
|
72
|
-
You need **Node 22+** and a **MongoDB** with vector search — a free
|
|
73
|
-
[Atlas](https://www.mongodb.com/atlas) cluster (nothing to install), or MongoDB
|
|
74
|
-
Community Edition with `mongot` running locally.
|
|
22
|
+
- **record**: click through a flow in your browser with the
|
|
23
|
+
[Understudy recorder](https://chromewebstore.google.com/detail/understudy-recorder/mdobdjogkgimabdpmbmhhcdeoahoapjf)
|
|
24
|
+
extension, or import a Playwright script. Passwords are never stored: a
|
|
25
|
+
password field is kept as a name like `SECRET.password`.
|
|
26
|
+
- **save**: the flow is replayed in a fresh browser first and kept only if
|
|
27
|
+
every step passes, so memory holds only flows known to work.
|
|
28
|
+
- **replay / run**: `replay` runs a flow by name; `run` finds the flow for a
|
|
29
|
+
goal you describe ("go to my basket") and runs it.
|
|
30
|
+
- **findings**: every run reports console errors, failed requests, values that
|
|
31
|
+
didn't stick, and whether the flow took a different path than last time.
|
|
75
32
|
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
understudy config set MONGODB_URI="mongodb+srv://…" EMBED_KEY="…"
|
|
81
|
-
```
|
|
33
|
+
A step can also wait for a person (a code from your phone), wait for a server
|
|
34
|
+
response, or check how the flow ended. Anything that buys, books or deletes is
|
|
35
|
+
marked destructive and only runs when you allow it.
|
|
82
36
|
|
|
83
|
-
|
|
84
|
-
a [Voyage](https://www.voyageai.com) API key (200M free tokens); it's optional —
|
|
85
|
-
without one, goals match flow names instead of meaning.
|
|
37
|
+
## Set up
|
|
86
38
|
|
|
87
|
-
|
|
39
|
+
You need **Node 22+** and a **MongoDB** with vector search: a free
|
|
40
|
+
[Atlas](https://www.mongodb.com/atlas) cluster, or MongoDB Community with
|
|
41
|
+
`mongot`.
|
|
88
42
|
|
|
89
43
|
```bash
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
To record, install the [Understudy recorder](https://chromewebstore.google.com/detail/understudy-recorder/mdobdjogkgimabdpmbmhhcdeoahoapjf) from the Chrome Web Store.
|
|
94
|
-
Not using Chrome or another Chromium browser? See
|
|
95
|
-
[extension/README.md](extension/README.md).
|
|
96
|
-
|
|
97
|
-
**On Safari, or prefer a fresh browser over your own?** Record in a browser
|
|
98
|
-
Understudy opens instead. It needs one extra download, the full Chromium
|
|
99
|
-
browser (about 350 MB, once):
|
|
100
|
-
|
|
101
|
-
```bash
|
|
102
|
-
npx playwright install chromium
|
|
103
|
-
understudy record myapp --new-browser --url https://your-app.example
|
|
44
|
+
npm install -g @jeffawe/understudy
|
|
45
|
+
npx playwright install --only-shell chromium
|
|
46
|
+
understudy config set MONGODB_URI="mongodb+srv://…" EMBED_KEY="…"
|
|
104
47
|
```
|
|
105
48
|
|
|
106
|
-
|
|
49
|
+
Settings are written to `~/.understudy/understudy.env`, which only you can
|
|
50
|
+
read. Already keep them in a file? Use `understudy config --env-file <path>`.
|
|
107
51
|
|
|
108
52
|
| Setting | What it's for |
|
|
109
|
-
|
|
110
|
-
| `MONGODB_URI` | your Atlas
|
|
111
|
-
| `EMBED_KEY` | optional: a Voyage key, to match goals by meaning
|
|
112
|
-
| `UNDERSTUDY_<
|
|
53
|
+
| --- | --- |
|
|
54
|
+
| `MONGODB_URI` | your Atlas or local MongoDB |
|
|
55
|
+
| `EMBED_KEY` | optional: a [Voyage](https://www.voyageai.com) key, to match goals by meaning rather than by flow name |
|
|
56
|
+
| `UNDERSTUDY_<NAME>` | login values, e.g. `UNDERSTUDY_SECRET_PASSWORD` for `SECRET.password`. Not set? The terminal asks for it. |
|
|
113
57
|
|
|
114
|
-
|
|
58
|
+
Another embedding model works too: set `EMBED_URL`, `EMBED_MODEL` and
|
|
59
|
+
`EMBED_DIMS` for any OpenAI-style `/v1/embeddings` endpoint (OpenAI, Ollama…),
|
|
60
|
+
then run `understudy calibrate <app> --template` to fit matching to it.
|
|
115
61
|
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
`EMBED_DIMS` if its vectors aren't 1024 numbers long. Free and offline, with
|
|
120
|
-
[Ollama](https://ollama.com):
|
|
121
|
-
|
|
122
|
-
```bash
|
|
123
|
-
ollama pull mxbai-embed-large
|
|
124
|
-
understudy config set EMBED_URL=http://localhost:11434/v1/embeddings EMBED_MODEL=mxbai-embed-large EMBED_DIMS=1024
|
|
125
|
-
```
|
|
126
|
-
|
|
127
|
-
Two things to know. One database holds one model's vectors, so switching later
|
|
128
|
-
means `understudy reembed`. And the line between "a flow I know" and "close,
|
|
129
|
-
but not it" was set for Voyage. Other models score on their own scale: with
|
|
130
|
-
the cutoffs set for Voyage, mxbai-embed-large called 12 of 14 goals an app didn't have
|
|
131
|
-
"known", so the wrong flow would have run. Fit the line to your app and model:
|
|
132
|
-
|
|
133
|
-
```bash
|
|
134
|
-
understudy calibrate myapp --template > goals.json # every flow, to reword
|
|
135
|
-
# fill in 2–3 ways someone would ask for each flow, and 5+ goals that sound
|
|
136
|
-
# like the app but that it has no flow for
|
|
137
|
-
understudy calibrate myapp --goals goals.json
|
|
138
|
-
```
|
|
139
|
-
|
|
140
|
-
The goals are kept, so after any later `understudy reembed` the line is re-fit
|
|
141
|
-
for the new model on its own. `recall` says when it's using cutoffs that
|
|
142
|
-
weren't fitted for the model you have.
|
|
62
|
+
No Chrome? `understudy record myapp --new-browser --url https://your-app.example`
|
|
63
|
+
records in a browser Understudy opens (run `npx playwright install chromium`
|
|
64
|
+
once first).
|
|
143
65
|
|
|
144
66
|
## Use it
|
|
145
67
|
|
|
146
68
|
```bash
|
|
147
|
-
understudy record myapp # record
|
|
148
|
-
understudy save <hash> "log in as a member" #
|
|
149
|
-
|
|
150
|
-
# --force keeps it even if the replay fails
|
|
69
|
+
understudy record myapp # record with the extension
|
|
70
|
+
understudy save <hash> "log in as a member" # replay it, keep it if it passes
|
|
71
|
+
understudy import myapp login.spec.ts # or start from a Playwright script
|
|
151
72
|
understudy flows myapp # what it knows how to do
|
|
152
73
|
understudy replay myapp log-in-as-a-member # run one flow
|
|
153
|
-
understudy run myapp "sign in" # find the flow for a goal,
|
|
154
|
-
understudy
|
|
155
|
-
understudy
|
|
156
|
-
understudy edit myapp book-a-visit --before 3 --step '{"action":"human","value":"Accept the visit"}'
|
|
157
|
-
# add a person's step, a wait or a check to a saved flow
|
|
158
|
-
understudy findings myapp # what looked broken, most severe first
|
|
159
|
-
understudy findings myapp --triage <id>=expected
|
|
160
|
-
# a changed path is meant to be there: make it the normal one
|
|
161
|
-
understudy emit myapp log-in-as-a-member # print it as a Playwright (or Cypress) test
|
|
162
|
-
understudy app myapp --placeholder email # keep email addresses out of memory (moves them to your env file)
|
|
74
|
+
understudy run myapp "sign in" # find the flow for a goal, run it
|
|
75
|
+
understudy findings myapp # what looked broken
|
|
76
|
+
understudy emit myapp log-in-as-a-member # export as a Playwright test
|
|
163
77
|
```
|
|
164
78
|
|
|
165
|
-
|
|
166
|
-
it that passes proves it. A flow that commits something real — a purchase, a
|
|
167
|
-
deletion — is marked destructive: saving and `prove` stop just before that
|
|
168
|
-
step, and a full run needs `--allow-purchases`. `understudy --help` lists
|
|
169
|
-
everything, and `understudy --version` says which one you have.
|
|
170
|
-
|
|
171
|
-
## Where your data goes
|
|
172
|
-
|
|
173
|
-
Everything stays with you. Understudy has no server, no account and no
|
|
174
|
-
telemetry.
|
|
175
|
-
|
|
176
|
-
- **Recordings** are files on your machine, in `~/.understudy` (or
|
|
177
|
-
`UNDERSTUDY_HOME`) — the same place whichever folder you, or your agent, run
|
|
178
|
-
it from. The Chrome extension sends what it records only to Understudy on
|
|
179
|
-
`127.0.0.1`. Before 0.2.2 they went in a `.understudy` folder wherever it ran;
|
|
180
|
-
those still load.
|
|
181
|
-
- **Saved flows, notes and findings** go to the MongoDB you configured.
|
|
182
|
-
- **Your embedding model** (Voyage by default, if you set a key) receives only
|
|
183
|
-
the short texts used for search — flow names and descriptions, facts and
|
|
184
|
-
lessons, the goals you ask for — never steps, typed values or cookies.
|
|
185
|
-
- **Passwords** are never stored; signed-in sessions and your env file are
|
|
186
|
-
local files only you can read.
|
|
187
|
-
- **Your agent**, if you use one, sees what Understudy's tools return to it.
|
|
188
|
-
|
|
189
|
-
The recorder extension's privacy policy: [understudy.jeffawe.dev/privacy.html](https://understudy.jeffawe.dev/privacy.html).
|
|
79
|
+
`understudy --help` lists everything else.
|
|
190
80
|
|
|
191
81
|
## With an agent
|
|
192
82
|
|
|
193
|
-
Add the MCP server
|
|
194
|
-
settings come from the env file you point it at, so keys never go in the
|
|
83
|
+
Add the MCP server; settings come from your env file, so keys never go in the
|
|
195
84
|
agent's config or the chat:
|
|
196
85
|
|
|
197
86
|
```bash
|
|
@@ -205,23 +94,31 @@ claude mcp add understudy -- npx -y -p @jeffawe/understudy understudy-mcp --env-
|
|
|
205
94
|
} } }
|
|
206
95
|
```
|
|
207
96
|
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
97
|
+
The agent can then recall and run flows, save what it explored, split flows
|
|
98
|
+
into reusable pieces, and write down what it learns.
|
|
99
|
+
[REASONER.md](REASONER.md) is how an agent should use it. Mid-run it may ask
|
|
100
|
+
you to do a step only a person can do; answer in the chat.
|
|
101
|
+
|
|
102
|
+
## Where your data goes
|
|
103
|
+
|
|
104
|
+
Understudy has no server, no account and no telemetry.
|
|
105
|
+
|
|
106
|
+
- **Recordings** stay in `~/.understudy`; the extension sends only to
|
|
107
|
+
Understudy on `127.0.0.1`.
|
|
108
|
+
- **Flows, notes and findings** go to your MongoDB.
|
|
109
|
+
- **Your embedding model** sees only short search texts (flow names, goals),
|
|
110
|
+
never steps, typed values or cookies.
|
|
111
|
+
- **Passwords** are never stored.
|
|
214
112
|
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
records your answer.
|
|
113
|
+
Recorder privacy policy:
|
|
114
|
+
[understudy.jeffawe.dev/privacy.html](https://understudy.jeffawe.dev/privacy.html).
|
|
218
115
|
|
|
219
116
|
## Learn more
|
|
220
117
|
|
|
221
|
-
- [understudy.jeffawe.dev](https://understudy.jeffawe.dev)
|
|
222
|
-
- [REASONER.md](REASONER.md)
|
|
223
|
-
- [extension/README.md](extension/README.md)
|
|
118
|
+
- [understudy.jeffawe.dev](https://understudy.jeffawe.dev): the overview
|
|
119
|
+
- [REASONER.md](REASONER.md): for agents
|
|
120
|
+
- [extension/README.md](extension/README.md): the Chrome recorder
|
|
224
121
|
|
|
225
122
|
## License
|
|
226
123
|
|
|
227
|
-
Apache-2.0
|
|
124
|
+
Apache-2.0, see [LICENSE](LICENSE).
|
package/REASONER.md
CHANGED
|
@@ -1,94 +1,84 @@
|
|
|
1
1
|
# Using Understudy
|
|
2
2
|
|
|
3
|
-
Understudy runs end-to-end tests
|
|
4
|
-
remembers.
|
|
3
|
+
Understudy runs end-to-end tests of the user's web apps from flows it
|
|
4
|
+
remembers. It calls no model: you answer its questions.
|
|
5
5
|
|
|
6
6
|
## Rules
|
|
7
7
|
|
|
8
|
-
- **
|
|
9
|
-
flow
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
(`UNDERSTUDY_SECRET_PASSWORD`)
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
- **
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
8
|
+
- **Recall first.** `understudy_recall` is free and runs nothing. It returns a
|
|
9
|
+
flow's steps, the login values they need (`needs`), and whether it's
|
|
10
|
+
**stale** (last run failed, or passed on a path nobody accepted; `why`,
|
|
11
|
+
`pagesChanged`). Check a stale step before trusting it.
|
|
12
|
+
- **Reach the goal however works** (`understudy_run` or your own browser) and
|
|
13
|
+
**say which you used**. Never imply Understudy ran what you drove.
|
|
14
|
+
- **Never ask for a password in chat.** Steps name `SECRET.password`; the value
|
|
15
|
+
comes from the user's env (`UNDERSTUDY_SECRET_PASSWORD`) or your `values`.
|
|
16
|
+
- **Logins are often rate-limited.** A missing login value stops a run before
|
|
17
|
+
a browser opens and names the env line: ask the user to add it, then retry.
|
|
18
|
+
- **Destructive flows** (purchases, bookings, deletions) are refused unless
|
|
19
|
+
`allowPurchases`, or run up to the commit with `stopBeforeCommit`. Start
|
|
20
|
+
with `dryRun: true`.
|
|
21
|
+
- **Testing a branch?** Pass `variant` (the branch name) to every call, and
|
|
22
|
+
`baseUrl` for its preview deploy. A copy never touches the main flow. A flow
|
|
23
|
+
listing `variants` has branch copies: ask the user which the run is for.
|
|
24
|
+
- **Ask the user first** before distilling, promoting a variant, triaging
|
|
25
|
+
`expected`, or remembering anything. Saving a flow needs no permission.
|
|
26
|
+
|
|
27
|
+
## Questions a run asks
|
|
28
|
+
|
|
29
|
+
It plans before any browser opens. Reply with `understudy_answer`.
|
|
30
|
+
|
|
31
|
+
| Question | Answer |
|
|
32
|
+
| --- | --- |
|
|
33
|
+
| decompose | `{"subGoals": [...]}` in the order the app does it, in the words of its flows (listed). Add prerequisites like logging in. One sub-goal naming a whole flow beats several naming its parts. Tell the user. |
|
|
34
|
+
| seam | `{"steps": [one click or goto]}` between two flows, or `{"steps": []}` **unless you actually know**: answers are saved forever. |
|
|
35
|
+
| state | `{"use": "<slug>"}` from `establishedBy`, or `{"holds": true}`. Ask the user; lasts this run. |
|
|
36
|
+
| human | A step only a person can do: tell the user `ask`, then `{"done": true}` when they say so, or `{"abort": "why"}`. |
|
|
37
|
+
| handoff | A step failed in a `headed` browser: same answers, they do that step. |
|
|
38
|
+
|
|
39
|
+
## Adding to memory
|
|
40
|
+
|
|
41
|
+
**A new flow.** Saving replays it in a fresh browser and keeps it only if
|
|
42
|
+
every step passes. A commit step ("Pay now") is checked, never pressed.
|
|
43
|
+
|
|
44
|
+
| You have | Call |
|
|
45
|
+
| --- | --- |
|
|
46
|
+
| Steps that worked in your own browser (Playwright MCP) | `understudy_save { name, code }`: the lines it printed |
|
|
47
|
+
| A Playwright script | `understudy_save { name, script }`; passwords from `process.env` |
|
|
48
|
+
| Nothing yet | `understudy_session`: `start` → `step` / `look` → `save` |
|
|
49
|
+
| A user who'll record it | `understudy_record`, then `understudy_save` when they stop |
|
|
50
|
+
| A flow that can't replay safely | add `verify: false` and a `note`; unproven until a run passes |
|
|
51
|
+
|
|
52
|
+
Save what the user would test again; a one-off is enough as facts.
|
|
53
|
+
|
|
54
|
+
**A saved flow.**
|
|
55
|
+
|
|
56
|
+
| To | Call |
|
|
57
|
+
| --- | --- |
|
|
58
|
+
| Repair a stale one | `understudy_session { flow }` stops at the failing step; fix it, save under the same name |
|
|
59
|
+
| Add a wait, check or person's step | `understudy_save { flow, add }` |
|
|
60
|
+
| Prove it as it stands | `understudy_save { flow }` |
|
|
61
|
+
| Keep a branch's version | any save with `variant`; when merged, `promote: true`; `drop: true` deletes the copy |
|
|
62
|
+
| Pin how it should end | a save offers end checks: ask which mean "it ended right", add them |
|
|
63
|
+
|
|
64
|
+
**Knowledge.** Put what you learned to the user at a natural pause.
|
|
65
|
+
|
|
66
|
+
| What | Call |
|
|
67
|
+
| --- | --- |
|
|
68
|
+
| Segments | `understudy_distill` → `understudy_save_distilled`. Steps by index; preconditions exactly `"authenticated"` / `"not authenticated"`; other state in `requires` / `establishes` (kebab-case, from `vocabulary.states`); reuse segment slugs. |
|
|
69
|
+
| Facts, lessons, findings | one `understudy_remember`. A fact changes plans; a lesson changes one step (exact trigger: `url_pattern` / `action` / `role` / `name`, never empty); a finding says the app is broken; `reached` records a goal done without `understudy_run`. |
|
|
70
|
+
| Triage | `understudy_findings`: `issue`, `lesson` or `noise`. A pass on a changed path isn't history until its `flow_drift` is `expected`. |
|
|
71
|
+
| App settings | `understudy_app`: `placeholders: ["email"]` moves emails to the env file; `timeoutMs` for slow apps. |
|
|
72
|
+
|
|
73
|
+
Runs and seam answers add history and page links on their own.
|
|
74
74
|
|
|
75
75
|
## Traps
|
|
76
76
|
|
|
77
|
-
- **File uploads can't be recorded
|
|
78
|
-
- **
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
- **
|
|
84
|
-
|
|
85
|
-
never pressed. Anything irreversible the words don't reveal still runs —
|
|
86
|
-
say so with a fact (`marksDestructive`) first — or save it without
|
|
87
|
-
replaying at all (`verify: false`, with a `note`). `understudy_save` with
|
|
88
|
-
`flow` proves one saved that way later, up to its commit.
|
|
89
|
-
- **Logins are often rate-limited**; a missing login value stops a run before
|
|
90
|
-
it opens a browser, so check `needs` from recall first. The answer names the
|
|
91
|
-
env file line to add: ask the user to add it, then call again.
|
|
92
|
-
- **"Matched no elements" isn't always a bad selector** — check the page
|
|
93
|
-
rendered at all.
|
|
94
|
-
- **On Atlas, a just-saved flow takes a few seconds to be searchable.**
|
|
77
|
+
- **File uploads can't be recorded**: write a script.
|
|
78
|
+
- **In a script**, a person's step is `human('what they do', { untilText |
|
|
79
|
+
untilUrl | untilResponse })`; a server-only result is `page.waitForResponse`
|
|
80
|
+
(or a `wait_response` step with `field` and `equals` / `above`).
|
|
81
|
+
- **Irreversible but the words don't say so?** It would run when saved: first
|
|
82
|
+
remember a fact with `marksDestructive`, or save with `verify: false`.
|
|
83
|
+
- **"Matched no elements"** may mean the page didn't render at all.
|
|
84
|
+
- **On Atlas**, a just-saved flow takes a few seconds to be searchable.
|