browser4-cli 0.1.28 → 0.1.30

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
@@ -513,7 +513,7 @@ paginated at 2000 lines by default; `get all text` is not paginated by default.
513
513
  > **correlated multi-field extraction** (title + price + URL per item), use
514
514
  > `htmlsnapshot query` with X-SQL's `DOM_LOAD_AND_SELECT` — it scopes each row
515
515
  > to a parent container so fields stay aligned. See the
516
- > [list-page scraping pattern](skill/references/x-sql-dom-load-select.md).
516
+ > [list-page scraping pattern](skills/browser4-cli/references/x-sql-dom-load-select.md).
517
517
 
518
518
  ```bash
519
519
  browser4-cli htmlsnapshot get all text "h2 a"
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "browser4-cli",
3
- "version": "0.1.28",
3
+ "version": "0.1.30",
4
4
  "description": "Browser automation CLI for AI agents",
5
5
  "type": "module",
6
6
  "files": [
package/scripts/README.md CHANGED
@@ -0,0 +1,135 @@
1
+ # CLI Scripts
2
+
3
+ Build, install, test, and publish utilities for the browser4-cli native binary and npm package.
4
+
5
+ ## Build
6
+
7
+ | Script | Platform | Purpose |
8
+ |--------|----------|---------|
9
+ | `build-all-platforms.sh` | Linux/macOS | Docker-based cross-compilation for all targets |
10
+ | `build-all-platforms.ps1` | Windows | PowerShell equivalent — same targets via Docker |
11
+ | `copy-native.js` | All (Node) | Copies the compiled Rust binary to `bin/` with platform-specific naming |
12
+
13
+ Both build-all-platforms scripts produce binaries for:
14
+ - `x86_64-unknown-linux-gnu` (Linux x64, glibc)
15
+ - `aarch64-unknown-linux-gnu` (Linux arm64, glibc)
16
+ - `x86_64-unknown-linux-musl` (Linux x64, musl)
17
+ - `aarch64-unknown-linux-musl` (Linux arm64, musl)
18
+ - `x86_64-pc-windows-gnu` (Windows x64)
19
+ - `x86_64-apple-darwin` (macOS x64)
20
+ - `aarch64-apple-darwin` (macOS arm64)
21
+
22
+ Options: `--skip-docker-build`, `--dry-run`.
23
+
24
+ `copy-native.js` expects a pre-built binary at `browser4-cli/target/release/browser4-cli` and copies it to `bin/browser4-cli-<platform>-<arch>`.
25
+
26
+ ## Install
27
+
28
+ | Script | Platform | Purpose |
29
+ |--------|----------|---------|
30
+ | `install-browser4-cli.sh` | Linux/macOS | Download and install the native binary |
31
+ | `install-browser4-cli.ps1` | Windows | PowerShell equivalent |
32
+
33
+ Both scripts auto-detect OS, CPU architecture, and libc variant (glibc vs musl on Linux). They download the matching binary from GitHub Releases or Alibaba Cloud OSS (auto-selected by locale: OSS first in China mainland). The binary is installed to a user-local directory and optionally added to PATH.
34
+
35
+ ### Common options
36
+
37
+ | Option | Description |
38
+ |--------|-------------|
39
+ | `--version, -v TAG` | Release tag (e.g. `v4.11.0`). Default: latest. |
40
+ | `--install-dir, -d DIR` | Install directory (default: `~/.local/bin` on Unix, `%LOCALAPPDATA%\Programs\browser4-cli` on Windows). |
41
+ | `--source SRC` | Force download source: `github` or `oss`. Default: auto (locale-aware). |
42
+ | `--no-path` / `-AddToPath:$false` | Skip adding the install directory to PATH. |
43
+ | `--silent, -s` / `-Silent` | Suppress non-error output. |
44
+ | `--dry-run` / `-DryRun` | Print what would be done without doing it. |
45
+ | `--skip-if-installed` / `-SkipIfInstalled` | Skip download if binary already exists. |
46
+ | `--skip-local` / `-SkipLocal` | Skip local bundled binary check; always download. |
47
+ | `--locate` (sh only) | Print detection results and exit (no install). |
48
+
49
+ ### One-liner install
50
+
51
+ ```shell
52
+ # Linux / macOS
53
+ curl -fsSL https://raw.githubusercontent.com/platonai/Browser4/main/cli/scripts/install-browser4-cli.sh | bash
54
+
55
+ # Windows (PowerShell)
56
+ iwr -useb https://raw.githubusercontent.com/platonai/Browser4/main/cli/scripts/install-browser4-cli.ps1 | iex
57
+ ```
58
+
59
+ ## Test
60
+
61
+ | Script | Platform | Purpose |
62
+ |--------|----------|---------|
63
+ | `smoke-test-runtime-bundle.sh` | Linux/macOS | End-to-end CLI smoke test against a runtime bundle |
64
+
65
+ Runs a full CLI smoke test suitable for CI and local development:
66
+
67
+ 1. Extracts a platform runtime bundle (`.tar.gz` or `.zip`)
68
+ 2. Sets up a local runtime directory (no network download)
69
+ 3. Starts a Python HTTP server serving a minimal interactive page
70
+ 4. Executes the full command cycle: `open` → `goto` → `snapshot` → `type` → `click` → `get` → `eval` → `screenshot` → `wait` → `close` → `kill-all`
71
+ 5. Reports pass/fail for each step
72
+
73
+ ```shell
74
+ ./smoke-test-runtime-bundle.sh <cli-binary> <bundle-archive> [test-port] [timeout-secs]
75
+ ```
76
+
77
+ ### Install script tests
78
+
79
+ | File | Purpose |
80
+ |------|---------|
81
+ | `tests/install-browser4-cli.tests.sh` | Unit tests for the Unix install script |
82
+ | `tests/install-browser4-cli.tests.ps1` | Unit tests for the Windows install script (Pester) |
83
+
84
+ ## Publish (npm)
85
+
86
+ | Script | Purpose |
87
+ |--------|---------|
88
+ | `npm-publish-check.js` | Shared library: reads package metadata and compares local vs npm registry version |
89
+ | `check-npm-publish-needed.js` | CLI wrapper: checks whether a publish is needed and prints the decision |
90
+ | `publish-if-needed.js` | Publishes to npm only when the local version differs from the registry |
91
+ | `postinstall.js` | npm `postinstall` hook: downloads the platform native binary after `npm install` |
92
+
93
+ ### Version check
94
+
95
+ ```shell
96
+ node scripts/check-npm-publish-needed.js # human-readable output
97
+ node scripts/check-npm-publish-needed.js --json # JSON output
98
+ node scripts/check-npm-publish-needed.js --shell # shell-var output
99
+ node scripts/check-npm-publish-needed.js --github-output # append to $GITHUB_OUTPUT
100
+ ```
101
+
102
+ ### Conditional publish
103
+
104
+ ```shell
105
+ node scripts/publish-if-needed.js # publish if versions differ
106
+ node scripts/publish-if-needed.js --dry-run # print what would happen
107
+ ```
108
+
109
+ Optional env: `BROWSER4_CLI_NPM_REMOTE_VERSION` to override the remote version for testing.
110
+
111
+ ### Postinstall
112
+
113
+ `postinstall.js` runs automatically after `npm install browser4-cli`. It detects the platform and downloads the matching native binary to `bin/`. On global installs, it also patches npm's bin shims to invoke the native binary directly.
114
+
115
+ ## Documentation
116
+
117
+ | Script | Platform | Purpose |
118
+ |--------|----------|---------|
119
+ | `enumerate-help.ps1` | Windows (pwsh) | Discovers all CLI commands/subcommands and generates categorized help output |
120
+
121
+ Enumerates every browser4-cli command (including hidden ones), captures `--help` output for each, and saves organized documentation to `cli/help-output/`:
122
+
123
+ - Top-level help overview
124
+ - One file per command (with numbered prefixes for ordering)
125
+ - Prefix group overviews (`swarm`, `agent`, `htmlsnapshot`, `crawl`, `snapshot`)
126
+ - `INDEX.md` for easy navigation
127
+
128
+ ```powershell
129
+ .\enumerate-help.ps1
130
+ .\enumerate-help.ps1 -Binary "C:\tools\browser4-cli.exe" -OutDir ".\docs\cli-help"
131
+ ```
132
+
133
+ ---
134
+
135
+ This README is intentionally concise; extend as the script collection grows.
@@ -9,7 +9,7 @@
9
9
  # 1. Extracts the platform runtime bundle (.tar.gz or .zip)
10
10
  # 2. Sets up a local "installed" runtime directory (no network download)
11
11
  # 3. Starts a Python HTTP server serving a minimal interactive page
12
- # 4. Runs CLI commands: open → goto → type → click → close → kill-all
12
+ # 4. Runs CLI commands: open → goto → snapshot → type → click → get → eval → screenshot → wait → close → kill-all
13
13
  # 5. Reports pass/fail for each step
14
14
  #
15
15
  # Designed for CI (GitHub Actions) but also runs on developer machines.
@@ -158,6 +158,7 @@ cat > "$TEST_PAGE" <<'HTML'
158
158
  <h1>Browser4 Smoke Test</h1>
159
159
  <input id="input1" type="text" value="">
160
160
  <button id="btn1" onclick="document.getElementById('input1').value='clicked'">Click Me</button>
161
+ <span id="output">ready</span>
161
162
  </body></html>
162
163
  HTML
163
164
 
@@ -240,10 +241,25 @@ check_step "type" type "hello-smoke" "#input1"
240
241
  # 4d. click — click the button
241
242
  check_step "click" click "#btn1"
242
243
 
243
- # 4e. closeclose the active session
244
+ # 4e. snapshotcapture page accessibility tree
245
+ check_step "snapshot" snapshot
246
+
247
+ # 4f. get text — extract text content from an element
248
+ check_step "get text" get text "#output"
249
+
250
+ # 4g. eval — execute JavaScript on the page
251
+ check_step "eval" eval "document.title"
252
+
253
+ # 4h. screenshot — capture page screenshot
254
+ check_step "screenshot" screenshot
255
+
256
+ # 4i. wait — wait for an element to be present
257
+ check_step "wait" wait "#output"
258
+
259
+ # 4j. close — close the active session
244
260
  check_step "close" close
245
261
 
246
- # 4f. kill-all — stop the server and clean up
262
+ # 4k. kill-all — stop the server and clean up
247
263
  check_step "kill-all" kill-all
248
264
 
249
265
  # ---------------------------------------------------------------------------