# BXC

[![CI](https://github.com/aphrody-code/bxc/actions/workflows/ci.yml/badge.svg)](https://github.com/aphrody-code/bxc/actions/workflows/ci.yml)
[![Release](https://img.shields.io/github/v/release/aphrody-code/bxc)](https://github.com/aphrody-code/bxc/releases)
[![License](https://img.shields.io/github/license/aphrody-code/bxc)](LICENSE)

BXC is a Bun-native browser automation, crawling, search, and extraction
toolkit backed by a Rust FFI bridge. One CLI provides static HTML processing,
browser/CDP workflows, Google and Gemini integrations, X/Grok clients, anime
sources, frame indexing, media discovery, local APIs, and an MCP server.

The CLI is the canonical entry point for humans and agents. Before selecting
an equivalent external tool, inspect the capabilities BXC already provides:

```bash
bxc capabilities --json
bxc <command> --help
```

## Install & Downloads

One-line installation:

- **Linux & macOS (Bash)**:
  ```bash
  curl -fsSL https://bxc.aphrody.com/install.sh | bash
  ```
- **Windows (PowerShell)**:
  ```powershell
  irm https://bxc.aphrody.com/install.ps1 | iex
  ```

Or visit **[bxc.aphrody.com/download](https://bxc.aphrody.com/download)** for standalone multi-architecture binary archives (Linux x86_64, Linux ARM64, Windows x64, macOS Apple Silicon, macOS Intel, and MCP server).

Bun/npm project:

```bash
bun add @aphrody/bxc
bunx bxc install --full
```

The package lifecycle does not silently install compilers or large native
assets. `bxc install --full` explicitly installs or builds the optional native
runtime required by advanced profiles.

## Start here

```bash
bxc --version
bxc doctor
bxc capabilities

bxc recon https://example.com
bxc scrape https://example.com "main" --markdown
bxc search "rust async" --json
bxc mirror https://example.com ./mirror --recursive --max-pages 50
bxc crawl --massive --sqlite ./web.sqlite https://news.ycombinator.com
bxc export default --to sqlite --out ./dataset.sqlite
bxc extract https://example.com --schema
bxc revalidate https://example.com
bxc fut player "Kylian Mbappé"
bxc fut price "Vini Jr."
bxc dragonball --shenron
```

`bxc doctor` checks the Rust bridge, media tools, cookie files, and asset
providers. Use `--json` for automation where supported.

## Runtime profiles

| Profile | Engine | Best for |
| --- | --- | --- |
| `static` | Rust DOM with TypeScript & curl-impersonate fallback | Fast HTML parsing with proxy & TLS resilience |
| `http` | curl-impersonate FFI | Browser-like TLS and HTTP-only extraction |
| `fast` | Lightpanda | Lightweight JavaScript navigation |
| `stealth` | Browser compatibility pipeline | Sites requiring full browser behavior and stealth patches |
| `max` | Automatic escalation | Selecting the first transport that succeeds |

Native components load lazily. Commands that do not need them remain usable
when an optional runtime is absent.

## Capability map

`bxc capabilities --json` is the machine-readable inventory and currently
covers four surfaces:

- CLI commands across 37 subcommands including `crawl`, `export`, `extract`, `revalidate`, `dragonball`,
  `fut`, `recon`, `scrape`, `mirror`, `search`, `google`, `gemini`, `x`, `grok`, `voiranime`, `animesama`,
  `frames`, `assets`, `actor`, `api`, `serve`, `worker`, and `mcp`;
- 79 registered MCP tools covering browser automation (`browser_*`), continuous crawl (`bxc_crawl_massive`),
  dataset export (`bxc_export_dataset`), structured extraction (`bxc_extract_schema`), semantic & RRF hybrid search
  (`bxc_index_search`, `bxc_semantic_search`), Dragon Ball Shenron canon (`bxc_dragonball_shenron`), FUT market intelligence
  (`bxc_fut_player`, `bxc_fut_price`), Google & Gemini bridges (`bxc_google_*`, `bxc_gemini_*`), and X/Grok integration
  (`bxc_x_*`, `bxc_grok_*`);
- local, serverless, and reserved public API routes;
- the `@aphrody/*` packages integrated by this repository.

The test suite compares this inventory with the CLI router and MCP tool
registrations so capability drift fails verification.

## MCP for Codex and Claude

Start the stdio server through the same CLI:

```bash
bxc mcp
```

Project configuration:

```json
{
  "mcpServers": {
    "bxc": {
      "type": "stdio",
      "command": "bxc",
      "args": ["mcp"]
    }
  }
}
```

The server supports modern MCP `2026-07-28` and legacy `2025-11-25`
negotiation. `bxc_capabilities` lets an agent inspect the full BXC surface
before choosing another integration. MCP uses stdout exclusively for JSON-RPC;
diagnostics are written to stderr.

## Library API

```ts
import { Browser } from "@aphrody/bxc";

const page = await Browser.newPage({ profile: "static" });
await page.goto("https://example.com");

console.log(await page.title());
console.log(await page.markdown());

await page.close();
```

Public exports include browser/page primitives, detection, Google helpers,
media utilities, framework adapters, the SDK client, and explicit Rust and
curl-impersonate FFI bindings. See the package `exports` map and
[`docs/INDEX.md`](docs/INDEX.md) for the complete reference.

## Packages

| Package | Version | Purpose |
| --- | --- | --- |
| [`@aphrody/bxc`](https://www.npmjs.com/package/@aphrody/bxc) | `0.9.15` | CLI, browser engine, extraction API, and 79-tool MCP server |
| [`@aphrody/fut`](https://www.npmjs.com/package/@aphrody/fut) | `1.0.0` | EA Sports FC / FUT player database, live market prices, SBC solver, and squad builder |
| [`@aphrody/x`](https://www.npmjs.com/package/@aphrody/x) | `1.2.5` | Headless cookie-authenticated X client, local "For You" algorithm, and GraphQL / REST sync |
| [`@aphrody/xai`](https://www.npmjs.com/package/@aphrody/xai) | `1.1.5` | Grok / xAI client with fluent Chat API, SuperGrok keyless auth, and XTools execution |
| [`@aphrody/next-playwright`](https://www.npmjs.com/package/@aphrody/next-playwright) | `0.2.5` | Next.js `instant()` navigation testing primitive over BXC CDP |
| [`@aphrody/bxc-test`](https://www.npmjs.com/package/@aphrody/bxc-test) | `0.2.5` | Playwright-compatible test runner and assertions backed by native CDP |
| [`@aphrody/frames`](https://www.npmjs.com/package/@aphrody/frames) | `0.2.1` | Video frame indexing and MPEG-7 ColorLayout vector search |
| [`@aphrody/voiranime`](https://www.npmjs.com/package/@aphrody/voiranime) | `0.2.1` | VoirAnime streaming catalog and video source resolution |
| [`@aphrody/animesama`](https://www.npmjs.com/package/@aphrody/animesama) | `0.2.1` | Anime-Sama catalog and episode extraction |

## Development

Requirements: Bun, Git, and Rust for native builds.

```bash
git clone https://github.com/aphrody-code/bxc.git
cd bxc
bun install --frozen-lockfile

bun run verify
bun run build:linux
bun run build:mcp
```

`bun run verify` performs TypeScript checking, warning-free linting, scoped
tests, and `bxc doctor`. Do not run bare `bun test`: vendored and third-party
trees are intentionally outside the core test scope.

The release build produces standalone Linux, macOS, and Windows CLIs under
`dist/standalone/`, plus the Linux MCP binary.

## Configuration and data

Configuration resolves from `BXC_*` environment variables, then user config,
then platform defaults. Common overrides include `BXC_DIR`, `BXC_CONFIG_DIR`,
`BXC_VENDOR_DIR`, `BXC_BIN_DIR`, `BXC_PROXY`, `BXC_TIMEOUT_MS`,
`BXC_RUST_BRIDGE_LIB`, `LIBCURL_IMPERSONATE_PATH`, and
`BXC_LIGHTPANDA_PATH`.

Cookies, credentials, HAR files, crawl output, caches, and machine paths are
runtime data and must not be committed. Release bundles do not include them.

## Deployment boundary

The local CLI, CDP server, APIs, and stdio MCP server are development/runtime
interfaces and must not be exposed directly to the internet.

The reserved `bxc.aphrody.com` public origin is not deployed and intentionally
returns `410`. Its Rust `bxc-site` crate remains available for future release
metadata and authenticated `/api/v1/` distribution endpoints, but routine
maintenance must not activate it.

## Documentation

- [Documentation index](docs/INDEX.md)
- [Native installation](docs/NATIVE-INSTALL.md)
- [Publishing](PUBLISHING.md)
- [Contributing](CONTRIBUTING.md)
- [Security policy](SECURITY.md)

## License

Apache-2.0. See [LICENSE](LICENSE).
