Commit Graph

55 Commits

Author SHA1 Message Date
yan5xu 31fb169516 fix(site): filter noise from recommend not_available list
- Only show domains with >= 5 visits
- Exclude localhost and non-domain strings (e.g. Chrome extension IDs)

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-15 12:16:42 +08:00
yan5xu fdb8288ce2 feat: add history, site recommend, site info, --jq, and Agent UX guide
New commands:
- `history search/domains` — query Chrome browsing history via chrome.history API
- `site recommend` — cross-reference history with adapters for personalized discovery
- `site info <name>` — expose full adapter @meta (args, example, domain)
- `--jq <expr>` — inline jq-like JSON filtering (inspired by gh CLI)

Agent UX improvements:
- --help grouped by intent, "开始使用" section first with site examples
- --help top hint explicitly guides Agents to use site commands over browser automation
- `open` command shows 💡 hint when the URL has available site adapters
- `--jq` auto-strips `.data.` prefix for Agent tolerance
- `site update` post-install nudge for site recommend
- AGENTS.md with full UX writing spec for contributors

Closes #21, closes #23, relates #24

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-15 12:02:04 +08:00
Yanwu bed7fbd987 feat(cli): categorize --help output, promote site system (#14)
Group commands by function (site adapters, navigation, interaction,
page info, network/debug, daemon) instead of a flat list.

Move site adapter section to the top with usage examples, making
the most powerful feature immediately visible.

Closes #13

Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-15 01:22:24 +08:00
yan5xu 94070402e1 fix(site): add guide hint to site --help 2026-03-15 00:30:01 +08:00
yan5xu 09ac697877 fix(cli): add guide command to help text 2026-03-15 00:27:33 +08:00
yan5xu bd9e89619c feat(guide): add bb-browser site adapter as gh CLI alternative
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-15 00:15:06 +08:00
yan5xu f0869aabef feat: add MCP instructions + bb-browser guide command
MCP server now sends instructions on connect so agents immediately
understand what bb-browser can do (capabilities, site adapters, etc).

New top-level `bb-browser guide` command teaches how to turn any
website into a site adapter — reverse engineer, write, test, contribute.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-15 00:13:14 +08:00
yan5xu 847a995db7 feat(site): include bb-browser site adapter as report alternative
reportHint now shows two options for agents:
1. gh issue create --repo epiral/bb-sites
2. bb-browser site github/issue-create epiral/bb-sites

Agents choose whichever tool is available.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-14 23:21:21 +08:00
yan5xu de713a2761 feat(site): add reportHint in error output for agents
When a site adapter fails, include a reportHint field telling the
agent how to file an issue via `gh issue create --repo epiral/bb-sites`.
Agents decide themselves whether to use gh CLI or bb-browser's own
github site adapter.

Remove site report subcommand — agents handle reporting autonomously.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-14 23:19:48 +08:00
yan5xu 9d8594a168 fix(site): detect auth errors in adapter hint text too
Check both error and hint fields for auth keywords.
When detected, replace with actionable login URL hint.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-14 23:02:57 +08:00
yan5xu c68653b2fa feat(site): auto-detect auth errors and show login hint
When a site adapter returns 401/403/unauthorized errors, automatically
suggest the user to log in to the site's domain in their browser.
Works in both CLI and JSON output modes.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-14 22:59:35 +08:00
yan5xu ce12d3a9f8 fix: simplify extension setup hints to 4 clear steps
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-14 22:28:55 +08:00
yan5xu 0491e72c4f fix: improve extension setup hints with direct download link
Point to releases/latest for zip download, simplify steps.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-14 22:28:04 +08:00
yan5xu 1f15f3e433 feat(cli,mcp): add setup hints when extension/daemon not connected
Show actionable setup guide when:
- Daemon not running (ECONNREFUSED)
- Extension not connected (HTTP 503)

Hints include install steps and GitHub releases link, guiding both
users and AI agents to complete the setup.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-14 22:23:05 +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 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 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 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 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 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 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 67bfe2ac9a chore: 更新仓库地址为 yan5xu/bb-browser 2026-01-31 11:56:15 +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 f02b081f48 feat: 添加 trace 命令 - 录制用户操作 2026-01-30 15:58:09 +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 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 bbfda3fc62 feat: 添加 Phase 3 命令 (eval/type/check/uncheck/select) 2026-01-30 10:02:53 +08:00
yan5xu f871763630 merge: 合并 check/uncheck 命令到 main 2026-01-30 09:59:49 +08:00
yan5xu 67d0a2cabe Merge branch 'feat/type' 2026-01-30 09:58:35 +08:00
yan5xu 638527916f feat: 添加 check/uncheck 命令 - 复选框操作 2026-01-30 09:58:25 +08:00
yan5xu de2223587e feat: 添加 type 命令 - 逐字符输入 2026-01-30 09:58:23 +08:00
yan5xu 7e6bf96aba feat: 添加 eval 命令 - 执行 JavaScript 2026-01-30 09:58:22 +08:00
yan5xu 9b5ea1f24f merge: 合并 nav 命令 (back/forward/refresh) 到 main 2026-01-30 09:36:32 +08:00
yan5xu 22d3a36d84 Merge branch 'feat/hover' 2026-01-30 09:35:10 +08:00
yan5xu 839cac81aa merge: 合并 scroll 命令到 main 2026-01-30 09:35:05 +08:00
yan5xu 260e8cedf7 feat: 实现 hover 命令 2026-01-30 09:32:12 +08:00
yan5xu 91a33983e6 feat: 实现导航命令 (back/forward/refresh) 2026-01-30 09:31:53 +08:00
yan5xu 16f3d842f3 feat: 实现 press 命令 2026-01-30 09:31:44 +08:00
yan5xu 0d60f938df feat: 实现 scroll 命令 2026-01-30 09:31:40 +08:00
yan5xu ef9b9fc5fb merge: 合并 wait 命令到 main 2026-01-29 22:03:57 +08:00
yan5xu e2e0fba0de merge: 合并 screenshot 命令到 main 2026-01-29 22:01:13 +08:00
yan5xu ebddd36aa8 merge: 合并 get 命令到 main 2026-01-29 21:59:15 +08:00
yan5xu 247e21cda1 feat: 实现 wait 命令 2026-01-29 21:57:03 +08:00