browse 0.9.3 → 0.9.5

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/README.md CHANGED
@@ -33,7 +33,7 @@ npm install -g browse
33
33
  npm install -g browse
34
34
 
35
35
  browse open https://example.com
36
- browse snapshot --compact
36
+ browse snapshot
37
37
  browse click @0-12
38
38
  browse fill @0-8 "hello"
39
39
  browse get title
@@ -89,8 +89,8 @@ browse forward # Navigate forward
89
89
  The accessibility snapshot is the recommended way for agents to discover elements. It prints a tree of refs like `@0-12` that the element commands accept directly.
90
90
 
91
91
  ```bash
92
- browse snapshot # Accessibility snapshot + cached refs
93
- browse snapshot --compact # Tree only, no ref maps
92
+ browse snapshot # Accessibility tree + cached refs (lean by default)
93
+ browse snapshot --full # Also include the ref maps (xpathMap, urlMap)
94
94
  browse snapshot --filter submit # Filter lines by text or /regex/, keeping ancestors
95
95
  browse snapshot --max-depth 4 # Trim output deeper than this depth
96
96
  ```
@@ -0,0 +1,20 @@
1
+ import { readFile } from "node:fs/promises";
2
+ import { join } from "node:path";
3
+ import { BrowseCommand } from "../../base.js";
4
+ import { fail } from "../../lib/errors.js";
5
+ import { bundledCliSkillPath } from "../../lib/skills/install.js";
6
+ export default class SkillsShow extends BrowseCommand {
7
+ static description = "Print the bundled browse skill (usage patterns, workflows, gotchas) to stdout. Run before using browse in an agent.";
8
+ static examples = ["browse skills show"];
9
+ async run() {
10
+ const skillMdPath = join(bundledCliSkillPath(), "SKILL.md");
11
+ let contents;
12
+ try {
13
+ contents = await readFile(skillMdPath, "utf8");
14
+ }
15
+ catch (error) {
16
+ fail(`Could not read the bundled browse skill (SKILL.md): ${error.message}`, 1, { resultCode: "skill_show_missing" });
17
+ }
18
+ this.log(contents);
19
+ }
20
+ }
@@ -2,17 +2,20 @@ import { Flags } from "@oclif/core";
2
2
  import { BrowseCommand } from "../base.js";
3
3
  import { driverCommandFlags, runDriverCommandFromFlags, } from "../lib/driver/command-cli.js";
4
4
  export default class Snapshot extends BrowseCommand {
5
- static description = "Print the active page accessibility snapshot and cache refs for element commands.";
5
+ static description = "Print the active page accessibility snapshot and cache refs for element commands. Pass --full to also include the ref maps (xpathMap, urlMap).";
6
6
  static examples = [
7
7
  "browse snapshot",
8
- "browse snapshot --compact",
8
+ "browse snapshot --full",
9
9
  "browse snapshot --filter submit",
10
10
  "browse snapshot --max-depth 4",
11
11
  ];
12
12
  static flags = {
13
13
  ...driverCommandFlags,
14
+ full: Flags.boolean({
15
+ description: "Also include the ref maps (xpathMap, urlMap).",
16
+ }),
14
17
  compact: Flags.boolean({
15
- description: "Print only the formatted tree, without ref maps.",
18
+ description: "Deprecated and has no effect; use --full to include the ref maps.",
16
19
  }),
17
20
  filter: Flags.string({
18
21
  description: "Filter output lines by text or /regex/ while preserving matching ancestors.",
@@ -25,8 +28,11 @@ export default class Snapshot extends BrowseCommand {
25
28
  };
26
29
  async run() {
27
30
  const { flags } = await this.parse(Snapshot);
31
+ if (flags.compact && process.stderr.isTTY) {
32
+ this.warn("`--compact` is deprecated and has no effect; use `--full` to include the ref maps.");
33
+ }
28
34
  await runDriverCommandFromFlags("snapshot", {
29
- compact: flags.compact,
35
+ full: flags.full,
30
36
  filter: flags.filter,
31
37
  maxDepth: flags["max-depth"],
32
38
  }, flags);
package/dist/help.js ADDED
@@ -0,0 +1,19 @@
1
+ import { Help } from "@oclif/core";
2
+ // Custom root-help formatter so `browse --help` (and bare `browse`) lead with
3
+ // a short block pointing agents at the bundled skill, ahead of oclif's
4
+ // auto-generated VERSION/USAGE/DESCRIPTION/COMMANDS sections. Only the root
5
+ // help view is customized -- individual `browse <command> --help` views are
6
+ // unaffected.
7
+ const AGENT_HEADER = `Start here (for AI agents):
8
+ browse skills show
9
+
10
+ The bundled skill ships with the CLI (always version-matched) and covers
11
+ workflows, session management, and common failure recovery. Prefer it over
12
+ guessing commands from flag docs alone.
13
+ `;
14
+ export default class BrowseHelp extends Help {
15
+ async showRootHelp() {
16
+ this.log(AGENT_HEADER);
17
+ await super.showRootHelp();
18
+ }
19
+ }
@@ -2,9 +2,9 @@ import { z } from "zod";
2
2
  import { formatSnapshotTree } from "./snapshot-format.js";
3
3
  export const snapshotHandlers = {
4
4
  async snapshot(manager, params) {
5
- const { compact, filter, maxDepth } = z
5
+ const { full, filter, maxDepth } = z
6
6
  .object({
7
- compact: z.boolean().optional(),
7
+ full: z.boolean().optional(),
8
8
  filter: z.string().optional(),
9
9
  maxDepth: z.number().int().nonnegative().optional(),
10
10
  })
@@ -16,17 +16,16 @@ export const snapshotHandlers = {
16
16
  xpathMap: snapshot.xpathMap ?? {},
17
17
  });
18
18
  const tree = formatSnapshotTree(snapshot.formattedTree, {
19
- compact,
20
19
  filter,
21
20
  maxDepth,
22
21
  });
23
- if (compact) {
24
- return { tree };
22
+ if (full) {
23
+ return {
24
+ tree,
25
+ urlMap: snapshot.urlMap,
26
+ xpathMap: snapshot.xpathMap,
27
+ };
25
28
  }
26
- return {
27
- tree,
28
- urlMap: snapshot.urlMap,
29
- xpathMap: snapshot.xpathMap,
30
- };
29
+ return { tree };
31
30
  },
32
31
  };
@@ -167,7 +167,7 @@ function localSkillPath(skillId) {
167
167
  const configHome = process.env.XDG_CONFIG_HOME || join(homedir(), ".config");
168
168
  return join(configHome, "browserbase", "skills", skillId.domain, skillId.task);
169
169
  }
170
- function bundledCliSkillPath() {
170
+ export function bundledCliSkillPath() {
171
171
  return join(packageRoot(), "skills", "browse");
172
172
  }
173
173
  function packageRoot() {
@@ -2093,10 +2093,10 @@
2093
2093
  "snapshot": {
2094
2094
  "aliases": [],
2095
2095
  "args": {},
2096
- "description": "Print the active page accessibility snapshot and cache refs for element commands.",
2096
+ "description": "Print the active page accessibility snapshot and cache refs for element commands. Pass --full to also include the ref maps (xpathMap, urlMap).",
2097
2097
  "examples": [
2098
2098
  "browse snapshot",
2099
- "browse snapshot --compact",
2099
+ "browse snapshot --full",
2100
2100
  "browse snapshot --filter submit",
2101
2101
  "browse snapshot --max-depth 4"
2102
2102
  ],
@@ -2190,8 +2190,14 @@
2190
2190
  "allowNo": false,
2191
2191
  "type": "boolean"
2192
2192
  },
2193
+ "full": {
2194
+ "description": "Also include the ref maps (xpathMap, urlMap).",
2195
+ "name": "full",
2196
+ "allowNo": false,
2197
+ "type": "boolean"
2198
+ },
2193
2199
  "compact": {
2194
- "description": "Print only the formatted tree, without ref maps.",
2200
+ "description": "Deprecated and has no effect; use --full to include the ref maps.",
2195
2201
  "name": "compact",
2196
2202
  "allowNo": false,
2197
2203
  "type": "boolean"
@@ -4530,6 +4536,29 @@
4530
4536
  "list.js"
4531
4537
  ]
4532
4538
  },
4539
+ "skills:show": {
4540
+ "aliases": [],
4541
+ "args": {},
4542
+ "description": "Print the bundled browse skill (usage patterns, workflows, gotchas) to stdout. Run before using browse in an agent.",
4543
+ "examples": [
4544
+ "browse skills show"
4545
+ ],
4546
+ "flags": {},
4547
+ "hasDynamicHelp": false,
4548
+ "hiddenAliases": [],
4549
+ "id": "skills:show",
4550
+ "pluginAlias": "browse",
4551
+ "pluginName": "browse",
4552
+ "pluginType": "core",
4553
+ "strict": true,
4554
+ "isESM": true,
4555
+ "relativePath": [
4556
+ "dist",
4557
+ "commands",
4558
+ "skills",
4559
+ "show.js"
4560
+ ]
4561
+ },
4533
4562
  "tab:close": {
4534
4563
  "aliases": [],
4535
4564
  "args": {
@@ -6392,5 +6421,5 @@
6392
6421
  ]
6393
6422
  }
6394
6423
  },
6395
- "version": "0.9.3"
6424
+ "version": "0.9.5"
6396
6425
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "browse",
3
- "version": "0.9.3",
3
+ "version": "0.9.5",
4
4
  "description": "Unified Browserbase CLI for browser automation and cloud APIs.",
5
5
  "type": "module",
6
6
  "private": false,
@@ -24,6 +24,7 @@
24
24
  "bin": "browse",
25
25
  "dirname": "browse",
26
26
  "commands": "./dist/commands",
27
+ "helpClass": "./dist/help.js",
27
28
  "hooks": {
28
29
  "init": "./dist/hooks/init.js",
29
30
  "prerun": "./dist/hooks/prerun.js",
@@ -65,12 +65,16 @@ browse open https://example.com --cdp ws://127.0.0.1:9222/devtools/browser/<id>
65
65
 
66
66
  Use local mode for development, localhost, trusted sites, and fast iteration. Use `--auto-connect` only when the user explicitly wants to attach to an already-running debuggable Chrome session with existing cookies or login state; use `--local` when no debuggable Chrome is available. Use remote mode when Browserbase credentials are available and the site needs hosted browser infrastructure, Verified browser mode, CAPTCHA solving, proxies, or session persistence.
67
67
 
68
+ `--local` requires Chrome or Chromium already installed on the machine. In containers, CI, and sandboxes with no browser installed, use `--remote` instead of `--local`. If `--local` fails with "No Chrome or Chromium found" and `BROWSERBASE_API_KEY` is set, switch to `--remote` — do not retry `--local`.
69
+
68
70
  For a Verified and/or proxied remote session, add `--verified` and/or `--proxies` to `--remote` — a single command that keeps the Browserbase session identity, so `browse status` and `browse doctor` report the session ID and live-view URL. `--verified` requires a Browserbase Scale plan. These flags only apply to `--remote` and are sticky for the session's lifetime, like `--headed`. Reach for `browse cloud sessions create` + `--cdp` only when you need session options `open` doesn't expose (region, keep-alive, contexts).
69
71
 
70
72
  Choose headed/headless and local/remote mode when starting a session. A running session keeps its mode: passing a conflicting flag such as `--headed` to an already-running headless session fails until you run `browse stop --session <name>` or target a different session.
71
73
 
72
74
  Use named sessions for any non-trivial work, especially when multiple agents or parallel tasks may run at once. Every browser command accepts `--session <name>` (or `-s <name>`); the `BROWSE_SESSION` env var sets the default, and commands without either share the `default` session.
73
75
 
76
+ If `BROWSE_SESSION` is already set in the environment, every command already targets that session — do not pass `--session` or invent a new name. An explicit `--session <name>` always overrides `BROWSE_SESSION` for that command, so only pass it to deliberately target a different session.
77
+
74
78
  ```bash
75
79
  browse open https://example.com --session research --local
76
80
  browse snapshot --session research
@@ -132,8 +136,8 @@ browse wait selector "#result"
132
136
  Page state:
133
137
 
134
138
  ```bash
135
- browse snapshot
136
- browse snapshot --compact
139
+ browse snapshot # formatted tree only
140
+ browse snapshot --full # also include ref maps (xpathMap, urlMap)
137
141
  browse get url
138
142
  browse get title
139
143
  browse get text body