@jeffawe/understudy 0.2.1 → 0.2.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +11 -11
- package/dist/adapters/recorder/live.js +6 -5
- package/dist/adapters/recorder/script.d.ts +27 -0
- package/dist/adapters/recorder/script.js +326 -96
- package/dist/core/auth-cache.d.ts +1 -0
- package/dist/core/auth-cache.js +4 -2
- package/dist/core/recording-store.d.ts +6 -0
- package/dist/core/recording-store.js +30 -7
- package/dist/core/replay.d.ts +11 -0
- package/dist/core/replay.js +153 -4
- package/dist/core/visual.js +3 -2
- package/dist/entry/cli.js +23 -7
- package/dist/entry/mcp.js +22 -9
- package/dist/entry/version.d.ts +8 -0
- package/dist/entry/version.js +16 -0
- package/dist/flows/drift.d.ts +6 -0
- package/dist/flows/emit.js +51 -5
- package/dist/flows/findings.d.ts +11 -0
- package/dist/flows/findings.js +18 -1
- package/dist/flows/runs.js +1 -1
- package/dist/plan/planner.js +5 -0
- package/extension/README.md +1 -1
- package/package.json +2 -2
package/dist/flows/findings.js
CHANGED
|
@@ -12,7 +12,9 @@ export function stable(text) {
|
|
|
12
12
|
return text
|
|
13
13
|
.replace(/(https?:\/\/[^\s'"?#]+)\?[^\s'"]*/g, '$1')
|
|
14
14
|
.replace(/[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}/gi, ':uuid')
|
|
15
|
-
|
|
15
|
+
// Not a port: `localhost:3000` is where the app is, not a varying id, and
|
|
16
|
+
// replacing it produced `localhost::n`.
|
|
17
|
+
.replace(/(?<![\w\]]:)\b\d{3,}\b/g, ':n')
|
|
16
18
|
.replace(/\s+/g, ' ')
|
|
17
19
|
.trim()
|
|
18
20
|
.slice(0, 300);
|
|
@@ -111,6 +113,21 @@ export async function saveFindings(coll, app, drafts, at = new Date()) {
|
|
|
111
113
|
},
|
|
112
114
|
})));
|
|
113
115
|
}
|
|
116
|
+
const SEVERITY_RANK = { high: 3, medium: 2, low: 1 };
|
|
117
|
+
/**
|
|
118
|
+
* Findings for an app, MOST SEVERE FIRST, then most frequent, then newest.
|
|
119
|
+
*
|
|
120
|
+
* Frequency alone put eight framework image warnings above the one real
|
|
121
|
+
* regression: a noisy console fires on every page, a broken route once.
|
|
122
|
+
* Sorted here rather than in the query because severity is a word, not a rank.
|
|
123
|
+
*/
|
|
124
|
+
export async function listFindings(coll, app, opts = {}) {
|
|
125
|
+
const rows = await coll.find(opts.all ? { app } : { app, status: 'open' }).toArray();
|
|
126
|
+
rows.sort((a, b) => (SEVERITY_RANK[b.severity] ?? 0) - (SEVERITY_RANK[a.severity] ?? 0)
|
|
127
|
+
|| (b.occurrences ?? 0) - (a.occurrences ?? 0)
|
|
128
|
+
|| +new Date(b.lastSeen) - +new Date(a.lastSeen));
|
|
129
|
+
return rows.slice(0, opts.limit ?? 40);
|
|
130
|
+
}
|
|
114
131
|
/**
|
|
115
132
|
* Route open findings. issue: the app is wrong and someone should fix it.
|
|
116
133
|
* lesson: accepted — the agent works around it (pass the lesson to store).
|
package/dist/flows/runs.js
CHANGED
|
@@ -32,7 +32,7 @@ export async function recordRun(opts) {
|
|
|
32
32
|
// page it never reached as "gone", which is noise, not drift.
|
|
33
33
|
const drift = result.ok
|
|
34
34
|
? compareToHistory(result.sigSequence, history.map((h) => h.sigSequence))
|
|
35
|
-
: compareToHistory([], []);
|
|
35
|
+
: { ...compareToHistory([], []), firstRun: false, notCompared: 'the run failed, so its path is incomplete' };
|
|
36
36
|
// 2. Findings.
|
|
37
37
|
const name = plan.join(' + ');
|
|
38
38
|
const drafts = extractFindings(result, name);
|
package/dist/plan/planner.js
CHANGED
|
@@ -98,6 +98,11 @@ async function block(run, why, detail) {
|
|
|
98
98
|
async function advance(run) {
|
|
99
99
|
const planning = (run.planning ??= {});
|
|
100
100
|
const { flows } = await collections();
|
|
101
|
+
// 0. Nothing to plan with. Asking how to split a goal across flows that
|
|
102
|
+
// don't exist wastes a round trip and suggests memory knows something.
|
|
103
|
+
if (!(await flows.countDocuments({ app: run.app }, { limit: 1 }))) {
|
|
104
|
+
return block(run, `"${run.app}" has no saved flows yet — record one (understudy_record, then understudy_save), or drive it yourself and save the script (understudy_save with script)`);
|
|
105
|
+
}
|
|
101
106
|
// 1. Split the goal.
|
|
102
107
|
if (!planning.subGoals) {
|
|
103
108
|
return ask(run, { kind: 'decompose', goal: run.goal, how: DECOMPOSE_HOW, vocabulary: await vocabulary(run.app) });
|
package/extension/README.md
CHANGED
|
@@ -49,7 +49,7 @@ in the terminal to start recording from there.
|
|
|
49
49
|
will start signed in too. Not sure? Leave it: Understudy copies the tab's
|
|
50
50
|
sign-in anyway, then when you `save` it tries the flow without it first,
|
|
51
51
|
and deletes the copy if it wasn't needed. Either way it's a file on your
|
|
52
|
-
machine (
|
|
52
|
+
machine (`~/.understudy/sessions/`, readable only by you), never sent
|
|
53
53
|
anywhere else.
|
|
54
54
|
4. Use the page as normal. The icon shows **REC**.
|
|
55
55
|
5. Click the icon → say what the flow does → **Stop**. With **Save as a flow
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jeffawe/understudy",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.2",
|
|
4
4
|
"description": "End-to-end tests for your own web apps: record a flow once, and Understudy remembers it, replays it, notices when the app changes, and runs goals you describe in words — on its own or as an MCP server for AI agents.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -42,7 +42,7 @@
|
|
|
42
42
|
"clean": "node -e \"require('fs').rmSync('dist',{recursive:true,force:true})\"",
|
|
43
43
|
"build": "npm run clean && tsc",
|
|
44
44
|
"typecheck": "tsc --noEmit",
|
|
45
|
-
"test": "node --import tsx --test test/*.test.ts",
|
|
45
|
+
"test": "node --import tsx --import ./test/setup.ts --test test/*.test.ts",
|
|
46
46
|
"prepack": "npm run extension:package && npm run build",
|
|
47
47
|
"understudy": "tsx src/entry/cli.ts",
|
|
48
48
|
"mcp": "tsx src/entry/mcp.ts",
|