# ๐ŸŸ Shiny Fishstick [![License](https://img.shields.io/badge/license-Apache--2.0-blue.svg)](LICENSE) [![CI Status](https://github.com/Hootsworth/shiny-fishstick/actions/workflows/ci.yml/badge.svg)](https://github.com/Hootsworth/shiny-fishstick/actions/workflows/ci.yml) [![Version](https://img.shields.io/badge/version-0.1.0--alpha-orange.svg)](https://github.com/Hootsworth/shiny-fishstick/releases/tag/v0.1.0-alpha) [![Python](https://img.shields.io/badge/python-3.9%2B-blue.svg)](backend/) [![Node](https://img.shields.io/badge/node-%3E%3D18-green.svg)](frontend/) [![MCP](https://img.shields.io/badge/MCP-compatible-purple.svg)](examples/mcp-agent/) > **Compile websites into semantic SDKs and MCP servers for AI agents.** > *Because agents shouldn't have to parse raw HTML, guess CSS selectors, or crash when a button gets renamed.* --- ## Table of Contents - [The Problem](#the-problem) - [The Solution](#the-solution) - [Quick Start](#quick-start) - [How It Works](#how-it-works) - [The `preflight.yaml` Format](#the-preflightyaml-format) - [Benchmarks](#benchmarks) - [Features](#features) - [Dashboard](#dashboard) - [CLI Reference](#cli-reference) - [Examples](#examples) - [vs. Everything Else](#vs-everything-else) - [FAQ](#faq) - [Architecture & Design](#architecture--design) - [The Vision](#the-vision) - [Contributing](#contributing) - [License](#license) --- ## The Problem Every AI browser agent today faces the same wall. The agent gets a task: *"Buy a pair of running shoes."* And then it has to: - Parse thousands of tokens of raw HTML just to find a button - Guess at CSS selectors that break the moment a developer refactors the frontend - Handle login redirects, session state, shadow DOMs, and dynamic injections - Pay a steep LLM context tax on every single page interaction This is not a browser problem. It's an abstraction problem. **Shiny Fishstick** is the compiler that fixes it. --- ## The Solution Run Shiny Fishstick on any website once. It crawls the site, discovers what it can do, and compiles the result into a clean, typed, agent-ready SDK. Your agent goes from this: ```python # Without Shiny Fishstick ๐Ÿ˜ฐ page = await browser.new_page() await page.goto("https://shop.example.com") await page.locator("#email").fill("agent@example.com") await page.locator("#password").fill("hunter2") await page.locator("#login-submit-btn").click() await page.wait_for_selector(".dashboard") # ... 40 more lines for every action ``` To this: ```python # With Shiny Fishstick ๐ŸŸ site = ShinyClient("https://shop.example.com") await site.login(email="agent@example.com", password="hunter2") await site.search_products(query="running shoes") await site.add_to_cart(product_id="42", quantity=1) # direct API call, no browser needed await site.checkout() ``` --- ## Quick Start **Prerequisites:** - Python 3.9+ - Node.js 18+ - Docker & Docker Compose *(optional โ€” for containerised setup)* - Playwright browsers: `playwright install chromium` ```bash # Clone and set up git clone git@github.com:Hootsworth/shiny-fishstick.git cd shiny-fishstick cp .env.example .env # configure API keys, DB path, etc. make setup # Run the live demo โ€” crawls a local mock store, generates all SDKs make demo ``` Generated files land in `./shared/specs/`: ``` shared/specs/ โ”œโ”€โ”€ preflight.yaml # The compiled action spec โ”œโ”€โ”€ sdk.py # Python client SDK โ”œโ”€โ”€ sdk.ts # TypeScript client SDK โ”œโ”€โ”€ sdk.rs # Rust client SDK โ””โ”€โ”€ mcp_server.py # MCP server โ€” ready to plug into any LLM ``` --- ## How It Works ``` Target URL โ”‚ โ–ผ Crawler โ†’ BFS traversal, handles auth redirects & session state โ”‚ โ–ผ DOM Analyzer โ†’ Heuristic selector scoring (data-testid > id > class > xpath) โ”‚ โ–ผ Intent Engine โ†’ LLM/heuristic classifier maps elements to semantic actions โ”‚ โ–ผ API Sniffer โ†’ Intercepts XHR/Fetch traffic, upgrades UI actions to API calls โ”‚ โ–ผ Workflow Builder โ†’ Models action sequences as a Finite State Machine (FSM) โ”‚ โ–ผ Compiler โ†’ Generates preflight.yaml + SDKs + MCP server ``` The key insight: once `add_to_cart` is discovered as a `POST /api/cart/add` call, future executions skip the browser entirely and call the API directly. Faster, cheaper, more reliable. --- ## The `preflight.yaml` Format The output is a human-readable, version-controllable action spec: ```yaml version: 1.0.0 site: https://shop.example.com actions: login: description: Authenticates the user action_type: browser selector: '#login-form' parameters: - name: email type: string required: true selector: '#email' - name: password type: string required: true selector: '#password' assertions: - type: visible selector: '#dashboard' add_to_cart: description: Adds a product to the cart action_type: api # โ† upgraded to direct API call api: url: /api/cart/add method: POST parameters: - name: product_id type: string required: true - name: quantity type: integer required: true ``` Think of it as OpenAPI โ€” but for websites that were never designed to have an API. --- ## Benchmarks Full methodology and reproduction instructions: **[BENCHMARKS.md](BENCHMARKS.md)** Three suites, all numbers live and verifiable: ```bash make demo && python benchmark.py # mock store (controlled) python benchmark_real_sites.py # Wikipedia, HN, GitHub (live) python benchmark_developer_effort.py # developer effort (code metrics) ``` ### Performance โ€” Mock Store | Benchmark | Raw Playwright | Compiled SDK | Result | |---|---|---|---| | Token overhead | ~669 tokens/call | ~144 tokens/call | **78.5% fewer tokens** | | Action latency (avg) | 1,444 ms | 1.5 ms | **953ร— faster** | | DOM mutation reliability | 0% (20/20 fail) | 100% (0/20 fail) | **+100 pp** | | Python heap delta | 1,642 KB | 21 KB | **99% less** | | Selector self-healing | โŒ manual fix | โœ… 1,648 ms auto | similarity: 1.00 | ### Performance โ€” Real Sites (Wikipedia, Hacker News, GitHub) No mock servers. The "Compiled SDK" column is the API Shiny Fishstick discovers and exposes as a typed method. | Site | Page tokens | API tokens | Reduction | Speed-up | Reliability | |---|---|---|---|---|---| | Wikipedia | 40,833 | 131 | **99.7%** | 8ร— | 0% โ†’ 100% | | Hacker News | 2,298 | 1 | **100%** | 3.5ร— | 0% โ†’ 100% | | GitHub (vscode) | 34,292 | 5 | **100%** | 24ร— | 0% โ†’ 100% | | **Average** | **25,808** | **46** | **99.9%** | **12ร—** | **+100 pp** | ### Developer Effort โ€” Writing the Same Agent in Both Approaches Task: login โ†’ search โ†’ add\_to\_cart โ†’ checkout. | Metric | Raw Playwright | Shiny Fishstick | Improvement | |---|---|---|---| | Lines of code | 75 | 10 | **87% less** | | CSS selectors to hand-discover & maintain | 6 | 0 | **none to manage** | | Explicit browser sync calls | 12 | 0 | **100% less** | | Boilerplate lines (session/teardown/errors) | 43 of 75 (57%) | 1 of 10 (10%) | **98% less** | | Cyclomatic complexity | 11 | 1 | **10ร— simpler** | | Setup steps before first line of agent code | 10 | 3 | **7 fewer** | | Manual fixes needed per full site redesign | 8 | 0 | **zero maintenance** | The 75-line raw Playwright script and the 10-line Shiny Fishstick script do exactly the same thing. 57% of the Playwright version is pure infrastructure โ€” session capture, error handling, teardown. With Shiny Fishstick, 90% of the script is intent. > See [BENCHMARKS.md](BENCHMARKS.md) for full per-metric explanations, the complete code side-by-side, and honest caveats on every number. --- ## Features ### Core | Feature | What it does | |---|---| | ๐Ÿ” BFS Crawler | Traverses pages, handles auth redirects, captures session state | | ๐Ÿท๏ธ DOM Analyzer | Heuristic selector scoring for stable element targeting | | ๐Ÿค– Intent Classifier | Maps UI elements to semantic action names via LLM or heuristics | | ๐Ÿ”Œ API Upgrade Engine | Intercepts XHR/Fetch and converts UI clicks to direct API calls | | ๐Ÿ“ˆ Workflow FSM | Models multi-step action sequences as a state machine | | ๐Ÿ› ๏ธ SDK Generator | Outputs Python, TypeScript, and Rust clients | | ๐Ÿ“„ MCP Server | Auto-generates a JSON-RPC 2.0 MCP server for LLM tool use | | ๐Ÿ“‹ OpenAPI Exporter | Compiles discovered endpoints into standard OpenAPI 3.0 specs | ### Advanced | Feature | What it does | |---|---| | ๐Ÿ”’ Encrypted Credentials | Auth sessions encrypted at rest with AES-256 Fernet | | ๐Ÿ•ต๏ธ Stealth Mode | `playwright-stealth` integration to bypass bot detection | | ๐ŸŒ Proxy Support | Environment-based proxy config including authenticated proxies | | ๐Ÿ–ผ๏ธ iFrame Traversal | Scans nested frames recursively, generates `frame_locator` actions | | ๐Ÿ”„ State Reconciler | Detects selector drift across environments and auto-heals | | ๐Ÿงช Chaos Monkey | Mutates selectors and injects latency to test self-healing | | ๐Ÿงช Sandbox Orchestrator | Spins up mock site instances on demand for testing | | ๐Ÿฆ™ Offline LLM | Routes intent classification to local Ollama instances | | ๐Ÿ“ก WebSocket Agent Hub | Coordinates distributed crawl workers via WebSocket registry | --- ## Dashboard A Next.js frontend ships with the project for when you want a visual interface: - **Projects** โ€” create and manage compilation targets - **Crawl Feed** โ€” watch real-time logs from the Playwright crawler - **Action Explorer** โ€” inspect, edit, and add assertions to discovered actions - **FSM Visualizer** โ€” drag-and-drop workflow editor with live graph rendering - **SDK Download** โ€” copy or download compiled SDKs and specs - **Docs & Help** โ€” inline reference for the CLI, architecture, and FAQ --- ## CLI Reference ```bash # Compile a website into a spec + SDKs shiny compile https://example.com --out ./specs # Inspect a spec file shiny inspect ./specs/preflight.yaml # Validate spec structure shiny validate ./specs/preflight.yaml # Serve the spec as an MCP server shiny serve-mcp ./specs/preflight.yaml # Run layout regression tests shiny test ./specs/preflight.yaml ``` --- ## Examples ``` examples/ โ”œโ”€โ”€ ecommerce/ โ†’ preflight.yaml for a catalogue + checkout flow โ”œโ”€โ”€ saas-dashboard/ โ†’ preflight.yaml for a metrics dashboard โ”œโ”€โ”€ mcp-agent/ โ†’ Python agent calling a compiled MCP server โ””โ”€โ”€ real-life/ โ”œโ”€โ”€ github_issue_creator.yaml โ†’ Login + create issue on GitHub โ”œโ”€โ”€ stripe_checkout.yaml โ†’ Fill Stripe payment form โ””โ”€โ”€ hackernews_searcher.yaml โ†’ Search HN via compiled action ``` --- ## vs. Everything Else | | Playwright | Selenium | Browser Use | Shiny Fishstick | |---|:---:|:---:|:---:|:---:| | Semantic action layer | โŒ | โŒ | Partial | โœ… | | SDK generation | โŒ | โŒ | โŒ | โœ… | | MCP server generation | โŒ | โŒ | โŒ | โœ… | | OpenAPI export | โŒ | โŒ | โŒ | โœ… | | Self-healing selectors | โŒ | โŒ | โŒ | โœ… | | Workflow graph | โŒ | โŒ | โŒ | โœ… | | API upgrade engine | โŒ | โŒ | โŒ | โœ… | **Playwright** is a great browser control library. Shiny Fishstick sits on top of it to add a compilation and abstraction layer. **Browser Use / Computer Use** works by having an LLM look at screenshots and decide what to click. High token overhead, non-deterministic. Shiny Fishstick compiles the site upfront so execution is deterministic and cheap. **Selenium** is for testing. Shiny Fishstick is for agents. --- ## FAQ **Why not just use Playwright directly?** You can, but then you're maintaining CSS selectors manually and paying the full DOM-parsing token tax on every LLM call. Shiny Fishstick compiles the navigation layer once, so agents get typed methods instead of raw locators. **Can I run this without an LLM API key?** Yes. The intent classifier falls back to heuristic DOM analysis when no API key is configured. You can also point it at a local Ollama instance. **Is auth session data secure?** Yes. Captured cookies and localStorage values are encrypted before writing to the database using AES-256 Fernet symmetric encryption. **What if the website changes?** The state reconciler compares selector similarity across environments. When drift is detected, it proposes a healed selector. The chaos monkey suite lets you test how resilient your compiled spec is to layout changes. **Can I use the compiled spec without the dashboard?** Yes, the CLI is fully standalone. The dashboard is optional. --- ## Architecture & Design For deeper technical detail on the system internals: - **[architecture.md](architecture.md)** โ€” pipeline stages, data flow, module boundaries - **[design.md](design.md)** โ€” design system tokens, UI component guidelines - **[SECURITY.md](SECURITY.md)** โ€” vulnerability reporting and sensitive data handling --- ## Built With | Layer | Technology | |---|---| | Crawler & browser automation | [Playwright](https://playwright.dev/) + [playwright-stealth](https://github.com/nickmilo/playwright_stealth) | | Backend API | [FastAPI](https://fastapi.tiangolo.com/) | | Database | SQLite + [SQLAlchemy](https://www.sqlalchemy.org/) + [Alembic](https://alembic.sqlalchemy.org/) | | Frontend dashboard | [Next.js](https://nextjs.org/) 15 + React 19 | | Structured logging | [structlog](https://www.structlog.org/) | | Linting | [Ruff](https://docs.astral.sh/ruff/) | | AI intent classification | OpenAI / [Ollama](https://ollama.ai/) (offline) | --- ## The Vision We think the agentic web needs a shared action-spec standard โ€” the same way REST APIs needed OpenAPI. The goal is to build `preflight.yaml` into an open standard: 1. **Spec** โ€” a declarative format for web actions 2. **Compiler** โ€” automated discovery and compilation from any site 3. **Validator** โ€” `shiny validate` enforces correctness 4. **Registry** โ€” eventually, a place where sites publish their own specs If a site publishes a `preflight.yaml`, any agent can call it natively. No scraping, no guessing, no breakage. --- ## Contributing Issues, PRs, and feedback welcome. Read [CONTRIBUTING.md](CONTRIBUTING.md) to get started. If you're building AI agents, browser automation tools, or MCP integrations and hit a limitation โ€” open an issue. That's the most useful contribution right now. --- ## License Apache 2.0. See [LICENSE](LICENSE).