bb-browser 0.4.2 → 0.4.4

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/dist/cli.js CHANGED
@@ -1930,10 +1930,9 @@ async function siteCommand(args, options = {}) {
1930
1930
  bb-browser site twitter/user yan5xu
1931
1931
  bb-browser site search reddit
1932
1932
 
1933
- Adapter \u7ED3\u679C\u4E0D\u7B26\u5408\u9884\u671F\uFF1F\u62A5\u544A\u95EE\u9898\uFF1A
1934
- gh issue create --repo epiral/bb-sites --title "[adapter-name] \u63CF\u8FF0"
1935
- \u6216: https://github.com/epiral/bb-sites/issues
1936
- \u8D21\u732E\u65B0 adapter: https://github.com/epiral/bb-sites`);
1933
+ \u521B\u5EFA\u65B0 adapter: bb-browser guide
1934
+ \u62A5\u544A\u95EE\u9898: gh issue create --repo epiral/bb-sites --title "[adapter-name] \u63CF\u8FF0"
1935
+ \u8D21\u732E\u793E\u533A: https://github.com/epiral/bb-sites`);
1937
1936
  return;
1938
1937
  }
1939
1938
  switch (subCommand) {
@@ -2035,6 +2034,7 @@ bb-browser - AI Agent \u6D4F\u89C8\u5668\u81EA\u52A8\u5316\u5DE5\u5177
2035
2034
  site search <q> \u641C\u7D22 adapter
2036
2035
  site <name> \u8FD0\u884C adapter\uFF08\u5982 site reddit/thread <url>\uFF09
2037
2036
  site update \u66F4\u65B0\u793E\u533A adapter \u5E93
2037
+ guide \u5982\u4F55\u628A\u4EFB\u4F55\u7F51\u7AD9\u53D8\u6210 site adapter\uFF08\u5F00\u53D1\u6307\u5357\uFF09
2038
2038
 
2039
2039
  \u9009\u9879\uFF1A
2040
2040
  --json \u4EE5 JSON \u683C\u5F0F\u8F93\u51FA
@@ -2459,6 +2459,66 @@ async function main() {
2459
2459
  await siteCommand(parsed.args, { json: parsed.flags.json, tabId: globalTabId });
2460
2460
  break;
2461
2461
  }
2462
+ case "guide": {
2463
+ console.log(`How to turn any website into a bb-browser site adapter
2464
+ =======================================================
2465
+
2466
+ 1. REVERSE ENGINEER the API
2467
+ bb-browser network clear --tab <tabId>
2468
+ bb-browser refresh --tab <tabId>
2469
+ bb-browser network requests --filter "api" --with-body --json --tab <tabId>
2470
+
2471
+ 2. TEST if direct fetch works (Tier 1)
2472
+ bb-browser eval "fetch('/api/endpoint',{credentials:'include'}).then(r=>r.json())" --tab <tabId>
2473
+
2474
+ If it works \u2192 Tier 1 (Cookie auth, like Reddit/GitHub/Zhihu/Bilibili)
2475
+ If needs extra headers \u2192 Tier 2 (like Twitter: Bearer + CSRF token)
2476
+ If needs request signing \u2192 Tier 3 (like Xiaohongshu: Pinia store actions)
2477
+
2478
+ 3. WRITE the adapter (one JS file per operation)
2479
+
2480
+ /* @meta
2481
+ {
2482
+ "name": "platform/command",
2483
+ "description": "What it does",
2484
+ "domain": "www.example.com",
2485
+ "args": { "query": {"required": true, "description": "Search query"} },
2486
+ "readOnly": true,
2487
+ "example": "bb-browser site platform/command value"
2488
+ }
2489
+ */
2490
+ async function(args) {
2491
+ if (!args.query) return {error: 'Missing argument: query'};
2492
+ const resp = await fetch('/api/search?q=' + encodeURIComponent(args.query), {credentials: 'include'});
2493
+ if (!resp.ok) return {error: 'HTTP ' + resp.status, hint: 'Not logged in?'};
2494
+ return await resp.json();
2495
+ }
2496
+
2497
+ 4. TEST it
2498
+ Save to ~/.bb-browser/sites/platform/command.js (private, takes priority)
2499
+ bb-browser site platform/command "test query" --json
2500
+
2501
+ 5. CONTRIBUTE
2502
+ Option A (with gh CLI):
2503
+ git clone https://github.com/epiral/bb-sites && cd bb-sites
2504
+ git checkout -b feat-platform
2505
+ # add adapter files
2506
+ git push -u origin feat-platform
2507
+ gh pr create --repo epiral/bb-sites
2508
+
2509
+ Option B (without gh CLI, using bb-browser itself):
2510
+ bb-browser site github/fork epiral/bb-sites
2511
+ git clone https://github.com/YOUR_USER/bb-sites && cd bb-sites
2512
+ git checkout -b feat-platform
2513
+ # add adapter files
2514
+ git push -u origin feat-platform
2515
+ bb-browser site github/pr-create epiral/bb-sites --title "feat(platform): add adapters" --head "YOUR_USER:feat-platform"
2516
+
2517
+ Private adapters: ~/.bb-browser/sites/<platform>/<command>.js
2518
+ Community: ~/.bb-browser/bb-sites/ (via bb-browser site update)
2519
+ Full guide: https://github.com/epiral/bb-sites/blob/main/SKILL.md`);
2520
+ break;
2521
+ }
2462
2522
  default: {
2463
2523
  console.error(`\u9519\u8BEF\uFF1A\u672A\u77E5\u547D\u4EE4 "${parsed.command}"`);
2464
2524
  console.error("\u8FD0\u884C bb-browser --help \u67E5\u770B\u53EF\u7528\u547D\u4EE4");