Newshot

An experimental web browser written from scratch in Rust by an AI agent (Claude)

Original text(via HN AI)

swb

An experimental web browser, written from scratch in Rust.

An AI agent (Claude) designs, writes and maintains all of the code. The project owner sets the goals and checks the results. See docs/ground-rules.md.

swb with the GitHub page of this repository
swb with the GitHub page of this repository

swb shows the GitHub page of this repository, with JavaScript on.

swb uses general-purpose libraries (HTTP, TLS, HTML tokenizing, image decoding, WOFF and WOFF2 decoding, font shaping, 2D rasterization, windowing). The browser parts (CSS, style, layout, painting, page loading, the JavaScript engine, the DOM and the other web APIs, user interface) are written in this repository.

Quick start

swb is developed and tested on Linux (Wayland or X11). Other platforms are not tested.

Requirements (Debian/Ubuntu package names):

  • Rust toolchain via rustup. The version is pinned in rust-toolchain.toml and installed automatically.
  • libfontconfig-dev, libxkbcommon-dev, libwayland-dev, pkg-config.
  • A C compiler, make and sh (build-essential): the build compiles jemalloc, the memory allocator of the binaries, from source (ADR 0029).
  • just (optional).

        git clone https://github.com/senko/swb.git
cd swb
just run https://senko.net/                    # build (release) and open a window
just run --js https://github.com/senko/swb     # the same, with JavaScript on
      

Without just: cargo run --release -p swb -- https://senko.net/. The binary is target/release/swb.

Use

The toolbar has back, forward and reload buttons, the JavaScript toggle (JS) and the address bar. In the address bar, an address without a scheme gets https://, and an absolute path opens a local file. On the command line, a relative file path also works.

KeyAction
Ctrl+LFocus the address bar
Alt+Left, Alt+Right, mouse back and forward buttonsBack, forward
BackspaceBack (when no text field has the focus)
F5, Ctrl+RReload
EscapeStop loading
Tab, Shift+TabMove the focus between links and form controls
EnterFollow the focused link
Ctrl+A, Ctrl+CSelect all text, copy the selection
Ctrl+X, Ctrl+VCut, paste (in text fields and the address bar)
Ctrl+Shift+JTurn JavaScript on or off
Ctrl+Q, Ctrl+WQuit

JavaScript is off by default. The JS button and Ctrl+Shift+J apply to the next page that loads; reload to apply the change to the current page. --js starts with JavaScript on. JavaScript needs a stack limit of at least 8 MiB (ulimit -s). Below it, the button is gray and JavaScript stays off.

Headless mode (for tests and scripts):


        swb --headless --screenshot page.png https://senko.net/
swb --headless --full-page --screenshot page.png https://senko.net/
swb --headless --with-chrome --screenshot window.png https://senko.net/
swb --headless --dump-layout https://senko.net/
swb --headless --js --eval 'document.title' https://senko.net/
swb --headless --bench 20 https://senko.net/   # time each pipeline stage
      

Remote control: swb --headless --remote-port 0 starts a WebSocket server on 127.0.0.1 that tests and tools use to drive the browser (also with a window: swb --remote-port 9222). See docs/automation.md.

See swb --help for all options.

Status

Early development.

  • Eight target pages match Chromium: senko.net, Hacker News, a Wikipedia article, a Craigslist posting, the Ars Technica and BBC front pages, the GitHub page of this repository, and an OpenStreetMap map. All of them except senko.net also work with JavaScript on, with the interactions that the targets list names.
  • swb has its own JavaScript engine (crates/js*); 41,842 tests of its test262 subset pass.
  • Not done: running scripts in workers (Worker exists but runs no script), window.open and tabs, media playback, WebGL, CSS anchor positioning.

The roadmap lists the milestones, what each one includes, and the backlog. The development log has the latest changes.

Development


        just check    # format check, clippy, all tests, license check
just --list   # all commands
      

docs/testing.md describes the tests and the tools that compare swb with Chromium. CLAUDE.md has the instructions and the workflow of the AI agents that write the code.

Documentation

  • Ground rules, target pages
  • Architecture
  • Testing and tools, performance
  • Automation protocol
  • Decision records
  • Roadmap, development log
  • Credits and sources

License

swb's own source code is MIT-licensed. See LICENSE.

Some of swb's source code and some of the material in swb binaries are third-party material that keeps its own license; the MIT License does not apply to it:

  • the Public Suffix List under the Mozilla Public License 2.0 (MPL-2.0, a one-off exception, ADR 0014);
  • stylesheets based on the WHATWG HTML Standard under CC BY 4.0;
  • code derived from Chromium and Skia under the BSD-3-Clause license (copies of swb's source code and binaries must include their license texts), and one file derived from Servo under the MPL-2.0;
  • the WebIDL files of crates/web/idl/, copied from WHATWG standards (BSD-3-Clause) and W3C specifications (W3C Software and Document License);
  • tables generated from the Unicode Character Database and Unicode CLDR (Unicode License v3).

See THIRD_PARTY_NOTICES.md for the details and license texts.

The test data in fixtures/ (snapshots of web pages, fonts) is third-party material under its own licenses; see fixtures/pages/README.md and fixtures/fonts/README.md. It is not part of swb binaries. The fixtures for JavaScript (fixtures/js/) are local only and not in the repository.

The text above was extracted automatically from the source page and may miss images, tables or code blocks. The original is authoritative.

Published by HN AI
This site only summarises and aggregates; copyright stays with the original author. Headlines and summaries follow the source — where they differ, the original wins.
Read the original ↗