pi-browser-use 0.3.3 → 0.4.1
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 +73 -14
- package/dist/annotate.d.ts +27 -0
- package/dist/annotate.d.ts.map +1 -0
- package/dist/annotate.js +73 -0
- package/dist/annotate.js.map +1 -0
- package/dist/doctor.d.ts +22 -0
- package/dist/doctor.d.ts.map +1 -0
- package/dist/doctor.js +53 -0
- package/dist/doctor.js.map +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +52 -7
- package/dist/index.js.map +1 -1
- package/package.json +2 -1
- package/skills/derive-client/SKILL.md +37 -0
- package/skills/dogfood/SKILL.md +28 -0
package/README.md
CHANGED
|
@@ -34,32 +34,65 @@ Settings key is `pi-browser-use` in `~/.pi/agent/settings.json` (user) or `.pi/s
|
|
|
34
34
|
|
|
35
35
|
| Mode | Config | Behavior |
|
|
36
36
|
| --------------- | --------------------------------------- | ------------------------------------------------------ |
|
|
37
|
-
| Fresh (default) | `isolated` + `headless: true` | Ephemeral profile, no window
|
|
37
|
+
| Fresh (default) | `isolated` + `headless: true` | Ephemeral profile, no window, never steals focus |
|
|
38
38
|
| Authenticated | `sessionMode: persistent` | Shared profile, log in once, headed windows pop |
|
|
39
39
|
| Existing | `sessionMode: existing` + `autoConnect` | Drives your daily Chrome — intrusive, avoid by default |
|
|
40
40
|
|
|
41
|
-
|
|
41
|
+
All browser behavior plus the policy skill in one install; `.pi/settings.json` is purely for overrides.
|
|
42
|
+
|
|
43
|
+
### Full option reference
|
|
44
|
+
|
|
45
|
+
| Option | Type | Default | Description |
|
|
46
|
+
| ---------------------- | ---------- | ---------- | ------------------------------------------------------------------------------ |
|
|
47
|
+
| `sessionMode` | `string` | `isolated` | `persistent`, `isolated`, or `existing` |
|
|
48
|
+
| `headless` | `boolean` | `true` | No window at all (the only true hide on macOS) |
|
|
49
|
+
| `channel` | `string` | — | `canary`, `dev`, `beta`, `stable` |
|
|
50
|
+
| `browserUrl` | `string` | — | Attach to a running debuggable Chrome via HTTP URL |
|
|
51
|
+
| `wsEndpoint` | `string` | — | Attach via DevTools WebSocket endpoint |
|
|
52
|
+
| `executablePath` | `string` | — | Custom Chrome executable |
|
|
53
|
+
| `viewport` | `string` | — | Initial viewport, e.g. `1280x720` |
|
|
54
|
+
| `userDataDir` | `string` | — | Custom profile dir (persistent mode defaults to `~/.pi/browser-profile`) |
|
|
55
|
+
| `autoConnect` | `boolean` | `false` | Auto-attach to a local running Chrome (implies `existing`) |
|
|
56
|
+
| `chromeArgs` | `string[]` | — | First-class Chrome flags, forwarded as `--chrome-arg=` |
|
|
57
|
+
| `extraArgs` | `string[]` | — | Raw escape hatch, forwarded verbatim to `chrome-devtools-mcp` |
|
|
58
|
+
| `visionModel` | `object` | — | `{ provider, model }` from Pi's registry; enables `browser_analyze_screenshot` |
|
|
59
|
+
| `allowedUrlPattern` | `string[]` | — | Cage navigation to matching URL patterns |
|
|
60
|
+
| `blockedUrlPattern` | `string[]` | — | Block matching URL patterns (mutually exclusive with allow) |
|
|
61
|
+
| `redactNetworkHeaders` | `boolean` | `true` | Strip sensitive headers from network results |
|
|
62
|
+
| `acceptInsecureCerts` | `boolean` | `false` | Ignore self-signed/expired certificates |
|
|
63
|
+
|
|
64
|
+
First-class `chromeArgs` only apply when `chrome-devtools-mcp` launches Chrome itself — never with `autoConnect`/`browserUrl`. On macOS `--start-minimized` is ignored; only `headless: true` truly hides the window.
|
|
42
65
|
|
|
43
66
|
Hosts where `process.execPath` is not a directly executable Node runtime can set `PI_BROWSER_USE_NODE` to the Node command used for the MCP subprocess.
|
|
44
67
|
|
|
45
|
-
##
|
|
68
|
+
## Tools
|
|
46
69
|
|
|
47
|
-
|
|
70
|
+
Upstream `chrome-devtools-mcp` tools are proxied as `browser_*` (navigation, snapshot, click/fill/hover/drag/type, emulation, console, network, screenshots, dialogs, uploads, waits). Noisy, slow, or privileged ones (`lighthouse_audit`, performance traces, screencast, extension management) are excluded. On top, this package adds:
|
|
48
71
|
|
|
49
|
-
|
|
72
|
+
### `browser_save_artifact`
|
|
50
73
|
|
|
51
|
-
|
|
74
|
+
Writes a screenshot or the rendered HTML to disk (default `~/.pi/browser-artifacts/`) and returns the path. Prefer it over inline captures for evidence, visual QA, and artifact sharing.
|
|
52
75
|
|
|
53
|
-
|
|
76
|
+
With `annotate: true`, screenshots get numbered badges over interactive elements plus a coordinate map for coordinate click tools — badges are removed after capture:
|
|
54
77
|
|
|
55
|
-
-
|
|
56
|
-
- `playwright-handoff` — when to stop clicking and run a repo Playwright spec instead (npm-first, bun alternatives, no repo changes required).
|
|
57
|
-
- `triage-console` — snapshot → console errors → failed network → screenshot.
|
|
58
|
-
- `visual-qa` — viewport matrix and canvas/WebGL discipline.
|
|
78
|
+

|
|
59
79
|
|
|
60
|
-
|
|
80
|
+
```text
|
|
81
|
+
browser_save_artifact({ "pageId": 1, "kind": "screenshot", "annotate": true })
|
|
82
|
+
# Saved screenshot to ~/.pi/browser-artifacts/page-....png
|
|
83
|
+
# Annotated elements:
|
|
84
|
+
# 1: (342, 49) a "Home"
|
|
85
|
+
# 2: (394, 49) a "Docs"
|
|
86
|
+
# 6: (394, 298) button "Create workspace"
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
### `browser_doctor`
|
|
90
|
+
|
|
91
|
+
Self-diagnostics: effective mode, whether this session launches its own Chrome, profile health, and upstream tool availability. Run it first when browser tools misbehave — it touches no pages.
|
|
61
92
|
|
|
62
|
-
|
|
93
|
+
### `browser_analyze_screenshot`
|
|
94
|
+
|
|
95
|
+
Vision analysis for canvas/WebGL scenes and coordinate clicks the accessibility tree cannot describe. Enabled only when `visionModel` is configured (see below); credentials resolve from Pi's model registry automatically.
|
|
63
96
|
|
|
64
97
|
```json
|
|
65
98
|
{
|
|
@@ -69,12 +102,38 @@ Enable `browser_analyze_screenshot` by referencing a model already configured in
|
|
|
69
102
|
}
|
|
70
103
|
```
|
|
71
104
|
|
|
72
|
-
|
|
105
|
+
## Page-scoped tools
|
|
106
|
+
|
|
107
|
+
Call `browser_list_pages` first, then pass its numeric `pageId` to page-scoped tools. Click-family calls blocked by an overlay are retried once automatically after dismissing it with Escape; stale element references get a refresh hint. See `skills/browser-policy/SKILL.md` for the full agent policy.
|
|
73
108
|
|
|
74
109
|
## Browser profile
|
|
75
110
|
|
|
76
111
|
On startup the default persistent profile is checked for accessibility. A root-owned or unreadable default (typically from running under `sudo`) is moved aside to `~/.pi/browser-profile.inaccessible-<timestamp>` so Chrome starts fresh instead of showing a preferences dialog. An explicit custom `userDataDir` in the same state fails fast with an ownership remediation hint. Never run the agent (or anything launching this browser) via `sudo`.
|
|
77
112
|
|
|
113
|
+
## Performance
|
|
114
|
+
|
|
115
|
+
`npm run bench` times the tool stack headless over 5 iterations (fixture setup excluded, matching vercel-labs/agent-browser's scenario set). Baseline on Apple Silicon: navigate ~1ms, snapshot ~3ms, screenshot ~37ms, evaluate ~206ms, full agent-loop cycle ~422ms. Re-run on your hardware before quoting numbers.
|
|
116
|
+
|
|
117
|
+
## Bundled skills
|
|
118
|
+
|
|
119
|
+
- `browser-policy` — CLI-first decision order, session modes, bot-wall and safety rules.
|
|
120
|
+
- `playwright-handoff` — when to stop clicking and run a repo Playwright spec instead (npm-first, bun alternatives, no repo changes required).
|
|
121
|
+
- `triage-console` — snapshot → console errors → failed network → screenshot.
|
|
122
|
+
- `visual-qa` — viewport matrix and canvas/WebGL discipline, including the annotate flow.
|
|
123
|
+
- `derive-client` — turn repeated flows into standalone fetch clients; stop driving solved problems.
|
|
124
|
+
- `dogfood` — charter-based exploratory bug hunts with severity discipline.
|
|
125
|
+
|
|
126
|
+
## Troubleshooting
|
|
127
|
+
|
|
128
|
+
| Symptom | Likely cause | Fix |
|
|
129
|
+
| ---------------------------------- | --------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------ |
|
|
130
|
+
| Chrome windows pop and steal focus | Headed mode (`headless: false`, `persistent`, or `existing`) | Switch to fresh headless defaults; on macOS no flag hides a headed window |
|
|
131
|
+
| `--chrome-arg` has no effect | Attached session (`autoConnect`/`browserUrl`) — flags only apply to MCP-launched Chrome | Move to `isolated`/`persistent` mode |
|
|
132
|
+
| Login wall / Turnstile loop | Bot check needs a human | Solve once in the persistent profile, then continue; never retry-loop a challenge |
|
|
133
|
+
| `profile is already in use` | Two sessions sharing one `userDataDir` | Use isolated mode or separate dirs per session |
|
|
134
|
+
| Stale uid errors | Page re-rendered after your snapshot | Take a fresh snapshot; ids invalidate on every action |
|
|
135
|
+
| Vision tool missing | No `visionModel` configured | Add it; otherwise use tree uids, or the global `vision` skill for vision-less models |
|
|
136
|
+
|
|
78
137
|
## License
|
|
79
138
|
|
|
80
139
|
MIT
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Numbered-badge annotation for screenshots (adapted from the technique
|
|
3
|
+
* popularized by vercel-labs/agent-browser).
|
|
4
|
+
*
|
|
5
|
+
* Badges are injected around visible interactive elements, screenshotted,
|
|
6
|
+
* then removed. The returned coordinate map pairs each badge number with a
|
|
7
|
+
* viewport center point for coordinate click tools, plus a short label so
|
|
8
|
+
* vision models can resolve "click the blue submit button" to (x, y).
|
|
9
|
+
*/
|
|
10
|
+
export interface AnnotatedElement {
|
|
11
|
+
n: number;
|
|
12
|
+
x: number;
|
|
13
|
+
y: number;
|
|
14
|
+
tag: string;
|
|
15
|
+
text: string;
|
|
16
|
+
}
|
|
17
|
+
export declare const ANNOTATE_MARKER = "data-pi-annotate";
|
|
18
|
+
export declare const INJECT_ANNOTATIONS = "() => {\n document.querySelectorAll('[data-pi-annotate]').forEach((el) => el.remove());\n const els = [...document.querySelectorAll('a, button, input, select, textarea, [role=\"button\"], [role=\"link\"], [role=\"checkbox\"], [role=\"switch\"]')].filter((el) => {\n const r = el.getBoundingClientRect();\n return r.width > 0 && r.height > 0 && r.top >= 0 && r.left >= 0 && r.top < window.innerHeight && r.left < window.innerWidth;\n }).slice(0, 50);\n return els.map((el, i) => {\n const r = el.getBoundingClientRect();\n const badge = document.createElement('div');\n badge.setAttribute('data-pi-annotate', '1');\n badge.textContent = String(i + 1);\n badge.style.cssText = 'position:fixed;left:' + r.left + 'px;top:' + r.top + 'px;z-index:2147483647;background:#7c3aed;color:#fff;font:12px/1.4 monospace;padding:1px 5px;border-radius:3px;pointer-events:none;';\n document.body.appendChild(badge);\n const label = el.innerText || el.value || el.getAttribute('aria-label') || el.getAttribute('placeholder') || '';\n return { n: i + 1, x: Math.round(r.left + r.width / 2), y: Math.round(r.top + r.height / 2), tag: el.tagName.toLowerCase(), text: String(label).replace(/\\s+/g, ' ').slice(0, 60) };\n });\n}";
|
|
19
|
+
export declare const CLEANUP_ANNOTATIONS = "() => {\n const badges = document.querySelectorAll('[data-pi-annotate]');\n const count = badges.length;\n badges.forEach((el) => el.remove());\n return count;\n}";
|
|
20
|
+
/**
|
|
21
|
+
* Upstream evaluate_script wraps results as prose around a ```json fence.
|
|
22
|
+
* Extract the payload array robustly.
|
|
23
|
+
*/
|
|
24
|
+
export declare function parseAnnotatedElements(text: string): AnnotatedElement[];
|
|
25
|
+
/** Render the coordinate map as compact text for tool results. */
|
|
26
|
+
export declare function formatAnnotatedMap(elements: AnnotatedElement[]): string;
|
|
27
|
+
//# sourceMappingURL=annotate.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"annotate.d.ts","sourceRoot":"","sources":["../src/annotate.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,MAAM,WAAW,gBAAgB;IAC/B,CAAC,EAAE,MAAM,CAAA;IACT,CAAC,EAAE,MAAM,CAAA;IACT,CAAC,EAAE,MAAM,CAAA;IACT,GAAG,EAAE,MAAM,CAAA;IACX,IAAI,EAAE,MAAM,CAAA;CACb;AAED,eAAO,MAAM,eAAe,qBAAqB,CAAA;AAEjD,eAAO,MAAM,kBAAkB,8tCAgB7B,CAAA;AAEF,eAAO,MAAM,mBAAmB,2KAK9B,CAAA;AAEF;;;GAGG;AACH,wBAAgB,sBAAsB,CAAC,IAAI,EAAE,MAAM,GAAG,gBAAgB,EAAE,CA0BvE;AAED,kEAAkE;AAClE,wBAAgB,kBAAkB,CAAC,QAAQ,EAAE,gBAAgB,EAAE,GAAG,MAAM,CAKvE"}
|
package/dist/annotate.js
ADDED
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Numbered-badge annotation for screenshots (adapted from the technique
|
|
3
|
+
* popularized by vercel-labs/agent-browser).
|
|
4
|
+
*
|
|
5
|
+
* Badges are injected around visible interactive elements, screenshotted,
|
|
6
|
+
* then removed. The returned coordinate map pairs each badge number with a
|
|
7
|
+
* viewport center point for coordinate click tools, plus a short label so
|
|
8
|
+
* vision models can resolve "click the blue submit button" to (x, y).
|
|
9
|
+
*/
|
|
10
|
+
export const ANNOTATE_MARKER = 'data-pi-annotate';
|
|
11
|
+
export const INJECT_ANNOTATIONS = `() => {
|
|
12
|
+
document.querySelectorAll('[${ANNOTATE_MARKER}]').forEach((el) => el.remove());
|
|
13
|
+
const els = [...document.querySelectorAll('a, button, input, select, textarea, [role="button"], [role="link"], [role="checkbox"], [role="switch"]')].filter((el) => {
|
|
14
|
+
const r = el.getBoundingClientRect();
|
|
15
|
+
return r.width > 0 && r.height > 0 && r.top >= 0 && r.left >= 0 && r.top < window.innerHeight && r.left < window.innerWidth;
|
|
16
|
+
}).slice(0, 50);
|
|
17
|
+
return els.map((el, i) => {
|
|
18
|
+
const r = el.getBoundingClientRect();
|
|
19
|
+
const badge = document.createElement('div');
|
|
20
|
+
badge.setAttribute('${ANNOTATE_MARKER}', '1');
|
|
21
|
+
badge.textContent = String(i + 1);
|
|
22
|
+
badge.style.cssText = 'position:fixed;left:' + r.left + 'px;top:' + r.top + 'px;z-index:2147483647;background:#7c3aed;color:#fff;font:12px/1.4 monospace;padding:1px 5px;border-radius:3px;pointer-events:none;';
|
|
23
|
+
document.body.appendChild(badge);
|
|
24
|
+
const label = el.innerText || el.value || el.getAttribute('aria-label') || el.getAttribute('placeholder') || '';
|
|
25
|
+
return { n: i + 1, x: Math.round(r.left + r.width / 2), y: Math.round(r.top + r.height / 2), tag: el.tagName.toLowerCase(), text: String(label).replace(/\\s+/g, ' ').slice(0, 60) };
|
|
26
|
+
});
|
|
27
|
+
}`;
|
|
28
|
+
export const CLEANUP_ANNOTATIONS = `() => {
|
|
29
|
+
const badges = document.querySelectorAll('[${ANNOTATE_MARKER}]');
|
|
30
|
+
const count = badges.length;
|
|
31
|
+
badges.forEach((el) => el.remove());
|
|
32
|
+
return count;
|
|
33
|
+
}`;
|
|
34
|
+
/**
|
|
35
|
+
* Upstream evaluate_script wraps results as prose around a ```json fence.
|
|
36
|
+
* Extract the payload array robustly.
|
|
37
|
+
*/
|
|
38
|
+
export function parseAnnotatedElements(text) {
|
|
39
|
+
const start = text.indexOf('[');
|
|
40
|
+
const end = text.lastIndexOf(']');
|
|
41
|
+
if (start === -1 || end === -1 || end <= start)
|
|
42
|
+
return [];
|
|
43
|
+
try {
|
|
44
|
+
const parsed = JSON.parse(text.slice(start, end + 1));
|
|
45
|
+
if (!Array.isArray(parsed))
|
|
46
|
+
return [];
|
|
47
|
+
return parsed
|
|
48
|
+
.filter((item) => typeof item === 'object' &&
|
|
49
|
+
item !== null &&
|
|
50
|
+
typeof item.n === 'number' &&
|
|
51
|
+
typeof item.x === 'number' &&
|
|
52
|
+
typeof item.y === 'number')
|
|
53
|
+
.map((item) => ({
|
|
54
|
+
n: item.n,
|
|
55
|
+
x: item.x,
|
|
56
|
+
y: item.y,
|
|
57
|
+
tag: typeof item.tag === 'string' ? item.tag : '',
|
|
58
|
+
text: typeof item.text === 'string' ? item.text : '',
|
|
59
|
+
}));
|
|
60
|
+
}
|
|
61
|
+
catch {
|
|
62
|
+
return [];
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
/** Render the coordinate map as compact text for tool results. */
|
|
66
|
+
export function formatAnnotatedMap(elements) {
|
|
67
|
+
if (elements.length === 0)
|
|
68
|
+
return 'No interactive elements annotated.';
|
|
69
|
+
return elements
|
|
70
|
+
.map((el) => `${el.n}: (${el.x}, ${el.y}) ${el.tag}${el.text ? ` "${el.text}"` : ''}`)
|
|
71
|
+
.join('\n');
|
|
72
|
+
}
|
|
73
|
+
//# sourceMappingURL=annotate.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"annotate.js","sourceRoot":"","sources":["../src/annotate.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAUH,MAAM,CAAC,MAAM,eAAe,GAAG,kBAAkB,CAAA;AAEjD,MAAM,CAAC,MAAM,kBAAkB,GAAG;gCACF,eAAe;;;;;;;;0BAQrB,eAAe;;;;;;;EAOvC,CAAA;AAEF,MAAM,CAAC,MAAM,mBAAmB,GAAG;+CACY,eAAe;;;;EAI5D,CAAA;AAEF;;;GAGG;AACH,MAAM,UAAU,sBAAsB,CAAC,IAAY;IACjD,MAAM,KAAK,GAAG,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,CAAA;IAC/B,MAAM,GAAG,GAAG,IAAI,CAAC,WAAW,CAAC,GAAG,CAAC,CAAA;IACjC,IAAI,KAAK,KAAK,CAAC,CAAC,IAAI,GAAG,KAAK,CAAC,CAAC,IAAI,GAAG,IAAI,KAAK;QAAE,OAAO,EAAE,CAAA;IACzD,IAAI,CAAC;QACH,MAAM,MAAM,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,KAAK,EAAE,GAAG,GAAG,CAAC,CAAC,CAAY,CAAA;QAChE,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC;YAAE,OAAO,EAAE,CAAA;QACrC,OAAO,MAAM;aACV,MAAM,CACL,CAAC,IAAI,EAA4B,EAAE,CACjC,OAAO,IAAI,KAAK,QAAQ;YACxB,IAAI,KAAK,IAAI;YACb,OAAQ,IAAyB,CAAC,CAAC,KAAK,QAAQ;YAChD,OAAQ,IAAyB,CAAC,CAAC,KAAK,QAAQ;YAChD,OAAQ,IAAyB,CAAC,CAAC,KAAK,QAAQ,CACnD;aACA,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC;YACd,CAAC,EAAE,IAAI,CAAC,CAAC;YACT,CAAC,EAAE,IAAI,CAAC,CAAC;YACT,CAAC,EAAE,IAAI,CAAC,CAAC;YACT,GAAG,EAAE,OAAO,IAAI,CAAC,GAAG,KAAK,QAAQ,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE;YACjD,IAAI,EAAE,OAAO,IAAI,CAAC,IAAI,KAAK,QAAQ,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE;SACrD,CAAC,CAAC,CAAA;IACP,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,EAAE,CAAA;IACX,CAAC;AACH,CAAC;AAED,kEAAkE;AAClE,MAAM,UAAU,kBAAkB,CAAC,QAA4B;IAC7D,IAAI,QAAQ,CAAC,MAAM,KAAK,CAAC;QAAE,OAAO,oCAAoC,CAAA;IACtE,OAAO,QAAQ;SACZ,GAAG,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,GAAG,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,CAAC,KAAK,EAAE,CAAC,CAAC,KAAK,EAAE,CAAC,GAAG,GAAG,EAAE,CAAC,IAAI,CAAC,CAAC,CAAC,KAAK,EAAE,CAAC,IAAI,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC;SACrF,IAAI,CAAC,IAAI,CAAC,CAAA;AACf,CAAC"}
|
package/dist/doctor.d.ts
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { type BrowserUseConfig } from './config.js';
|
|
2
|
+
export interface DoctorReport {
|
|
3
|
+
mode: string;
|
|
4
|
+
headless: boolean;
|
|
5
|
+
launchesChrome: boolean;
|
|
6
|
+
profile: {
|
|
7
|
+
dir: string | null;
|
|
8
|
+
exists: boolean;
|
|
9
|
+
writable: boolean;
|
|
10
|
+
};
|
|
11
|
+
endpoint: string | null;
|
|
12
|
+
upstreamTools: number;
|
|
13
|
+
node: string;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Self-diagnostics for the browser setup: effective mode, whether this
|
|
17
|
+
* session launches its own Chrome or attaches elsewhere, profile health,
|
|
18
|
+
* and upstream tool availability. No pages touched.
|
|
19
|
+
*/
|
|
20
|
+
export declare function diagnose(config: BrowserUseConfig, listToolNames: () => Promise<string[]>): Promise<DoctorReport>;
|
|
21
|
+
export declare function formatDoctorReport(report: DoctorReport, home?: string): string;
|
|
22
|
+
//# sourceMappingURL=doctor.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"doctor.d.ts","sourceRoot":"","sources":["../src/doctor.ts"],"names":[],"mappings":"AAEA,OAAO,EAAuB,KAAK,gBAAgB,EAAE,MAAM,aAAa,CAAA;AAExE,MAAM,WAAW,YAAY;IAC3B,IAAI,EAAE,MAAM,CAAA;IACZ,QAAQ,EAAE,OAAO,CAAA;IACjB,cAAc,EAAE,OAAO,CAAA;IACvB,OAAO,EAAE;QAAE,GAAG,EAAE,MAAM,GAAG,IAAI,CAAC;QAAC,MAAM,EAAE,OAAO,CAAC;QAAC,QAAQ,EAAE,OAAO,CAAA;KAAE,CAAA;IACnE,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAA;IACvB,aAAa,EAAE,MAAM,CAAA;IACrB,IAAI,EAAE,MAAM,CAAA;CACb;AAcD;;;;GAIG;AACH,wBAAsB,QAAQ,CAC5B,MAAM,EAAE,gBAAgB,EACxB,aAAa,EAAE,MAAM,OAAO,CAAC,MAAM,EAAE,CAAC,GACrC,OAAO,CAAC,YAAY,CAAC,CAcvB;AAED,wBAAgB,kBAAkB,CAAC,MAAM,EAAE,YAAY,EAAE,IAAI,GAAE,MAAkB,GAAG,MAAM,CAmBzF"}
|
package/dist/doctor.js
ADDED
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { accessSync, constants, existsSync } from 'node:fs';
|
|
2
|
+
import { homedir } from 'node:os';
|
|
3
|
+
import { DEFAULT_PROFILE_DIR } from './config.js';
|
|
4
|
+
function profileStatus(dir) {
|
|
5
|
+
if (!dir)
|
|
6
|
+
return { exists: false, writable: false };
|
|
7
|
+
const exists = existsSync(dir);
|
|
8
|
+
if (!exists)
|
|
9
|
+
return { exists, writable: true };
|
|
10
|
+
try {
|
|
11
|
+
accessSync(dir, constants.R_OK | constants.W_OK);
|
|
12
|
+
return { exists, writable: true };
|
|
13
|
+
}
|
|
14
|
+
catch {
|
|
15
|
+
return { exists, writable: false };
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Self-diagnostics for the browser setup: effective mode, whether this
|
|
20
|
+
* session launches its own Chrome or attaches elsewhere, profile health,
|
|
21
|
+
* and upstream tool availability. No pages touched.
|
|
22
|
+
*/
|
|
23
|
+
export async function diagnose(config, listToolNames) {
|
|
24
|
+
const launchesChrome = !config.browserUrl && !config.wsEndpoint && !config.autoConnect;
|
|
25
|
+
const dir = config.userDataDir ?? (config.sessionMode === 'persistent' ? DEFAULT_PROFILE_DIR : null);
|
|
26
|
+
return {
|
|
27
|
+
mode: config.sessionMode ?? 'isolated',
|
|
28
|
+
headless: config.headless ?? true,
|
|
29
|
+
launchesChrome,
|
|
30
|
+
profile: { dir, ...profileStatus(dir) },
|
|
31
|
+
endpoint: config.browserUrl ?? config.wsEndpoint ?? (config.autoConnect ? 'auto-discovered' : null),
|
|
32
|
+
upstreamTools: (await listToolNames()).length,
|
|
33
|
+
node: process.version,
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
export function formatDoctorReport(report, home = homedir()) {
|
|
37
|
+
const lines = [
|
|
38
|
+
`Mode: ${report.mode} (headless: ${report.headless ? 'yes' : 'no'})`,
|
|
39
|
+
report.launchesChrome
|
|
40
|
+
? 'Chrome: launched by chrome-devtools-mcp for this session.'
|
|
41
|
+
: `Chrome: attached externally (${report.endpoint ?? 'unknown endpoint'}). Launch flags do not apply.`,
|
|
42
|
+
];
|
|
43
|
+
if (report.profile.dir) {
|
|
44
|
+
const display = report.profile.dir.replace(home, '~');
|
|
45
|
+
lines.push(`Profile: ${display} (exists: ${report.profile.exists ? 'yes' : 'no'}, writable: ${report.profile.writable ? 'yes' : 'NO — check ownership'}).`);
|
|
46
|
+
}
|
|
47
|
+
else {
|
|
48
|
+
lines.push('Profile: ephemeral (nothing persists between sessions).');
|
|
49
|
+
}
|
|
50
|
+
lines.push(`Upstream tools: ${report.upstreamTools} (prefix browser_). Node: ${report.node}.`);
|
|
51
|
+
return lines.join('\n');
|
|
52
|
+
}
|
|
53
|
+
//# sourceMappingURL=doctor.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"doctor.js","sourceRoot":"","sources":["../src/doctor.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,SAAS,CAAA;AAC3D,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAA;AACjC,OAAO,EAAE,mBAAmB,EAAyB,MAAM,aAAa,CAAA;AAYxE,SAAS,aAAa,CAAC,GAAkB;IACvC,IAAI,CAAC,GAAG;QAAE,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,QAAQ,EAAE,KAAK,EAAE,CAAA;IACnD,MAAM,MAAM,GAAG,UAAU,CAAC,GAAG,CAAC,CAAA;IAC9B,IAAI,CAAC,MAAM;QAAE,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAA;IAC9C,IAAI,CAAC;QACH,UAAU,CAAC,GAAG,EAAE,SAAS,CAAC,IAAI,GAAG,SAAS,CAAC,IAAI,CAAC,CAAA;QAChD,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAA;IACnC,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,EAAE,MAA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G,EAAE,CAAC;QACvB,MAAM,OAAO,GAAG,MAAM,CAAC,OAAO,CAAC,GAAG,CAAC,OAAO,CAAC,IAAI,EAAE,GAAG,CAAC,CAAA;QACrD,KAAK,CAAC,IAAI,CACR,YAAY,OAAO,aAAa,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,eAClE,MAAM,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,sBACpC,IAAI,CACL,CAAA;IACH,CAAC;SAAM,CAAC;QACN,KAAK,CAAC,IAAI,CAAC,yDAAyD,CAAC,CAAA;IACvE,CAAC;IACD,KAAK,CAAC,IAAI,CAAC,mBAAmB,MAAM,CAAC,aAAa,6BAA6B,MAAM,CAAC,IAAI,GAAG,CAAC,CAAA;IAC9F,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;AACzB,CAAC"}
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AA6BA,OAAO,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,aAAa,CAAA;AAkCzD,UAAU,aAAa;IACrB,IAAI,CAAC,QAAQ,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,OAAO,CAAA;IAChD,mBAAmB,CACjB,KAAK,EAAE,OAAO,GACb,OAAO,CACR;QAAE,EAAE,EAAE,IAAI,CAAC;QAAC,MAAM,CAAC,EAAE,MAAM,CAAC;QAAC,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;KAAE,GAAG;QAAE,EAAE,EAAE,KAAK,CAAC;QAAC,KAAK,EAAE,MAAM,CAAA;KAAE,CAC/F,CAAA;CACF;AAED,UAAU,aAAa;IACrB,aAAa,CAAC,EAAE,aAAa,CAAA;CAC9B;AAED,UAAU,EAAE;IACV,YAAY,CAAC,GAAG,EAAE;QAChB,IAAI,EAAE,MAAM,CAAA;QACZ,KAAK,EAAE,MAAM,CAAA;QACb,WAAW,EAAE,MAAM,CAAA;QACnB,UAAU,EAAE,OAAO,CAAA;QACnB,OAAO,EAAE,CACP,UAAU,EAAE,MAAM,EAClB,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAC/B,MAAM,CAAC,EAAE,WAAW,EACpB,QAAQ,CAAC,EAAE,OAAO,EAClB,GAAG,CAAC,EAAE,aAAa,KAChB,OAAO,CAAC;YACX,OAAO,EAAE,KAAK,CAAC;gBAAE,IAAI,EAAE,MAAM,CAAC;gBAAC,IAAI,CAAC,EAAE,MAAM,CAAC;gBAAC,IAAI,CAAC,EAAE,MAAM,CAAC;gBAAC,QAAQ,CAAC,EAAE,MAAM,CAAA;aAAE,CAAC,CAAA;YACjF,OAAO,CAAC,EAAE,OAAO,CAAA;YACjB,OAAO,CAAC,EAAE,SAAS,CAAA;SACpB,CAAC,CAAA;KACH,GAAG,IAAI,CAAA;IACR,EAAE,CACA,KAAK,EAAE,MAAM,EACb,OAAO,EAAE,CAAC,KAAK,EAAE,OAAO,EAAE,GAAG,EAAE;QAAE,GAAG,EAAE,MAAM,CAAA;KAAE,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,KAAK,OAAO,CAAC,IAAI,CAAC,GACzF,IAAI,CAAA;CACR;AA8BD;;;;;;;;GAQG;AACH,MAAM,CAAC,OAAO,UAAU,mBAAmB,CAAC,EAAE,EAAE,EAAE,QAyOjD"}
|
package/dist/index.js
CHANGED
|
@@ -7,6 +7,8 @@ import { resolveConfig } from './config.js';
|
|
|
7
7
|
import { isProjectTrusted, loadConfig } from './settings.js';
|
|
8
8
|
import { augmentToolDescription, extractTextContent, looksOverlayBlocked, OVERLAY_RECOVERABLE, postProcessToolResult, } from './tool-augment.js';
|
|
9
9
|
import { pickImageData, resolveArtifactTarget } from './artifacts.js';
|
|
10
|
+
import { CLEANUP_ANNOTATIONS, formatAnnotatedMap, INJECT_ANNOTATIONS, parseAnnotatedElements, } from './annotate.js';
|
|
11
|
+
import { diagnose, formatDoctorReport } from './doctor.js';
|
|
10
12
|
import { prepareBrowserProfile } from './profile.js';
|
|
11
13
|
import { createRegistryVisionCaller, handleAnalyzeScreenshot, } from './vision.js';
|
|
12
14
|
export { configToArgs, resolveConfig } from './config.js';
|
|
@@ -118,6 +120,9 @@ export default function browserUseExtension(pi) {
|
|
|
118
120
|
path: Type.Optional(Type.String({
|
|
119
121
|
description: 'Absolute destination path. Defaults to ~/.pi/browser-artifacts/<timestamp>.<png|html>.',
|
|
120
122
|
})),
|
|
123
|
+
annotate: Type.Optional(Type.Boolean({
|
|
124
|
+
description: 'Screenshots only: overlay numbered badges on interactive elements and return their coordinate map for coordinate click tools. Badges are removed after capture.',
|
|
125
|
+
})),
|
|
121
126
|
};
|
|
122
127
|
if (config?.experimentalPageIdRouting === true) {
|
|
123
128
|
properties.pageId = Type.Number({
|
|
@@ -154,19 +159,58 @@ export default function browserUseExtension(pi) {
|
|
|
154
159
|
};
|
|
155
160
|
}
|
|
156
161
|
const shotArgs = pageId === undefined ? {} : { pageId };
|
|
157
|
-
const
|
|
158
|
-
const
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
162
|
+
const evalArgs = pageId === undefined ? {} : { pageId };
|
|
163
|
+
const wantAnnotations = params.annotate === true && kind === 'screenshot';
|
|
164
|
+
let annotatedMap = '';
|
|
165
|
+
try {
|
|
166
|
+
if (wantAnnotations) {
|
|
167
|
+
const injected = (await browser.callTool('evaluate_script', {
|
|
168
|
+
...evalArgs,
|
|
169
|
+
function: INJECT_ANNOTATIONS,
|
|
170
|
+
}, signal));
|
|
171
|
+
annotatedMap = formatAnnotatedMap(parseAnnotatedElements(extractTextContent(injected.content)));
|
|
172
|
+
}
|
|
173
|
+
const shot = (await browser.callTool('take_screenshot', shotArgs, signal));
|
|
174
|
+
const image = pickImageData(shot.content);
|
|
175
|
+
if (!image)
|
|
176
|
+
throw new Error('Screenshot came back without image data.');
|
|
177
|
+
mkdirSync(dirname(target), { recursive: true });
|
|
178
|
+
writeFileSync(target, Buffer.from(image.data, 'base64'));
|
|
179
|
+
}
|
|
180
|
+
finally {
|
|
181
|
+
if (wantAnnotations) {
|
|
182
|
+
try {
|
|
183
|
+
await browser.callTool('evaluate_script', {
|
|
184
|
+
...evalArgs,
|
|
185
|
+
function: CLEANUP_ANNOTATIONS,
|
|
186
|
+
}, signal);
|
|
187
|
+
}
|
|
188
|
+
catch {
|
|
189
|
+
// Badges are pointer-events:none and harmless if cleanup fails.
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
const suffix = annotatedMap ? `\nAnnotated elements:\n${annotatedMap}` : '';
|
|
163
194
|
return {
|
|
164
|
-
content: [{ type: 'text', text: `Saved screenshot to ${target}` }],
|
|
195
|
+
content: [{ type: 'text', text: `Saved screenshot to ${target}${suffix}` }],
|
|
165
196
|
details: undefined,
|
|
166
197
|
};
|
|
167
198
|
},
|
|
168
199
|
});
|
|
169
200
|
}
|
|
201
|
+
function registerDoctorTool() {
|
|
202
|
+
pi.registerTool({
|
|
203
|
+
name: `${TOOL_PREFIX}doctor`,
|
|
204
|
+
label: `${TOOL_PREFIX}doctor`,
|
|
205
|
+
description: 'Diagnose the browser setup: effective mode, whether this session launches its own Chrome, profile health, and upstream tool availability. Run this first when browser tools misbehave. Touches no pages.',
|
|
206
|
+
parameters: Type.Object({}),
|
|
207
|
+
async execute() {
|
|
208
|
+
await ensureConnected();
|
|
209
|
+
const report = await diagnose(config ?? {}, async () => (await client.listAllTools()).map((tool) => tool.name));
|
|
210
|
+
return { content: [{ type: 'text', text: formatDoctorReport(report) }], details: undefined };
|
|
211
|
+
},
|
|
212
|
+
});
|
|
213
|
+
}
|
|
170
214
|
async function registerVisionTool(visionConfig) {
|
|
171
215
|
const properties = {
|
|
172
216
|
instruction: Type.Optional(Type.String({
|
|
@@ -202,6 +246,7 @@ export default function browserUseExtension(pi) {
|
|
|
202
246
|
client = new DevToolsClient(config);
|
|
203
247
|
await registerUpstreamTools();
|
|
204
248
|
registerSaveArtifactTool();
|
|
249
|
+
registerDoctorTool();
|
|
205
250
|
if (config.visionModel) {
|
|
206
251
|
await registerVisionTool(config.visionModel);
|
|
207
252
|
}
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,aAAa,EAAE,MAAM,SAAS,CAAA;AAClD,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAA;AACjC,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAA;AACzC,OAAO,EAAE,IAAI,EAAgB,MAAM,SAAS,CAAA;AAC5C,OAAO,EAAE,cAAc,EAAE,MAAM,aAAa,CAAA;AAC5C,OAAO,EAAE,aAAa,EAAyB,MAAM,aAAa,CAAA;AAClE,OAAO,EAAE,gBAAgB,EAAE,UAAU,EAAE,MAAM,eAAe,CAAA;AAC5D,OAAO,EACL,sBAAsB,EACtB,kBAAkB,EAClB,mBAAmB,EACnB,mBAAmB,EACnB,qBAAqB,GACtB,MAAM,mBAAmB,CAAA;AAC1B,OAAO,EAAE,aAAa,EAAE,qBAAqB,EAAqB,MAAM,gBAAgB,CAAA;AACxF,OAAO,EAAE,qBAAqB,EAAE,MAAM,cAAc,CAAA;AACpD,OAAO,EACL,0BAA0B,EAC1B,uBAAuB,GAExB,MAAM,aAAa,CAAA;AAEpB,OAAO,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,aAAa,CAAA;AAEzD,gFAAgF;AAChF,MAAM,WAAW,GAAG,UAAU,CAAA;AAO9B,KAAK,UAAU,YAAY,CAC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,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pi-browser-use",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.4.1",
|
|
4
4
|
"description": "Opinionated browser-use for the Pi coding agent, powered by chrome-devtools-mcp (not Playwright). Fresh headless by default, authenticated persistent profile opt-in, CLI-first policy bundled.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"pi-package",
|
|
@@ -55,6 +55,7 @@
|
|
|
55
55
|
"format:check": "prettier --check .",
|
|
56
56
|
"typecheck": "tsc -p tsconfig.json --noEmit",
|
|
57
57
|
"prepublishOnly": "npm run build",
|
|
58
|
+
"bench": "node scripts/bench.mjs",
|
|
58
59
|
"test": "node --test test/*.test.mjs",
|
|
59
60
|
"pretest": "npm run build"
|
|
60
61
|
},
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: derive-client
|
|
3
|
+
description: "Turn observed browser traffic into a standalone API client. Use when a task repeats the same site interactions and should stop driving the browser — record the network calls, then replace clicks with fetch."
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Derive API Client
|
|
7
|
+
|
|
8
|
+
Browser automation is for discovery; repetition belongs in code. When you catch yourself performing the same flow twice, derive the client:
|
|
9
|
+
|
|
10
|
+
## 1. Record
|
|
11
|
+
|
|
12
|
+
Drive the flow once via `browser_*`, then capture what actually happened:
|
|
13
|
+
|
|
14
|
+
```text
|
|
15
|
+
browser_list_network_requests({ "pageId": <id> })
|
|
16
|
+
browser_get_network_request({ "pageId": <id>, "reqid": "<id>" })
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
Keep only the requests that matter (auth, data mutations, queries). Ignore analytics, beacons, and preflights.
|
|
20
|
+
|
|
21
|
+
## 2. Extract
|
|
22
|
+
|
|
23
|
+
For each kept request, note method, URL (parameterize IDs and tokens), headers (keep `authorization`/`content-type`, drop browser fingerprints like `user-agent`/`sec-ch-*`), and body shape. `browser_get_network_request` redacts sensitive headers in output — re-add secrets from the agent's credential source at runtime, never hardcode them.
|
|
24
|
+
|
|
25
|
+
## 3. Emit
|
|
26
|
+
|
|
27
|
+
Write a minimal client (fetch, one function per endpoint, base URL + auth injected). Verify it reproduces the flow end to end, then delete the browser steps from the runbook.
|
|
28
|
+
|
|
29
|
+
## 4. Graduate
|
|
30
|
+
|
|
31
|
+
If the client is used more than twice, it does not belong in chat history — commit it to the repo (or a scripts dir) with the base URL and auth from environment. The browser path stays as the documented fallback for when the API drifts.
|
|
32
|
+
|
|
33
|
+
## Do not derive
|
|
34
|
+
|
|
35
|
+
- Flows behind Turnstile/bot checks per-request (the browser session is the bypass; code is not).
|
|
36
|
+
- Real-time socket protocols on the first pass — poll the REST surface first.
|
|
37
|
+
- Anything the site's terms reserve for interactive use.
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: dogfood
|
|
3
|
+
description: "Exploratory testing playbook for bug hunts and quality passes. Use when asked to dogfood, poke at, or break a site — tour it with intent instead of clicking around."
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Dogfood Tour
|
|
7
|
+
|
|
8
|
+
Exploratory testing with charters, not random clicking. Timebox: 30 minutes per charter, then report.
|
|
9
|
+
|
|
10
|
+
## Charters (pick one per run)
|
|
11
|
+
|
|
12
|
+
- **First-run**: fresh isolated session, no logins. Can a stranger complete the core flow?
|
|
13
|
+
- **Return user**: persistent profile, existing state. Does yesterday's data render correctly today?
|
|
14
|
+
- **Hostile input**: long strings, emoji, empty submits, rapid double-clicks, back-button mid-flow.
|
|
15
|
+
- **Small screen**: 390px wide. Overlaps, clipped actions, unreachable buttons.
|
|
16
|
+
- **Flaky network**: DevTools emulation throttling (see `browser_emulate`). Skeletons, retries, stuck spinners.
|
|
17
|
+
|
|
18
|
+
## Rules
|
|
19
|
+
|
|
20
|
+
1. One charter at a time; note which charter each finding came from.
|
|
21
|
+
2. Every finding needs: charter, repro steps (3 max), expected vs actual, artifact path via `browser_save_artifact`.
|
|
22
|
+
3. Console triage applies (`triage-console`) — a finding with a console error attached outranks one without.
|
|
23
|
+
4. Stop at crashes, data loss, or auth bypasses; report immediately, do not keep touring.
|
|
24
|
+
5. End with the top 3, not top 30. Severity beats inventory.
|
|
25
|
+
|
|
26
|
+
## Out of scope
|
|
27
|
+
|
|
28
|
+
Performance numbers (that's a benchmark, not a bug hunt), copy Voice (flag once, move on), and third-party outages (verify on a second network before filing).
|