barebrowse 0.4.8 → 0.5.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/CHANGELOG.md +37 -0
- package/README.md +4 -3
- package/barebrowse.context.md +34 -6
- package/mcp-server.js +38 -1
- package/package.json +4 -1
- package/src/bareagent.js +80 -0
- package/.barebrowse/page-2026-02-23T15-39-32-011Z.yml +0 -1219
- package/.barebrowse/page-2026-02-23T15-40-19-874Z.yml +0 -663
- package/.mcp.json +0 -8
- package/CLAUDE.md +0 -24
- package/baremobile.md +0 -105
- package/docs/00-context/assumptions.md +0 -38
- package/docs/00-context/system-state.md +0 -402
- package/docs/00-context/vision.md +0 -52
- package/docs/01-product/prd.md +0 -308
- package/docs/03-logs/bug-log.md +0 -16
- package/docs/03-logs/decisions-log.md +0 -32
- package/docs/03-logs/implementation-log.md +0 -54
- package/docs/03-logs/insights.md +0 -35
- package/docs/03-logs/validation-log.md +0 -269
- package/docs/04-process/definition-of-done.md +0 -31
- package/docs/04-process/dev-workflow.md +0 -68
- package/docs/04-process/testing.md +0 -242
- package/docs/README.md +0 -56
- package/docs/archive/poc-plan.md +0 -230
- package/docs/skill-template.md +0 -106
package/docs/archive/poc-plan.md
DELETED
|
@@ -1,230 +0,0 @@
|
|
|
1
|
-
# barebrowse — POC Plan
|
|
2
|
-
|
|
3
|
-
**Date:** 2026-02-22
|
|
4
|
-
**Goal:** Prove that an autonomous agent can get an authenticated, pruned ARIA snapshot of any web page via CDP — no Playwright, no bundled browser.
|
|
5
|
-
|
|
6
|
-
---
|
|
7
|
-
|
|
8
|
-
## Repo Structure
|
|
9
|
-
|
|
10
|
-
```
|
|
11
|
-
barebrowse/
|
|
12
|
-
├── src/
|
|
13
|
-
│ ├── index.js # Public API: browse(), connect()
|
|
14
|
-
│ ├── chromium.js # Find/launch/connect to Chromium browsers
|
|
15
|
-
│ ├── cdp.js # Vanilla WebSocket CDP client
|
|
16
|
-
│ ├── aria.js # Accessibility.getFullAXTree → structured tree
|
|
17
|
-
│ ├── auth.js # Cookie extraction + CDP Network.setCookie injection
|
|
18
|
-
│ ├── prune.js # ARIA tree pruning (ported from mcprune)
|
|
19
|
-
│ ├── interact.js # Click, type, scroll via CDP Input domain
|
|
20
|
-
│ ├── consent.js # Auto-dismiss cookie consent dialogs
|
|
21
|
-
│ └── stealth.js # Anti-detection patches via Runtime.evaluate (Phase 4)
|
|
22
|
-
├── test/
|
|
23
|
-
│ ├── integration/
|
|
24
|
-
│ │ ├── browse.test.js # End-to-end: URL → pruned snapshot
|
|
25
|
-
│ │ ├── auth.test.js # Cookie injection → authenticated page
|
|
26
|
-
│ │ └── interact.test.js # Click/type on a live page
|
|
27
|
-
│ └── unit/
|
|
28
|
-
│ ├── cdp.test.js # CDP client message handling
|
|
29
|
-
│ ├── aria.test.js # ARIA tree formatting
|
|
30
|
-
│ └── prune.test.js # Pruning logic on sample trees
|
|
31
|
-
├── docs/
|
|
32
|
-
│ ├── prd.md # Product requirements (comprehensive)
|
|
33
|
-
│ └── poc-plan.md # This file
|
|
34
|
-
├── package.json
|
|
35
|
-
└── CLAUDE.md
|
|
36
|
-
```
|
|
37
|
-
|
|
38
|
-
**No build step.** Vanilla JS, ES modules, runs directly with Node.js >= 22.
|
|
39
|
-
|
|
40
|
-
---
|
|
41
|
-
|
|
42
|
-
## Phases
|
|
43
|
-
|
|
44
|
-
### Phase 1 — CDP + ARIA Foundation
|
|
45
|
-
|
|
46
|
-
**Prove:** Get an ARIA tree from any page via CDP, no Playwright.
|
|
47
|
-
|
|
48
|
-
**Files:**
|
|
49
|
-
- `src/chromium.js` — Find installed Chromium browsers on the system (Chrome, Chromium, Brave, Edge). Launch headless with `--headless=new --remote-debugging-port=<port>`. Parse CDP WebSocket URL from stderr output.
|
|
50
|
-
- `src/cdp.js` — Vanilla WebSocket client that speaks CDP. Send JSON commands, receive responses and events. Handle command IDs, promises, event subscriptions. ~100 lines.
|
|
51
|
-
- `src/aria.js` — Call `Accessibility.getFullAXTree` via CDP. Transform the raw CDP response (flat array of AXNodes with parentId references) into a nested tree structure. Format as readable output.
|
|
52
|
-
- `src/index.js` — Wire chromium → cdp → aria into `browse(url)` function. Minimal, just the pipeline.
|
|
53
|
-
|
|
54
|
-
**Test:**
|
|
55
|
-
```bash
|
|
56
|
-
node -e "import { browse } from './src/index.js'; console.log(await browse('https://example.com'))"
|
|
57
|
-
```
|
|
58
|
-
|
|
59
|
-
**DoD:**
|
|
60
|
-
- [x] `chromium.js` finds and launches at least one Chromium browser on Fedora Linux
|
|
61
|
-
- [x] `cdp.js` connects via WebSocket, sends commands, receives responses
|
|
62
|
-
- [x] `aria.js` returns a structured ARIA tree for any public page
|
|
63
|
-
- [x] `browse(url)` works end-to-end with zero external dependencies
|
|
64
|
-
- [x] Headless Chrome process is cleaned up on close
|
|
65
|
-
|
|
66
|
-
### Phase 2 — Auth + Prune
|
|
67
|
-
|
|
68
|
-
**Prove:** Authenticated, pruned ARIA snapshot of a Cloudflare-protected page.
|
|
69
|
-
|
|
70
|
-
**Files:**
|
|
71
|
-
- `src/auth.js` — Extract cookies from user's browser profile (use sweet-cookie or implement minimal extraction from Chrome's Cookies SQLite DB + Linux keyring decryption via `secret-tool`). Inject via CDP `Network.setCookie` before navigation.
|
|
72
|
-
- `src/prune.js` — Port mcprune's pruning logic as a pure function. Input: raw ARIA tree. Output: pruned ARIA tree. Role-based: keep landmarks + interactive elements, drop noise/structural wrappers.
|
|
73
|
-
- Update `src/index.js` — Add cookie injection and pruning to the `browse()` pipeline.
|
|
74
|
-
|
|
75
|
-
**Test:**
|
|
76
|
-
```bash
|
|
77
|
-
# Should return authenticated content, not a login wall or CF challenge
|
|
78
|
-
node -e "import { browse } from './src/index.js'; console.log(await browse('https://some-cf-protected-site.com'))"
|
|
79
|
-
```
|
|
80
|
-
|
|
81
|
-
**DoD:**
|
|
82
|
-
- [x] `auth.js` extracts cookies from Firefox profile on Linux (also supports Chromium when installed)
|
|
83
|
-
- [x] Cookies injected via CDP before navigation
|
|
84
|
-
- [ ] CF-protected page returns real content, not challenge page (needs active session to test)
|
|
85
|
-
- [x] `prune.js` reduces ARIA tree by 47%+ on HN (minimal site — heavier sites will see 70%+)
|
|
86
|
-
- [x] Pruned output preserves all interactive elements and landmarks
|
|
87
|
-
- [x] `browse(url)` returns pruned, authenticated snapshot by default
|
|
88
|
-
|
|
89
|
-
### Phase 3 — Headed Mode + Interaction
|
|
90
|
-
|
|
91
|
-
**Prove:** Connect to user's running browser and interact with a logged-in page.
|
|
92
|
-
|
|
93
|
-
**Files:**
|
|
94
|
-
- Update `src/chromium.js` — Add `connect()` mode: connect to an already-running browser's debug port instead of launching a new one. Detect running browsers with debug ports.
|
|
95
|
-
- `src/interact.js` — Click (`Input.dispatchMouseEvent`), type (`Input.dispatchKeyEvent`), scroll. Resolve ARIA node IDs to DOM coordinates for click targets.
|
|
96
|
-
- Update `src/index.js` — Add `connect()` export for long-lived sessions. Add `mode: 'headed'` option.
|
|
97
|
-
|
|
98
|
-
**Prerequisite:** User must launch their browser with `--remote-debugging-port=9222` flag.
|
|
99
|
-
|
|
100
|
-
**Test:**
|
|
101
|
-
```bash
|
|
102
|
-
# User has Chrome open with debug port, logged into GitHub
|
|
103
|
-
node -e "
|
|
104
|
-
import { connect } from './src/index.js';
|
|
105
|
-
const page = await connect({ mode: 'headed' });
|
|
106
|
-
await page.goto('https://github.com/notifications');
|
|
107
|
-
console.log(await page.snapshot());
|
|
108
|
-
"
|
|
109
|
-
```
|
|
110
|
-
|
|
111
|
-
**DoD:**
|
|
112
|
-
- [x] `connect()` attaches to a running Chromium browser via CDP
|
|
113
|
-
- [x] Same ARIA + prune pipeline works on headed browser
|
|
114
|
-
- [x] `click()` and `type()` send real input events via CDP
|
|
115
|
-
- [x] `press()` sends special keys (Enter, Tab, Escape, arrows) — triggers form submit
|
|
116
|
-
- [x] `scrollIntoView` before click ensures off-screen elements are reachable
|
|
117
|
-
- [x] `type({ clear: true })` replaces pre-filled input content
|
|
118
|
-
- [x] `waitForNavigation()` waits for page load after link clicks
|
|
119
|
-
- [x] Interactions tested against real sites: Wikipedia, GitHub, Google, Hacker News, DuckDuckGo, YouTube
|
|
120
|
-
- [x] Browser stays open after barebrowse disconnects
|
|
121
|
-
- [x] Cookie injection via `page.injectCookies()` for headed mode (Firefox → Chromium)
|
|
122
|
-
- [x] Permission prompts suppressed via launch flags + CDP `Browser.setPermission`
|
|
123
|
-
- [x] Cookie consent dialogs auto-dismissed across 16+ sites in 7 languages
|
|
124
|
-
- [x] YouTube end-to-end: Firefox cookies → search → click → video playback in headed mode
|
|
125
|
-
|
|
126
|
-
### Phase 4 — Hybrid + bareagent Integration
|
|
127
|
-
|
|
128
|
-
**Prove:** Agent autonomously browses the web using barebrowse tools.
|
|
129
|
-
|
|
130
|
-
**Files:**
|
|
131
|
-
- Update `src/chromium.js` — Add `mode: 'hybrid'`. Try headless first. If navigation returns a CF challenge or 403, automatically retry in headed mode.
|
|
132
|
-
- `src/stealth.js` — Basic anti-detection: patch `navigator.webdriver`, `navigator.plugins`, `window.chrome`. Applied via `Runtime.evaluate` on new page.
|
|
133
|
-
- Update `src/index.js` — Final API surface: `browse()`, `connect()`.
|
|
134
|
-
|
|
135
|
-
**Test:**
|
|
136
|
-
```js
|
|
137
|
-
import { Loop } from 'bare-agent';
|
|
138
|
-
import { browse } from './src/index.js';
|
|
139
|
-
|
|
140
|
-
const tools = [
|
|
141
|
-
{ name: 'browse', execute: ({ url }) => browse(url) },
|
|
142
|
-
];
|
|
143
|
-
|
|
144
|
-
const loop = new Loop({ provider });
|
|
145
|
-
await loop.run([
|
|
146
|
-
{ role: 'user', content: 'Go to hacker news and tell me the top 3 stories' }
|
|
147
|
-
], tools);
|
|
148
|
-
```
|
|
149
|
-
|
|
150
|
-
**DoD:**
|
|
151
|
-
- [ ] Hybrid mode automatically falls back when headless is blocked
|
|
152
|
-
- [ ] Stealth patches reduce headless detection on common sites
|
|
153
|
-
- [ ] bareagent can use `browse()` as a tool in its think/act/observe loop
|
|
154
|
-
- [ ] Agent successfully completes a multi-page research task autonomously
|
|
155
|
-
|
|
156
|
-
---
|
|
157
|
-
|
|
158
|
-
## Definition of Done — Full POC
|
|
159
|
-
|
|
160
|
-
The POC is complete when ALL of these are true:
|
|
161
|
-
|
|
162
|
-
1. **`browse(url)` works end-to-end** — URL in, pruned ARIA snapshot out, authenticated as the user
|
|
163
|
-
2. **Zero heavy deps** — no Playwright, no Puppeteer. Only deps: `ws` (WebSocket client, if Node's built-in isn't sufficient) and optionally `sweet-cookie`
|
|
164
|
-
3. **Three modes work** — headless (default), headed (connect to running browser), hybrid (auto-fallback)
|
|
165
|
-
4. **Works on Fedora Linux** — finds Chrome/Chromium/Brave, launches headless, connects headed
|
|
166
|
-
5. **Token-efficient output** — pruned ARIA tree is 70%+ smaller than raw tree
|
|
167
|
-
6. **Clean process management** — headless browser spawned and killed cleanly, no orphan processes
|
|
168
|
-
7. **Under 1,000 lines total** for core src/ (excluding tests)
|
|
169
|
-
8. **Documented** — PRD captures all decisions, this file captures all phases
|
|
170
|
-
|
|
171
|
-
## What the POC is NOT
|
|
172
|
-
|
|
173
|
-
- Not production-ready. No error recovery, no retry logic, no edge case handling beyond happy path.
|
|
174
|
-
- Not cross-platform tested. Linux first (Fedora). macOS/Windows later.
|
|
175
|
-
- Not an MCP server. That's a future wrapper.
|
|
176
|
-
- Not a published npm package. Local development only.
|
|
177
|
-
|
|
178
|
-
---
|
|
179
|
-
|
|
180
|
-
## Running Tests
|
|
181
|
-
|
|
182
|
-
```bash
|
|
183
|
-
# All tests (47+ tests)
|
|
184
|
-
node --test test/unit/*.test.js test/integration/*.test.js
|
|
185
|
-
|
|
186
|
-
# Unit tests only (fast, no network)
|
|
187
|
-
node --test test/unit/prune.test.js # 16 tests — pruning logic
|
|
188
|
-
node --test test/unit/auth.test.js # 7 tests — cookie extraction (2 fail when Chromium locked)
|
|
189
|
-
node --test test/unit/cdp.test.js # 5 tests — CDP client + browser launch
|
|
190
|
-
|
|
191
|
-
# Integration tests (needs network + Chromium)
|
|
192
|
-
node --test test/integration/browse.test.js # 11 tests — end-to-end pipeline
|
|
193
|
-
node --test test/integration/interact.test.js # 15 tests — interactions on real sites
|
|
194
|
-
|
|
195
|
-
# Quick smoke test
|
|
196
|
-
node -e "import { browse } from './src/index.js'; console.log(await browse('https://example.com'))"
|
|
197
|
-
|
|
198
|
-
# Headed mode demos (requires: chromium-browser --remote-debugging-port=9222)
|
|
199
|
-
node examples/headed-demo.js # Wikipedia → DuckDuckGo search
|
|
200
|
-
node examples/yt-demo.js # YouTube: Firefox cookies → search → play video
|
|
201
|
-
```
|
|
202
|
-
|
|
203
|
-
---
|
|
204
|
-
|
|
205
|
-
## Repos Studied — What We Borrowed vs Built
|
|
206
|
-
|
|
207
|
-
| steipete repo | What we studied | What we used | Why not more |
|
|
208
|
-
|---|---|---|---|
|
|
209
|
-
| **sweet-cookie** | Cookie extraction (SQLite + keyring) | **Concept only** — wrote `auth.js` ourselves | Not on npm (different package). Our version is simpler, tailored, vanilla JS |
|
|
210
|
-
| **sweetlink** | CDP dual-channel, selector discovery, daemon | **CDP-direct concept only** | Daemon + WebSocket bridge + in-page runtime = bloat. CDP direct is 100 lines vs ~2,000 |
|
|
211
|
-
| **canvas** | Stealth/anti-detection patterns | **Noted for Phase 4** `stealth.js` | Not needed yet — headless + real cookies handles most cases |
|
|
212
|
-
| **mcprune (own)** | ARIA pruning pipeline | **Full port** — `prune.js` (472 lines) | Proven code, adapted node format from Playwright YAML to CDP tree objects |
|
|
213
|
-
|
|
214
|
-
### What to explore in later phases
|
|
215
|
-
|
|
216
|
-
- **Selector discovery** (sweetlink) — crawl ARIA tree, score interactive elements, rank action targets. Phase 3/4.
|
|
217
|
-
- **Stealth patches** (canvas) — `navigator.webdriver`, plugins, chrome object spoofing. Phase 4.
|
|
218
|
-
- **In-page JS execution** (sweetlink) — `Runtime.evaluate` for complex interactions. Phase 3.
|
|
219
|
-
- **Screenshot + visual grounding** — `Page.captureScreenshot` for multimodal agents. Post-POC.
|
|
220
|
-
|
|
221
|
-
---
|
|
222
|
-
|
|
223
|
-
## Dev Rules (from AGENT_RULES.md)
|
|
224
|
-
|
|
225
|
-
- **Vanilla JS only.** No TypeScript, no build step, no transpilation.
|
|
226
|
-
- **Dependency hierarchy:** vanilla → stdlib → external. Write it yourself if <50 lines.
|
|
227
|
-
- **Simple > clever.** Readable code a junior can follow.
|
|
228
|
-
- **POC first.** Validate logic before designing. Never ship the POC — rewrite it.
|
|
229
|
-
- **Test behavior, not implementation.** Integration tests over unit tests.
|
|
230
|
-
- **No speculative code.** Every line must have a purpose.
|
package/docs/skill-template.md
DELETED
|
@@ -1,106 +0,0 @@
|
|
|
1
|
-
# Skill Template — Teaching AI Agents to Use CLI Tools
|
|
2
|
-
|
|
3
|
-
A **skill** is a markdown file that teaches a coding agent (Claude Code, etc.) how to use a CLI tool. No code, no dependencies, no scripts — just a markdown file with YAML frontmatter that the agent reads as context.
|
|
4
|
-
|
|
5
|
-
## What's in a skill file
|
|
6
|
-
|
|
7
|
-
```markdown
|
|
8
|
-
---
|
|
9
|
-
name: your-tool
|
|
10
|
-
description: One-liner explaining what the tool does.
|
|
11
|
-
allowed-tools: Bash(your-tool:*)
|
|
12
|
-
---
|
|
13
|
-
|
|
14
|
-
# your-tool — Brief Title
|
|
15
|
-
|
|
16
|
-
One paragraph: what it does, what it's for.
|
|
17
|
-
|
|
18
|
-
## Quick Start
|
|
19
|
-
|
|
20
|
-
\```bash
|
|
21
|
-
your-tool init # Setup
|
|
22
|
-
your-tool do-thing # Core action
|
|
23
|
-
your-tool status # Check state
|
|
24
|
-
your-tool cleanup # Teardown
|
|
25
|
-
\```
|
|
26
|
-
|
|
27
|
-
## Commands
|
|
28
|
-
|
|
29
|
-
| Command | Description |
|
|
30
|
-
|---------|-------------|
|
|
31
|
-
| `your-tool init` | ... |
|
|
32
|
-
| `your-tool do-thing <arg>` | ... |
|
|
33
|
-
| `your-tool status` | ... |
|
|
34
|
-
| `your-tool cleanup` | ... |
|
|
35
|
-
|
|
36
|
-
## Output Format
|
|
37
|
-
|
|
38
|
-
Describe what the tool outputs and where (stdout, files, etc.)
|
|
39
|
-
Show a real example so the agent knows what to expect.
|
|
40
|
-
|
|
41
|
-
## Workflow Pattern
|
|
42
|
-
|
|
43
|
-
1. Step one
|
|
44
|
-
2. Step two
|
|
45
|
-
3. Repeat as needed
|
|
46
|
-
4. Clean up
|
|
47
|
-
|
|
48
|
-
## Tips
|
|
49
|
-
|
|
50
|
-
- Gotchas, edge cases, best practices
|
|
51
|
-
- Things the agent should always/never do
|
|
52
|
-
```
|
|
53
|
-
|
|
54
|
-
## Frontmatter fields
|
|
55
|
-
|
|
56
|
-
| Field | Required | What it does |
|
|
57
|
-
|-------|----------|--------------|
|
|
58
|
-
| `name` | Yes | Tool identifier. Shown in Claude's skill list. |
|
|
59
|
-
| `description` | Yes | One-liner. Shown when Claude lists available skills. |
|
|
60
|
-
| `allowed-tools` | Yes | Auto-grants Bash permission. `Bash(your-tool:*)` means any command starting with `your-tool`. |
|
|
61
|
-
|
|
62
|
-
## How to install
|
|
63
|
-
|
|
64
|
-
The skill file is just a `.md` file placed where the agent can find it:
|
|
65
|
-
|
|
66
|
-
**Claude Code:** `.claude/skills/your-tool/` (project) or `~/.claude/skills/your-tool/` (global).
|
|
67
|
-
|
|
68
|
-
**Other agents:** `.your-tool/commands/` (project) or `~/.config/your-tool/commands/` (global).
|
|
69
|
-
|
|
70
|
-
Non-Claude agents ignore the YAML frontmatter — they just read it as markdown context. The `allowed-tools` field is Claude Code specific.
|
|
71
|
-
|
|
72
|
-
## What the skill does NOT do
|
|
73
|
-
|
|
74
|
-
- Does not install the CLI tool — `npm install` (or equivalent) is still required
|
|
75
|
-
- Does not run any code — it's pure documentation
|
|
76
|
-
- Does not replace MCP — it's an alternative integration path (see below)
|
|
77
|
-
|
|
78
|
-
## Skill vs MCP
|
|
79
|
-
|
|
80
|
-
| | Skill (CLI) | MCP Server |
|
|
81
|
-
|---|---|---|
|
|
82
|
-
| **What it is** | Markdown file teaching the agent CLI commands | Long-running JSON-RPC process |
|
|
83
|
-
| **How agent calls it** | `bash` tool with shell commands | Native tool calls via MCP protocol |
|
|
84
|
-
| **State** | Tool manages its own state (daemon, files, etc.) | MCP server holds state in memory |
|
|
85
|
-
| **Install** | Copy a `.md` file | Register server in config JSON |
|
|
86
|
-
| **Deps at runtime** | CLI tool must be installed (`npm install`) | CLI tool must be installed (`npx` or global) |
|
|
87
|
-
| **Works with** | Claude Code (+ any agent that reads project docs) | Any MCP client (Claude Desktop, Cursor, VS Code, etc.) |
|
|
88
|
-
| **Pros** | Simple, debuggable, no process management | Structured schemas, wide MCP client support |
|
|
89
|
-
| **Cons** | Agent needs Bash access, less structured | Extra process, protocol overhead |
|
|
90
|
-
|
|
91
|
-
Both require the underlying tool to be installed. Choose based on your agent's capabilities.
|
|
92
|
-
|
|
93
|
-
## Example: barebrowse
|
|
94
|
-
|
|
95
|
-
barebrowse ships its skill at `commands/barebrowse/SKILL.md`:
|
|
96
|
-
|
|
97
|
-
```bash
|
|
98
|
-
# Claude Code — project
|
|
99
|
-
cp node_modules/barebrowse/commands/barebrowse/SKILL.md .claude/skills/barebrowse/SKILL.md
|
|
100
|
-
|
|
101
|
-
# Claude Code — global
|
|
102
|
-
barebrowse install --skill
|
|
103
|
-
|
|
104
|
-
# Other agents — project or global
|
|
105
|
-
cp node_modules/barebrowse/commands/barebrowse/SKILL.md .barebrowse/commands/SKILL.md
|
|
106
|
-
```
|