Skip to content

stagehand-python@4.5.0a0.dev1713

@shrey150 shrey150 tagged this 18 Nov 20:24
# why

Make it easy to join the Stagehand and Browse CLI community from the
terminal to contribute, request features, and share feedback.

# what changed

Adds `browse discord`, visible in root help, with this invitation:

```console
$ browse discord --no-open
https://discord.gg/stagehand
Join our Discord community to contribute to Stagehand and the Browse CLI, request features, and share feedback!
```

- In an interactive terminal outside CI, opens the invite using the
maintained [`open`](https://github.com/sindresorhus/open) package and
prints the URL and invitation.
- `--no-open` or noninteractive stdout skips the opener. A nonempty `CI`
value (including `true` or `1`) also skips it; literal `CI=false`
disables that guard, matching the `ci-info` convention.
- If the opener cannot start, the command still prints the invitation
and exits successfully.
- Adds a Discord link to the CLI README and shared support URLs.
- Includes a **patch changeset for `browse`**: a small support command
that preserves existing behavior.

For review, the command and copy are in
`packages/cli/src/commands/discord.ts`; terminal/CI guards and opener
error handling are in `packages/cli/src/lib/open-url.ts`.
Platform-specific launching is delegated to `open`, with its dependency
recorded in the CLI manifest and lockfile. The stacked follow-up, #3451,
adds community links to help and error messages.

# test plan

- [x] CLI TypeScript build and oclif manifest generation.
- [x] Discord, CLI surface, and opener regression tests: **73 passed**.
- [x] Seven compiled CLI smoke checks using the real `open` package:
interactive launch, `CI=false`, `--no-open`, `CI=true`, `CI=0`, piped
stdout, and missing-launcher fallback.
- [x] Changed-file formatting and lint checks, plus changeset
validation.
- [x] CI passing at `7e1f854bd`, including Linux/Windows builds, CLI
contracts, Chrome smoke tests, regression tests, and automated review.

<!-- CURSOR_AGENT_PR_BODY_BEGIN -->
# why

Make it easy to join the Stagehand and Browse CLI community from the
terminal to contribute, request features, and share feedback.

# what changed

Adds `browse discord`, visible in root help, with this invitation:

```console
$ browse discord --no-open
https://discord.gg/stagehand
Join our Discord community to contribute to Stagehand and the Browse CLI, request features, and share feedback!
```

- In an interactive terminal outside CI, opens the invite using a
hand-rolled browser opener and prints the URL and invitation.
- `--no-open` or noninteractive stdout skips the opener. A nonempty `CI`
value (including `true` or `1`) also skips it; literal `CI=false`
disables that guard, matching the `ci-info` convention.
- If the opener cannot start, the command still prints the invitation
and exits successfully.
- Adds a Discord link to the CLI README and shared support URLs.
- Includes a **patch changeset for `browse`**: a small support command
that preserves existing behavior.

## Browser opener implementation

Uses a hand-rolled default-browser opener instead of the `open` npm
package (no new dependencies):

| Platform | Command | Notes |
|----------|---------|-------|
| macOS | `open <url>` | |
| Windows | `rundll32 url.dll,FileProtocolHandler <url>` | Avoids URL
mangling |
| Linux/Unix | `$BROWSER <url>` | If `$BROWSER` is set |
| WSL (non-SSH) | `rundll32.exe url.dll,FileProtocolHandler <url>` |
Falls back to `xdg-open` on ENOENT |
| Linux/Unix/WSL-SSH | `xdg-open <url>` | Default fallback |

Key properties:
- **No shell**: spawns without `shell: true`, so URLs with `&`, `?`,
`#`, spaces, etc. are passed untouched as a single argv element.
- **Detached + unref**: the opener process continues after the CLI
exits.
- **Error-safe**: registers an `'error'` listener to swallow async
ENOENT/EACCES (opener not found) without crashing.
- **`$BROWSER` support**: respects the standard `$BROWSER` environment
variable on Linux/Unix.
- **WSL-aware**: detects WSL via `WSL_DISTRO_NAME` or `/proc/version`
containing "microsoft", uses Windows opener via interop (unless over
SSH).
- **WSL fallback**: if `rundll32.exe` fails (e.g. interop disabled),
falls back to `xdg-open`.

For review, the command and copy are in
`packages/cli/src/commands/discord.ts`; terminal/CI guards and opener
error handling are in `packages/cli/src/lib/open-url.ts`. The stacked
follow-up, #3451, adds community links to help and error messages.

# test plan

- [x] CLI TypeScript build and oclif manifest generation.
- [x] Discord, CLI surface, and opener regression tests: **643 passed**.
- [x] Comprehensive unit tests for the browser opener:
  - Platform-specific command verification (darwin, linux, win32)
  - `$BROWSER` override tests
  - WSL detection via env and `/proc/version`
  - WSL over SSH uses `xdg-open`
  - `rundll32.exe` ENOENT falls back to `xdg-open`
- URLs with special characters (`&`, `?`, `#`, encoded spaces) passed
untouched
  - `shell: false`, `detached: true`, `stdio: 'ignore'` options verified
  - `unref()` called on child process
  - Async `'error'` event (ENOENT) swallowed without crash
  - TTY/CI/`--no-open` gating verified
- [x] Changed-file formatting and lint checks, plus changeset
validation.
<!-- CURSOR_AGENT_PR_BODY_END -->

<div><a
href="https://cursor.com/agents/bc-1a17422b-39e8-50b7-99b6-8f734c5335c8?cursor_ref=pr_footer&cursor_cta=open_in_web"><picture><source
media="(prefers-color-scheme: dark)"
srcset="https://cursor.com/assets/images/open-in-web-dark.png"><source
media="(prefers-color-scheme: light)"
srcset="https://cursor.com/assets/images/open-in-web-light.png"><img
alt="Open in Web" width="114" height="28"
src="https://cursor.com/assets/images/open-in-web-dark.png"></picture></a>&nbsp;<a
href="https://cursor.com/background-agent?bcId=bc-1a17422b-39e8-50b7-99b6-8f734c5335c8&cursor_ref=pr_footer&cursor_cta=open_in_cursor"><picture><source
media="(prefers-color-scheme: dark)"
srcset="https://cursor.com/assets/images/open-in-cursor-dark.png"><source
media="(prefers-color-scheme: light)"
srcset="https://cursor.com/assets/images/open-in-cursor-light.png"><img
alt="Open in Cursor" width="131" height="28"
src="https://cursor.com/assets/images/open-in-cursor-dark.png"></picture></a>&nbsp;</div>

---------

Co-authored-by: Cursor Agent <cursoragent@cursor.com>
Assets 2
Loading