72 Commits

Author SHA1 Message Date
yan5xu 15661ba276 chore: bump extension version to 0.4.1
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
v0.4.1
2026-03-14 22:19:54 +08:00
yan5xu cb28e815aa feat(cli): add --mcp flag to start MCP server
`bb-browser --mcp` spawns the MCP server with stdio transport.
Users can configure AI tools with: npx -y bb-browser --mcp

Also fixes root tsup bundling to properly exclude ws while
bundling all other deps (MCP SDK, ajv, zod).

Bump version to 0.4.1.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-14 22:15:33 +08:00
yan5xu eb62804e1f chore: prepare v0.4.0 for npm publish
- Bump version to 0.4.0
- Add MCP runtime deps (ajv, ajv-formats, @modelcontextprotocol/sdk)
- Bundle all deps in root tsup for npx compatibility
- Fix repo URL to epiral/bb-browser
- Add mcp keyword

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-14 22:03:32 +08:00
yan5xu 537e5536f9 feat(mcp): add MCP server for AI agent integration
New package @bb-browser/mcp exposes all browser commands as MCP tools:
browser_snapshot, browser_click, browser_fill, browser_type, browser_open,
browser_tab_list, browser_tab_new, browser_press, browser_scroll,
browser_eval, browser_network, browser_screenshot, browser_get,
browser_close, browser_hover, browser_wait

All tools support `tab` parameter for concurrent multi-tab operations.
Uses stdio transport, connects to daemon via HTTP (same as CLI).

Also adds missing fields to shared protocol types:
- Request: key, modifiers, direction, pixels, waitType, ms
- ResponseData: dataUrl

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-14 21:59:22 +08:00
yan5xu c3fa112624 fix(cli): daemon command works in npm-published layout
Replace broken `import("@bb-browser/daemon")` with `spawn(getDaemonPath())`
so `bb-browser daemon` works both in dev monorepo and npm install scenarios.

- Export getDaemonPath() from daemon-manager
- daemon command uses spawn with stdio: "inherit" for foreground mode
- Pass --host flag through to daemon process

Fixes #6, fixes #10

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-14 21:49:39 +08:00
yan5xu a882809abc fix(cli): --tab flag works correctly for all commands
- parseArgs: remove `&& !result.command` guard so --tab value is not
  leaked into command args (e.g. network filter)
- site: respect --tab, stop calling tab_select (no foreground steal)
- fetch: stop calling tab_select (no foreground steal)
- site --json: wrap output in standard {id, success, data} envelope

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-14 21:46:42 +08:00
yan5xu 50d7558742 docs: split README into English + Chinese files
- README.md: English (default)
- README.zh-CN.md: Chinese
- Cross-linked via header

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-14 21:25:12 +08:00
yan5xu 0d33a84a0e docs: rewrite README — BadBoy Browser, bilingual, new capabilities
- Rename narrative: bb = BadBoy Browser
- Tagline: "Your browser is the API. No keys. No bots. No scrapers."
- Add fetch, site, network --with-body to command reference
- Bilingual: English (default) + Chinese section
- Reframe positioning: not automation, not scraping — being the browser

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-14 21:23:15 +08:00
yan5xu a2e1f29daa feat: network requests --with-body captures full request/response data
Via CDP Network.loadingFinished + Network.getResponseBody, capture:
- Request headers and body (POST data)
- Response headers, body, and mimeType
- Memory management: 256KB/response, 64KB/request, 8MB/tab total
- Eviction: oldest bodies removed first when over budget
- Graceful error handling: bodyError field for failed captures

This enables a new paradigm for site adapters: instead of reverse-engineering
API signing (like Xiaohongshu's X-s), just navigate to a page and read the
response bodies from requests the page already made with proper authentication.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-14 20:44:22 +08:00
yan5xu f63a1f4c9d refactor: recipe → site, fix Codex review criticals
Rename:
- recipe.ts → site.ts, command `recipe` → `site`
- bb-recipes → bb-sites, ~/.bb-browser/bb-recipes → bb-sites

Codex review fixes (fetch.ts):
- Fix headers injection: validate as JSON instead of string interpolation
- Fix origin matching: exact hostname comparison instead of includes()
- Fix method normalization: toUpperCase() + exclude HEAD from body
- Fix JSON parse on 204: skip resp.json() for empty responses
- Remove duplicate --json/non-json output branches

Codex review fixes (site.ts):
- Parse /* @meta JSON */ block comment format (with @tag fallback)
- Structured args: required/optional per-arg, skip optional in validation
- Fix arg parsing: separate --flag values from positional args
- Fix tab routing: exact origin match via URL parsing
- Capture tabId from new tab and pass to eval
- Surface adapter {error, hint} as CLI errors instead of normal output

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-14 17:16:14 +08:00
yan5xu 56684707da feat: add fetch and recipe commands
- `bb-browser fetch <url>`: browser-native fetch with auto same-origin tab routing.
  Like curl but with browser login state. No API keys, no anti-bot.

- `bb-browser recipe`: manage and run community/private fetch recipes.
  - recipe list: scan ~/.bb-browser/recipes/ (local) and ~/.bb-browser/bb-recipes/ (community)
  - recipe search <query>: keyword search across recipes
  - recipe run <name> [args]: execute a recipe via eval
  - recipe update: git clone/pull community recipes from epiral/bb-recipes
  - recipe <name> [args]: shorthand for recipe run

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-14 16:54:09 +08:00
yan5xu 4eea8e5880 fix(daemon): allow positional args in parseArgs for CLI passthrough
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-11 16:45:18 +08:00
yan5xu 3a69040bf7 feat(daemon): add --host flag to configure listen address
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-11 16:45:13 +08:00
Yanwu 9095463988 Merge pull request #5 from epiral/feature/4-ax-tree-snapshot
feat: 切换 snapshot 到 CDP Accessibility Tree
v0.3.0
2026-02-13 20:03:16 +08:00
yan5xu 4e85c29728 chore: bump version to 0.3.0
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-02-13 20:03:04 +08:00
yan5xu 2bc77bcf17 fix: interactive 模式去掉 /url: 和子节点,扁平输出
interactive 模式目的是找元素交互,不需要 URL 和子节点文本。
GitHub 页面 interactive 从 259 行降到 140 行,和 agent-browser (122 行) 接近。

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-02-13 20:02:08 +08:00
yan5xu e66256a138 feat: 切换 snapshot 到 CDP Accessibility Tree
- 新增 ax-tree-formatter.ts:将 CDP AXNode[] 格式化为语义化 accessibility 树文本
- cdp-dom-service.ts:getSnapshot 改用 Accessibility.getFullAXTree,元素操作改用 backendDOMNodeId
- 支持新参数:--compact/-c(移除空结构节点)、--depth/-d(限制树深度)、--selector/-s(CSS 范围)
- link 内联 /url:,heading 标记 [level=N],重复元素标记 [nth=N]
- GitHub 页面 snapshot 从 56KB 降到 31KB(-45%)

Closes #4

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-02-13 19:55:34 +08:00
yan5xu 77c8e668bd chore: bump version to 0.2.0 v0.2.0 2026-02-07 09:54:13 +08:00
Yanwu 44761b8748 Merge pull request #3 from yan5xu/feature/upstream-url
feat: 插件支持配置上游 URL + 修改后立即重连
2026-02-07 09:50:12 +08:00
yan5xu e67e69fc33 fix: 选项页修改 URL 后立即重连 SSE 2026-02-07 09:45:29 +08:00
yan5xu aec5221473 docs: 措辞润色 — 收紧标题和开头 2026-02-06 20:46:09 +08:00
yan5xu 1aa6fcadfd docs: 重写 README — 双模式说明、Playwright 对比、修正技术栈、Epiral 集成 2026-02-06 20:33:06 +08:00
yan5xu ca78b457f3 feat: 插件支持配置上游 URL
- 新增 options page (options.html + options.ts)
- 上游 URL 存储到 chrome.storage.sync
- sse-client.ts / api-client.ts 从 storage 动态读取 URL
- 默认值保持 http://localhost:19824 兼容

Closes #2
2026-02-06 18:28:46 +08:00
yan5xu 7acd596073 feat: 全局 --tab 参数支持多 tab 并发隔离
- CLI: 全局 --tab <tabId> 参数,透传给所有子命令
- Extension: resolveTab() 按 tabId 定位目标 tab,fallback activeTab
- Extension: 状态 (refs/frame) 按 tabId 隔离
- Extension: SSE 去除 await,支持并发处理命令
- bump version to 0.1.2
2026-02-06 10:41:41 +08:00
yan5xu d046b2e601 chore: 同步 extension manifest 版本号到 0.1.1 2026-02-06 09:44:26 +08:00
yan5xu 1fc42dc990 chore: bump version to 0.1.1 2026-02-06 09:35:57 +08:00
yan5xu 1acfb6031b feat: tab select/close 支持按 tabId 操作
- 协议 Request 新增 tabId 字段(优先于 index,向下兼容)
- Extension handleTabSelect/handleTabClose 支持 tabId 直接定位
- CLI 新增 tab select --id <tabId> 和 tab close --id <tabId> 语法
- 解决多调用方共用时 index 重编号导致的 tab 错位问题
2026-02-06 09:35:33 +08:00
yan5xu a7c9ce2058 chore: 添加构建产物到 gitignore v0.1.0 2026-01-31 11:56:36 +08:00
yan5xu 67bfe2ac9a chore: 更新仓库地址为 yan5xu/bb-browser 2026-01-31 11:56:15 +08:00
yan5xu 2c83c9fc45 docs: SKILL.md 添加信息提取 vs 页面操作指南
- eval 提取长文本(微信公众号、知乎等)
- snapshot -i 用于页面操作
- 解释为什么某些网站 snapshot 输出冗长
2026-01-30 19:50:23 +08:00
yan5xu 7998184000 docs: 优化 SKILL.md 强调信息获取能力 2026-01-30 18:52:53 +08:00
yan5xu a284d7d904 docs: 添加 bb-browser skills 文档
- SKILL.md: 命令速查、Tab 管理规范、工作流程
- references/snapshot-refs.md: Ref 生命周期和最佳实践

核心定位:代替用户执行重复的浏览器操作
2026-01-30 18:28:44 +08:00
yan5xu 4c7c64f8ba fix: 解决 MV3 Service Worker 休眠导致连接断开的问题
- 添加 chrome.alarms 保活机制(每 24 秒唤醒)
- 使用 chrome.storage.session 持久化 refs(防止休眠后丢失)
- 心跳间隔从 30s 改为 15s
- 添加 storage 和 alarms 权限
2026-01-30 18:12:42 +08:00
yan5xu 9582e1034a feat: open 命令支持 --tab 参数,解决并发打开页面冲突
- 默认行为改为创建新 tab(并发安全)
- --tab current: 在当前活动 tab 中导航
- --tab <tabId>: 在指定 tab 中导航
- 返回 tabId 供 AI Agent 追踪管理
2026-01-30 17:24:53 +08:00
yan5xu fa39bdb360 fix: 修复 trace 录制 - manifest 匹配规则和页面导航后自动恢复录制 2026-01-30 16:36:27 +08:00
yan5xu f02b081f48 feat: 添加 trace 命令 - 录制用户操作 2026-01-30 15:58:09 +08:00
yan5xu 518f267453 docs: 更新 README 添加 network/console/errors 文档 2026-01-30 12:37:36 +08:00
yan5xu 02edcb4c85 feat: 添加 network/console/errors 调试命令
- network requests [filter]: 查看网络请求
- network route <url> [--abort|--body]: 拦截/mock 请求
- network unroute [url]: 移除拦截规则
- network clear: 清空请求记录
- console: 查看控制台消息(log/info/warn/error)
- console --clear: 清空控制台
- errors: 查看 JS 异常
- errors --clear: 清空错误记录

扩展通过 CDP Network/Fetch/Runtime/Log 域实现监控和拦截
2026-01-30 12:34:33 +08:00
yan5xu 7bddac4fa2 docs: 完善 README 文档
- 添加核心特性说明
- 添加架构图
- 添加完整命令列表和示例
- 添加 CDP 开发模式说明
- 添加项目结构和技术栈
2026-01-30 11:51:05 +08:00
yan5xu 4304883e43 refactor: 清理旧代码 - 移除 Content Script,精简 dom-service
- 删除 content/index.ts(未使用的 Content Script)
- 移除 manifest.json 中的 content_scripts 配置
- 精简 dom-service.ts:1285 行 → 539 行(只保留 snapshot 相关)
- 更新 vite.config.ts:移除 content script 打包
2026-01-30 11:48:24 +08:00
yan5xu 827f24d6a2 feat: v2.0 CDP 架构迁移 - 使用 chrome.debugger 实现所有 DOM 操作
- 新增 cdp-service.ts: chrome.debugger API 封装
- 新增 cdp-dom-service.ts: 高级 DOM 操作(click, fill, type, scroll 等)
- 更新 command-handler.ts: 所有命令改用 CDP 实现
- snapshot 暂时保持使用 buildDomTree.js(Accessibility API 待优化)
2026-01-30 11:41:40 +08:00
yan5xu 8395ae7a07 fix: 修复 back/forward 命令 - 使用 CDP 和 tabs.update 导航 2026-01-30 10:53:27 +08:00
yan5xu c74fca3a2a fix: 使用 CDP Runtime.evaluate 替代 eval 绕过 MV3 CSP 限制 2026-01-30 10:49:18 +08:00
yan5xu 0052ec5c31 merge: feat/dialogs - 添加 dialog 命令 2026-01-30 10:36:55 +08:00
yan5xu fb726aec3c merge: feat/frames - 添加 frame 命令 2026-01-30 10:32:37 +08:00
yan5xu 394d7e7dc3 feat: 添加 frame 命令(切换 iframe) 2026-01-30 10:28:48 +08:00
yan5xu 8d6e6c1d75 feat: 添加 dialog 命令(accept/dismiss) 2026-01-30 10:26:52 +08:00
yan5xu a608124f06 feat: 添加 tab 命令(list/new/select/close) 2026-01-30 10:26:31 +08:00
yan5xu c16b442bb6 fix: eval 命令使用 MAIN world 访问页面 DOM 2026-01-30 10:06:35 +08:00
yan5xu bbfda3fc62 feat: 添加 Phase 3 命令 (eval/type/check/uncheck/select) 2026-01-30 10:02:53 +08:00