chromeflow 0.1.0 → 0.1.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/CLAUDE.md +102 -0
- package/dist/index.js +12 -625
- package/dist/setup.js +202 -0
- package/dist/tools/browser.js +70 -0
- package/dist/tools/capture.js +119 -0
- package/dist/tools/flow.js +133 -0
- package/dist/tools/highlight.js +84 -0
- package/dist/types.js +0 -0
- package/dist/ws-bridge.js +104 -0
- package/package.json +7 -5
package/CLAUDE.md
ADDED
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
# Chromeflow — Claude Instructions
|
|
2
|
+
|
|
3
|
+
## What chromeflow is
|
|
4
|
+
Chromeflow is a browser guidance tool. When a task requires the user to interact with a
|
|
5
|
+
website (create accounts, set up billing, retrieve API keys, configure third-party services),
|
|
6
|
+
use chromeflow to guide them through it visually instead of giving text instructions.
|
|
7
|
+
|
|
8
|
+
## When to use chromeflow (be proactive)
|
|
9
|
+
Use chromeflow automatically whenever a task requires:
|
|
10
|
+
- Creating or configuring a third-party account (Stripe, SendGrid, Supabase, Vercel, etc.)
|
|
11
|
+
- Retrieving API keys, secrets, or credentials to place in `.env`
|
|
12
|
+
- Setting up pricing tiers, webhooks, or service configuration in a web UI
|
|
13
|
+
- Any browser-based step that is blocking code work
|
|
14
|
+
|
|
15
|
+
Do NOT ask "should I open the browser?" — just do it. The user expects seamless handoff.
|
|
16
|
+
|
|
17
|
+
**Never end a response with a "you still need to" list of browser tasks.** If code changes are done and browser steps remain (e.g. creating a Stripe product, adding an env var), continue immediately with chromeflow — don't hand them back to the user.
|
|
18
|
+
|
|
19
|
+
## HARD RULES — never break these
|
|
20
|
+
|
|
21
|
+
1. **Never use Bash as a fallback for browser tasks.** If `click_element` fails, use
|
|
22
|
+
`scroll_page` then retry, or use `highlight_region` to show the user. Never use
|
|
23
|
+
`osascript`, `applescript`, or any shell command to control the browser.
|
|
24
|
+
|
|
25
|
+
2. **`take_screenshot` is only for pixel-position lookups before `highlight_region`.** Every
|
|
26
|
+
other state check — after navigation, after a click, after `wait_for_click`, to confirm an
|
|
27
|
+
action succeeded — must use `get_page_text` or `wait_for_selector`. Never take a screenshot
|
|
28
|
+
as a "let me see what's on screen" step. Correct order: try `click_element` → if it fails,
|
|
29
|
+
THEN `take_screenshot` → `highlight_region`. Never screenshot preemptively.
|
|
30
|
+
|
|
31
|
+
3. **`open_page` already waits for navigation.** Never call `wait_for_navigation`
|
|
32
|
+
immediately after `open_page` — it will time out.
|
|
33
|
+
|
|
34
|
+
4. **When `click_element` fails:** first try `scroll_page(down)` then retry
|
|
35
|
+
`click_element`. If it still fails, `take_screenshot` and use `highlight_region`
|
|
36
|
+
with pixel coordinates from the image.
|
|
37
|
+
|
|
38
|
+
5. **Use `wait_for_selector` to wait for async page changes** (build completion, modals,
|
|
39
|
+
toasts). Never poll with repeated `take_screenshot` calls.
|
|
40
|
+
|
|
41
|
+
## Guided flow pattern
|
|
42
|
+
|
|
43
|
+
```
|
|
44
|
+
1. show_guide_panel(title, steps[]) — show the full plan upfront
|
|
45
|
+
2. open_page(url) — navigate to the right page
|
|
46
|
+
3. For each step:
|
|
47
|
+
a. Claude acts directly:
|
|
48
|
+
click_element("Save") — press buttons/links Claude can press
|
|
49
|
+
fill_input("Product name", "Pro") — fill fields Claude knows the answer to
|
|
50
|
+
scroll_page("down") — reveal off-screen content then retry
|
|
51
|
+
b. Check results with text, not vision:
|
|
52
|
+
get_page_text() — read errors/status after actions
|
|
53
|
+
wait_for_selector(".success") — wait for async changes (builds, modals)
|
|
54
|
+
execute_script("document.title") — query DOM state programmatically
|
|
55
|
+
c. Only take a screenshot when click_element failed and you need pixel coords:
|
|
56
|
+
click_element("Save") — try this first, ALWAYS
|
|
57
|
+
[if fails] take_screenshot() — now get coords, not before
|
|
58
|
+
highlight_region(x,y,w,h,msg) — point user to exact location
|
|
59
|
+
[after wait_for_click] get_page_text() — confirm result, NOT take_screenshot
|
|
60
|
+
d. Pause for the user when needed:
|
|
61
|
+
find_and_highlight(text, msg) — show the user what to do
|
|
62
|
+
wait_for_click() — wait for user interaction
|
|
63
|
+
e. mark_step_done(i) — check off the step
|
|
64
|
+
4. clear_overlays() — clean up when done
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
**Default to automation.** Only pause for human input when the step genuinely requires
|
|
68
|
+
personal data or a human decision.
|
|
69
|
+
|
|
70
|
+
## What to do automatically vs pause for the user
|
|
71
|
+
|
|
72
|
+
**Claude acts directly** (`click_element` / `fill_input`):
|
|
73
|
+
- Any button: Save, Continue, Create, Add, Confirm, Next, Submit, Update
|
|
74
|
+
- Product names, descriptions, feature lists
|
|
75
|
+
- Prices and amounts specified in the task
|
|
76
|
+
- URLs, redirect URIs, webhook endpoints
|
|
77
|
+
- Selecting billing period, currency, or other known options
|
|
78
|
+
- Dismissing cookie banners, cookie dialogs, "not now" prompts
|
|
79
|
+
|
|
80
|
+
**Pause for the user** (`find_and_highlight` + `wait_for_click`):
|
|
81
|
+
- Email address / username / login
|
|
82
|
+
- Password or passphrase
|
|
83
|
+
- Payment method / billing / card details
|
|
84
|
+
- Phone number / 2FA / OTP codes
|
|
85
|
+
- Any legal consent the user must personally accept
|
|
86
|
+
- Choices that depend on user preference Claude wasn't told
|
|
87
|
+
|
|
88
|
+
## Capturing credentials
|
|
89
|
+
After a secret key or API key is revealed:
|
|
90
|
+
1. `read_element(hint)` — capture the value
|
|
91
|
+
2. `write_to_env(KEY_NAME, value, envPath)` — write to `.env`
|
|
92
|
+
3. Tell the user what was written
|
|
93
|
+
|
|
94
|
+
Use the absolute path for `envPath` — it's the Claude Code working directory + `/.env`.
|
|
95
|
+
|
|
96
|
+
## Error handling
|
|
97
|
+
- After any action → `get_page_text()` to check for errors (not `take_screenshot`)
|
|
98
|
+
- `click_element` not found → `scroll_page("down")` then retry
|
|
99
|
+
- Still not found → `take_screenshot()` then `highlight_region(x,y,w,h,msg)`
|
|
100
|
+
- `fill_input` not found → `click_element(hint)` to focus the field, then retry `fill_input`. If still failing, `take_screenshot()` then `highlight_region(x,y,w,h,"Type: [value]")` — do NOT ask the user to type unless all automated attempts have failed
|
|
101
|
+
- Waiting for async result (build, save, deploy) → `wait_for_selector(selector, timeout)`
|
|
102
|
+
- Never use Bash to work around a stuck browser interaction
|