browserforce 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,123 @@
1
+ ---
2
+ name: browserforce
3
+ description: Browse the web using the user's real Chrome browser — already logged in, with real cookies and extensions. No headless browser. Uses BrowserForce relay + Playwright API via CLI.
4
+ read_when:
5
+ - Browsing as the user with logged-in sessions
6
+ - Accessing sites that require authentication
7
+ - Interacting with the user's real Chrome tabs
8
+ - Web automation with existing cookies and extensions
9
+ - Taking screenshots of authenticated pages
10
+ metadata: {"clawdbot":{"emoji":"🔌","requires":{"bins":["node","browserforce"]},"install":[{"kind":"node","package":"browserforce","bins":["browserforce"],"label":"Install BrowserForce CLI"}]}}
11
+ allowed-tools: Bash(browserforce:*)
12
+ ---
13
+
14
+ # BrowserForce — Your Real Chrome Browser
15
+
16
+ BrowserForce gives you the user's actual Chrome browser — all their logins,
17
+ cookies, and extensions already active. No headless browser, no fresh profiles.
18
+
19
+ ## Prerequisites
20
+
21
+ The user must have:
22
+ 1. BrowserForce relay running: `browserforce serve`
23
+ 2. BrowserForce Chrome extension installed and connected (green icon)
24
+
25
+ Check with: `browserforce status`
26
+
27
+ ## Quick Reference
28
+
29
+ ```bash
30
+ browserforce status # Check relay + extension status
31
+ browserforce tabs # List open tabs
32
+ browserforce snapshot [n] # Accessibility tree of tab n
33
+ browserforce screenshot [n] # Screenshot tab n (PNG to stdout)
34
+ browserforce navigate <url> # Open URL in new tab
35
+ browserforce -e "<code>" # Run Playwright JavaScript (one-shot)
36
+ ```
37
+
38
+ ## Important: One-Shot Execution
39
+
40
+ Each `browserforce -e` call is independent — state does NOT persist between calls.
41
+ Do everything you need (navigate, act, observe) within a single `-e` call.
42
+
43
+ ## Core Workflow: Observe → Act → Observe
44
+
45
+ ### Quick observation (no code needed)
46
+ ```bash
47
+ browserforce snapshot 0 # See what's on tab 0
48
+ browserforce tabs # List all tabs
49
+ ```
50
+
51
+ ### Navigate and read a page
52
+ ```bash
53
+ browserforce -e "
54
+ state.page = await context.newPage();
55
+ await state.page.goto('https://example.com');
56
+ await waitForPageLoad();
57
+ return await snapshot();
58
+ "
59
+ ```
60
+
61
+ Note: `snapshot()` reads from `state.page` (if set) or `page` (default tab 0).
62
+ Always assign `state.page` when creating a new page so `snapshot()` reads the right tab.
63
+
64
+ ### Click and verify
65
+ ```bash
66
+ browserforce -e "
67
+ state.page = context.pages()[context.pages().length - 1];
68
+ await state.page.locator('role=button[name=\"Next\"]').click();
69
+ await waitForPageLoad();
70
+ return await snapshot();
71
+ "
72
+ ```
73
+
74
+ ### Fill a form
75
+ ```bash
76
+ browserforce -e "
77
+ state.page = context.pages()[context.pages().length - 1];
78
+ await state.page.locator('role=textbox[name=\"Email\"]').fill('user@example.com');
79
+ return await snapshot();
80
+ "
81
+ ```
82
+
83
+ ### Extract data
84
+ ```bash
85
+ browserforce -e "
86
+ const p = context.pages()[context.pages().length - 1];
87
+ return await p.evaluate(() => document.querySelector('.price').textContent);
88
+ "
89
+ ```
90
+
91
+ ### Screenshot
92
+ ```bash
93
+ browserforce screenshot 0 > page.png
94
+ # or via -e:
95
+ browserforce -e "
96
+ state.page = context.pages()[0];
97
+ return await state.page.screenshot();
98
+ " > page.png
99
+ ```
100
+
101
+ ## Rules
102
+
103
+ 1. **snapshot() over screenshot()** — snapshot returns text (fast, cheap).
104
+ Use screenshot only for visual layout verification.
105
+ 2. **One-shot execution** — each -e call is independent. Do all steps in one call.
106
+ 3. **Don't navigate existing tabs** — create your own via `context.newPage()`
107
+ or `browserforce navigate <url>`.
108
+ 4. **Use convenience commands** for simple operations: `browserforce tabs`,
109
+ `browserforce snapshot`, `browserforce screenshot`.
110
+ 5. **waitForPageLoad()** — call after navigation or clicks that trigger page loads.
111
+
112
+ ## Error Recovery
113
+
114
+ - Connection lost: User must check `browserforce status`
115
+ - No tabs: `browserforce navigate https://example.com`
116
+ - Element not found: `browserforce -e "return await snapshot({ search: 'button' })"`
117
+
118
+ ## Important
119
+
120
+ This is the user's REAL browser. Be respectful:
121
+ - Don't close tabs you didn't open
122
+ - Don't navigate tabs you didn't create
123
+ - Don't modify browser settings or stored data