Skip to main content
Glama
AndroidMCP Framework

AndroidMCP Framework

by kshivam1177
README.md
# test-orbit

**Record once, replay fast, forever.**

test-orbit is a fast testing kit for any app — Android, iOS, Flutter, and web. A coding agent records a flow once in plain language, the flow is saved as a deterministic test, and the test replays with **zero LLM calls**: Maestro YAML for mobile, Playwright for web.

[![npm version](https://img.shields.io/npm/v/test-orbit.svg)](https://www.npmjs.com/package/test-orbit)
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](LICENSE)

- **npm:** https://www.npmjs.com/package/test-orbit
- **Repo:** https://github.com/kshivam1177/test-orbit
- **Version:** 0.1.53 — requires Node.js >= 18

## What it is

- **Record → save → replay.** The host agent drives the app in plain language while test-orbit records every action with the `(screen, variant, elementId)` it acted on. The recording converts to a canonical JSON test case plus a generated Maestro YAML. `orbit run` replays the YAML.
- **Variant-aware.** A screen is learned once with its variants (for example, checkout with cash-on-delivery vs card). The runner detects the variant before a run and fails with evidence instead of running against the wrong state.
- **Deterministic replay.** The saved test is the test. Replay needs no model, no API key, and no cost — the run report records 0 LLM calls.
- **No hardcoded flows.** No demo flow, canned flow, or example test is baked in. Test flows come only from recording the actual flow of a real app, at testing time, on your apps.
- **One tool for every app.** The same record → convert → run loop works for Android, iOS, Flutter, and web, with one folder per platform under `.test-orbit/`. A test recorded on one platform can be copied to another with `orbit copy`.

## What it is not

- Not an in-server LLM planner. The LLM lives in the host agent (Claude Code, Copilot, and friends), never inside test-orbit's code. It plugs in at three points only: **plan** (once per flow, at record time), **convert** (once per flow), and **replay (zero times)**.
- Not a custom YAML executor and not self-healing. Maestro runs the YAML; Playwright runs the web test. test-orbit wraps them, it does not re-implement them.
- Not a recorder of coordinates. Actions address stable element ids, never screen coordinates.
- Not a place for secrets. Typed values become `${ENV_VAR}` references at conversion time and are redacted in reports, logs, and failure bundles.

## Screenshots

The `orbit` CLI — every command, with flags:

![orbit --help](docs/images/orbit-help.png)

The main `test-orbit` CLI:

![test-orbit --help](docs/images/test-orbit-help.png)

`test-orbit doctor` on a machine without the Android toolchain — it says plainly what is missing:

![test-orbit doctor](docs/images/test-orbit-doctor.png)

All three screenshots show real output captured from the built CLI. The doctor screenshot was taken on a machine with no Android SDK, Java, Maestro, or Playwright installed, so it reports exactly that.

## Install

```bash
npm install -g test-orbit
```

Then check your machine:

```bash
test-orbit doctor
```

Or run on demand with no global install:

```bash
npx -y test-orbit@latest mcp
```

Update a global install later with:

```bash
test-orbit update
```

## Quick start

```bash
# 1. In your app project, initialise test-orbit
test-orbit setup

# 2. Check the toolchain (adb, Java, Maestro, ...)
test-orbit doctor

# 3. In your coding agent, learn the first screen, then record a flow.
#    (These steps run through the agent's MCP tools — see below.)
#    - orbit_learn_screen   → saves the screen + its elements
#    - orbit_start_recording → drive the app in plain language
#    - orbit_stop_recording  → saves the recording
#    - orbit_convert_recording → JSON test case + Maestro YAML
#    - orbit_replay_recording  → replays it, 0 LLM calls

# 4. Or use the orbit CLI directly
orbit learn --screen login --variantId default --project .
orbit convert --recording login-flow --test login-flow --project .
orbit run --test login-flow --project .
```

## How it works

```mermaid
flowchart LR
    Learn["learn — screens/<screenId>/"] --> Record["record — recordings/<flowId>.json"]
    Record --> Convert["convert — testcases/<testId>.json + tests/<testId>.yaml"]
    Convert --> Run["run — Maestro replay, 0 LLM calls"]
    Run --> Check["check — screen-map.json"]
```

1. **Learn** — capture a screen once and save a reusable screen definition: screenshot, semantic element selectors, normalised coordinates, and a form specification. Each screen can have variants (for example, a login screen with and without a password field). Re-learning an existing screen refuses without `force: true`; with force, it keeps `.bak` backups and reports the added/removed/renamed/changed element diff.
2. **Record** — opt-in recording of the UI actions the agent performs (`tap`, `long_press`, `swipe`, `type_text`, `key_press`). Password/OTP-like fields are automatically redacted; `redactText: true` redacts all typed text. Existing recordings are never overwritten — use a new `flowId` for each capture.
3. **Convert** — the recording becomes a canonical JSON test case (`schemaVersion: 2`) plus a generated Maestro YAML. Typed values become `${ENV_VAR}` references with a `<testId>.env.example` manifest; assertions are derived mechanically from the recorded screen sequence. Unmappable elements fail loudly, naming the step.
4. **Run** — pre-flow detection first (fresh hierarchy dump + variant detection; on mismatch it fails with evidence and never runs Maestro against an unknown screen), then `maestro test`, then a failure bundle on failure. The run report records per-step timing from Maestro's own report and an LLM-call count of 0 for replay.
5. **Check** — `orbit generate-map` builds `screen-map.json` from learned screens and v2 recordings (edges proved by navigation steps); `orbit check` verifies the map and the learned screens and exits 1 when any rule fails.

Element grounding falls back hierarchy → Tesseract OCR → LLM vision, only at record/convert time, never during replay.

## Architecture

```mermaid
flowchart TB
    Agent["Host agent — the LLM (Claude Code, Copilot, ...)"]
    MCP["test-orbit MCP server — stdio"]
    Tools["121 MCP tools in 12 workflows"]
    OrbitTools["orbit_* tools — record / learn / replay / convert / copy"]
    Core["src/testorbit — core / domain / application / infrastructure / cli"]
    Adapters["Adapters — adb · WebDriverAgent · Patrol · Maestro · Playwright"]
    Devices["Android device or emulator · iOS simulator · Flutter app · Browser"]
    Store[".test-orbit/<platform>/ — screens, recordings, testcases, tests, screen-map.json"]

    Agent --> MCP
    MCP --> Tools
    Tools --> OrbitTools
    OrbitTools --> Core
    Core --> Adapters
    Adapters --> Devices
    Core --> Store
```

The code is layered: `core/` (pure logic: stable element ids, fingerprinting, matching) and `domain/` (schemas) have no outside dependencies; `application/` holds the use cases (learn, record, convert, run, copy, check); `infrastructure/` holds the swappable adapters (filesystem, adb hierarchy, WebDriverAgent, Patrol dumps, the Maestro subprocess); `cli/` wires it together. MCP tool handlers stay in `src/tools/` — there is no `src/testorbit/tools/`. The server itself never calls an LLM and holds no API key.

## CLI reference

### `test-orbit` — the main CLI

```text
$ test-orbit --help
test-orbit <command>

Commands:
  test-orbit mcp        Start the MCP server over stdio (for MCP clients)
  test-orbit doctor     Check the local Android toolchain (adb, java, gradle, SDK, emulator)
  test-orbit update     Update test-orbit if a newer npm version exists and clear the npx execution cache
  test-orbit workflows  List every workflow, its tool count, and whether it is on by default
  test-orbit tools      List every tool, grouped by workflow
  test-orbit setup      Initialize .test-orbit/ in the current project; use --migrate to copy legacy files safely
  test-orbit skill-gen  Generate a test-orbit skill file for your coding agent

Options:
  --version  Show version number
  --help     Show help
```

(The table above joins the descriptions from the real `--help` output, which wraps at 80 columns in a narrow terminal.)

- `test-orbit mcp` — start the MCP server over stdio, for MCP clients.
- `test-orbit doctor` — check the local toolchain. Required checks: `adb`, `java`, `ANDROID_HOME`. Optional checks: `gradle`, Android CLI, Tesseract OCR, Maestro, Playwright, WebDriverAgent (iOS). See [Troubleshooting](#troubleshooting).
- `test-orbit setup` — create `.test-orbit/config.yaml` in the current project and write a project setup guide. Use `--migrate` to copy files from the legacy `.android-build-mcp/` / `.androidbuildmcp/` directories without overwriting existing content. The old directory is not deleted automatically.
- `test-orbit skill-gen` — generate a test-orbit skill file for your coding agent. Supported agents: `claude`, `codex`, `gemini`, `antigravity`, `cursor`, `copilot`, `other`, `auto`.
- `test-orbit workflows` / `test-orbit tools` — list workflows and tools (see below).
- `test-orbit update` — update a global install to the latest npm version and clear the npx execution cache.

### `orbit` — the test-orbit CLI

```text
$ orbit --help
Usage: orbit <command> [options]

Commands:
  detect --screen <id> [--platform <platform>] [--project <path>]
         [--target <id>] [--hierarchy-file <path>]
         [--wda-url <url>] [--patrol-dump <path>]
         Dump the live hierarchy, run variant detection, print the
         variant id or unknown with evidence.
  learn --screen <id> --variantId <name> [--required <a,b>]
        [--learned-from <text>] [--platform <platform>]
        [--project <path>] [--target <id>] [--hierarchy-file <path>]
        Learn one variant of a screen from a hierarchy dump.
  record --plan-file <path> [--no-dry-run] [--platform <platform>]
         [--project <path>]
         Print the plan that would be recorded (dry-run is the
         default); writes nothing. Live recording is via MCP.
  convert --recording <flowId> --test <testId> [--goal <text>]
          [--app-id <id>] [--app-version <version>]
          [--loading-indicators <file>]
          [--platform <platform>] [--project <path>]
          Convert a recording to a JSON test case + Maestro YAML.
          The loading-indicators file is JSON like
          { "checkout": { "elementId": "checkout.spinner" } }.
  run --test <testId> [--platform <platform>] [--project <path>]
      [--target <id>] [--hierarchy-file <path>]
      [--wda-url <url>] [--patrol-dump <path>]
      Pre-flow detection, then maestro test, then the failure bundle.
  copy --test <testId> --from <platform> --to <platform>
       [--as <newTestId>] [--loading-indicators <file>] [--project <path>]
       Copy a test across platform folders, re-resolving elements.
  generate-map [--platform <platform>] [--project <path>]
       Generate <platform>/screen-map.json from learned screens
       and v2 recordings (edges proved by navigation steps).
  check [--platform <platform>] [--project <path>]
       Check the screen map and learned screens (check-screen-map);
       exit 1 when any rule fails.
  rename-screen --screen <old> --to <new>
       [--platform <platform>] [--project <path>]
       Rename a screen id and rewrite every reference to it,
       then regenerate the map.
```

Flags: `--platform` is one of `android`, `ios`, `flutter`, `web`. `--project` is the project root (defaults to the current directory). `--hierarchy-file` lets a command read a saved hierarchy dump instead of a live device. `orbit record` is a dry-run by default — it prints the plan that would be recorded and writes nothing; live recording happens through the MCP tools.

## MCP tools

The server exposes **121 tools in 12 workflows** (run `test-orbit workflows` to list them). The testing kit itself is seven `orbit_*` tools:

| Tool | Workflow | What it does |
| --- | --- | --- |
| `orbit_start_recording` | ui-automation | Start an opt-in recording of UI actions on the selected device. Actions and typed text are stored in the project recording file; password/OTP-like fields are automatically redacted. |
| `orbit_stop_recording` | ui-automation | Stop the active recording and persist its actions plus start/stop screenshots under `.test-orbit/`. |
| `orbit_learn_screen` | ui-automation | Capture the current screen once and save a reusable screen definition: screenshot, semantic element selectors, normalised coordinates, and a form specification, under `.test-orbit/<platform>/screens/<screenId>/`. |
| `orbit_replay_recording` | ui-automation | Replay a saved recording. Semantic selectors are preferred; coordinate actions are scaled to the current display size. Stops on first failure by default and saves a timestamped report plus failure screenshot/hierarchy evidence. |
| `orbit_detect_variant` | ui-automation | Identify the current screen and variant from a fresh hierarchy dump and return the identified `(screen, variant)` with match evidence and diff — or `unknown` with evidence. |
| `orbit_convert_recording` | testing-intelligence | Convert a saved recording (schema v1 or v2) into a canonical JSON test case (schemaVersion 2) plus generated Maestro YAML. Typed values become `${ENV_VAR}` references; assertions are derived mechanically from the recorded screen sequence. |
| `orbit_copy_test_case` | testing-intelligence | Copy a canonical JSON test case from one platform folder to another. Each step's elementId is re-resolved against the target platform's learned screens; the target Maestro YAML is regenerated; the copy is marked "copied, unverified" until its first green run. |

The full workflow list (from `test-orbit workflows`):

```text
device (11 tools) [enabled by default]
  Build, install, launch, stop, test, and transfer files to/from Android targets.
emulator-management (10 tools)
  Create, boot, wipe, and configure AVDs: location, dark/light appearance, status-bar demo mode, screen recording.
ui-automation (28 tools) [enabled by default]
  Semantic UI snapshots, screenshot OCR coordinates, selector-based form filling, declarative JSON workflows, tap/swipe/drag/type/key/gesture/wait/batch.
debugging (6 tools) [enabled by default]
  Logcat streaming, crash and ANR extraction, log clearing, full adb bugreport.
project-discovery (4 tools)
  Find Gradle project roots, list modules and build variants, inspect build configuration.
gradle-module (5 tools)
  Build/test/run/list/stop a standalone Gradle module (pure-JVM/Kotlin library or CLI).
session-management (4 tools) [enabled by default]
  View, set, clear, and switch between named session-default profiles.
doctor (1 tool) [enabled by default]
  Environment diagnostics: adb, Java, Gradle, Android SDK, emulator and optional Google Android CLI.
android-cli (6 tools)
  Optional integration with Google Android CLI 1.0+.
testing-intelligence (35 tools) [enabled by default]
  Project test discovery, change-aware test planning, saved UI workflows, native/Flutter test matrices, unified resumable E2E runs, strict evidence gates, and consolidated reports.
cross-platform-automation (10 tools)
  Cross-platform runtime preflight, saved-suite orchestration, device-fleet registry and exclusive leases, evidence manifests, iOS simulator management, Android/iOS app lifecycle, deterministic assertions, failure diagnosis, and JSON/Markdown/JUnit reporting.
workflow-discovery (1 tool) [enabled by default]
  List and toggle which workflows are enabled for this running server session.
```

The `testing-intelligence` workflow also covers the wider test lifecycle: `analyze_test_project`, `audit_screen`, `save_test_case`, `write_test_report`, `plan_change_aware_test_run` (Git changes → reviewable test plan), `run_unified_test_run` (selected suites + saved UI cases under one resumable run ID), `validate_test_evidence_bundle`, `inspect_test_runtime`, `analyze_test_quality`, `evaluate_test_quality_gate`, `run_test_suite_matrix`, and `approve_selector_repair` (a proposed selector is validated against a fresh hierarchy and needs explicit approval before a saved test changes). See [docs/md-files/testing-framework.md](docs/md-files/testing-framework.md) and [docs/md-files/autonomous-test-lifecycle.md](docs/md-files/autonomous-test-lifecycle.md). The `device` workflow's `test_device` routes Flutter unit/widget tests through `flutter test` and can run device integration tests with `flutter test -d <device-id> integration_test` when `integration_test/` exists.

## Connect an MCP client

```json
{
  "mcpServers": {
    "test-orbit": {
      "command": "npx",
      "args": ["-y", "test-orbit@latest", "mcp"]
    }
  }
}
```

See [coding agent setup](docs/md-files/agent-setup.md) for Claude Code, Codex, Gemini CLI, Antigravity, and VS Code/GitHub Copilot instructions. Android Studio's documented MCP client requires HTTP, while this server currently exposes stdio only; see [supported clients](docs/md-files/supportedclients.md).

### Local checkout

Build with `npm ci && npm run build`, then configure the MCP client to launch the built entry point `build/cli/index.js mcp`. Use an absolute path to your own checkout; do not copy machine-specific paths from examples.

## The canonical test case and the generated Maestro YAML

One canonical form per platform (mobile): the **JSON test case** (`<platform>/testcases/<testId>.json`, `schemaVersion: 2`) plus the **generated Maestro YAML** (`<platform>/tests/<testId>.yaml`). The export is one-way and lossy: the JSON is canonical, the YAML is generated from it. Every generated YAML carries a header with the source JSON's hash, `generatedAt`, and `schemaVersion: 2`. CI regenerates the YAML and fails on diff.

The YAML below is real output from the built exporter (`buildMaestroFlow` + `renderMaestroYaml`), generated from a one-step example test case (tap the submit button on a learned login screen). The JSON abridged below it is the test case that produced it.

```yaml
# Generated by test-orbit — one-way/lossy export. Never re-import into JSON.
# sourceJsonSha256: 9cda863b54a54944e1f15f4a867be41b766b38426eb0f226ff66f4ddc92a66c9
# generatedAt: 2026-12-01T00:00:00.000Z
# schemaVersion: 2
appId: com.shop.app
name: login-flow
onFlowComplete:
  - clearState: null
---
- launchApp:
    clearState: true
    appId: com.shop.app
- tapOn:
    id: com.shop.app:id/submit
- assertVisible:
    id: com.shop.app:id/username
```

```json
{
  "id": "login-flow",
  "goal": "Log in",
  "steps": [
    {
      "index": 1,
      "screen": "login",
      "variant": "login.password",
      "action": "tap",
      "elementId": "login.submit",
      "timeoutMs": 3000,
      "assert": {
        "kind": "variant-present",
        "variant": "login.password"
      }
    }
  ]
}
```

The converter adds a variant assertion (`assertVisible` on an element unique to the expected variant) to variant-scoped tests. Selectors prefer `resourceId`, then `contentDesc`; an element that cannot be mapped to a Maestro selector fails loudly, naming the step, instead of guessing.

## Cross-platform copy

A test recorded on one platform can be reused on another:

```bash
orbit copy --test login-flow --from android --to ios
orbit copy --test login-flow --from android --to ios --as login-flow-ios
```

`orbit copy` copies the canonical JSON across platform folders, re-resolves each step's elementId against the target platform's learned screens (stable-selector fields, then unique contentDesc, then className + sibling index — never raw text or list order), and regenerates the target Maestro YAML. The copy records `provenance.copiedFrom` and stays "copied, unverified" until its first green run on the target platform. Unmapped elements fail loudly, naming the step. The same copy is available to agents as the `orbit_copy_test_case` MCP tool.

A cross-platform suite can also be declared as one JSON file. `examples/cross-platform/login-smoke.json` ships in the repo as the format example (placeholder app ids — replace them with your own):

```json
{
  "schemaVersion": "1.0",
  "id": "login-smoke",
  "name": "Cross-platform login smoke test",
  "platforms": ["android", "flutter", "ios", "web"],
  "targets": {
    "android": { "appId": "com.example.app", "targetId": "emulator-5554" },
    "ios": { "appId": "com.example.app", "deviceName": "iPhone Simulator" },
    "web": { "baseUrl": "https://example.test" }
  },
  "variables": { "USERNAME": "replace-at-runtime", "PASSWORD": "replace-at-runtime" },
  "steps": [
    { "id": "enter-username", "type": "type", "selector": { "strategy": "accessibilityId", "value": "username" }, "value": "${USERNAME}" },
    { "id": "submit-login", "type": "tap", "selector": { "strategy": "accessibilityId", "value": "login-submit" } },
    { "id": "assert-home-title", "type": "assert", "assertion": { "kind": "textContains", "selector": { "strategy": "accessibilityId", "value": "home-title" }, "expected": "Home" } }
  ]
}
```

(Excerpted from `examples/cross-platform/login-smoke.json`; see the file for the full suite, including the password step and wait conditions.)

## Storage layout

Everything test-orbit writes lives inside the project folder, under `.test-orbit/` — one folder per platform:

```text
<projectRoot>/.test-orbit/
  config.yaml                 # project config (created by `test-orbit setup`)
  android/
    screens/<screenId>/       # learned screens: elements.json + variants/<variantId>.json
    recordings/<flowId>.json  # versioned action log (schema v1 or v2)
    recording-evidence/<flowId>/  # start/stop screenshots, replay failure evidence
    testcases/<testId>.json   # canonical JSON test cases (schemaVersion 2)
    tests/<testId>.yaml       # generated Maestro YAML (never edit by hand)
    test-reports/             # timestamped run reports (run-report.json, 0 LLM calls)
    screen-map.json           # generated map of screens, variants, and edges
  ios/                        # same layout, for iOS (Maestro + WebDriverAgent)
  flutter/                    # same layout, for Flutter (Patrol tree, Maestro replay)
  web/                        # same layout, for web (Playwright tests)
```

The workspace root is discovered by walking upward to the nearest `.test-orbit/config.yaml` or `.git` marker, with the current directory as fallback. Generated artifacts are local outputs and are ignored by Git by default. Nothing is uploaded anywhere by the framework — recordings are local project files.

## Configuration

`test-orbit setup` creates `.test-orbit/config.yaml`. Every field is optional; the whole file is optional. The shipped example (`config.example.yaml`):

```yaml
# test-orbit project config.
# Created at .test-orbit/config.yaml by `test-orbit setup`.
# Every field is optional; the whole file is optional.

schemaVersion: 1

# MCP workflows exposed to your coding agent.
enabledWorkflows:
  - device
  - ui-automation
  - session-management
  - doctor
  - workflow-discovery
  - testing-intelligence
  - debugging

customWorkflows: {}

# UI automation uses Android SDK platform-tools (adb); no Python runtime required.
automationBackend: adb

disableSessionDefaults: false
debug: false

sessionDefaults:
  projectPath: . # workspace root; Flutter/native project roots are auto-detected
  module: :app
  variant: debug
  targetId: null
  avdName: null
  applicationId: null
  gradleTaskPrefix: null

paths:
  adbPath: adb
  gradlePath: null
  androidHome: null
  javaHome: null
  androidCliPath: android
```

## Platform support

| Platform | Record / learn | Replay | Requirements |
| --- | --- | --- | --- |
| **Android** | adb hierarchy + Tesseract OCR fallback | Maestro (`maestro test`) | Android SDK platform-tools (`adb`), Java, `ANDROID_HOME`; emulator or physical device. All three are required checks in `test-orbit doctor`. |
| **iOS** | WebDriverAgent `/source` hierarchy | Maestro | A Mac with Xcode, WebDriverAgent running, and `idb`. `test-orbit doctor` checks that WebDriverAgent answers on its default local port. |
| **Flutter** | Semantics labels + Patrol tree dumps | Maestro | A Flutter app with semantics enabled; Patrol as the tree provider during record/learn. Replay stays Maestro. `test_device` runs unit/widget tests with `flutter test`. |
| **Web** | — | Playwright | Playwright installed (`test-orbit doctor` checks it via `npx`). Web's canonical form is the Playwright test itself — no JSON test case, no converter, and no screen map in v1. The Playwright exporter is deferred to v2, after Maestro is stable. |

Honest limits, as of v0.1.53:

- **Live proofs need a real app.** Maestro replay, multi-variant proofs, and the web pilot have been built and unit-tested, but the end-to-end live proof runs against a real app on a real device, on your computer. No pilot app, APK, or demo flow ships in this repo — pilot apps are provided at testing time only.
- **iOS needs a Mac.** Real iOS testing needs macOS with Xcode; this Linux environment cannot run it.
- **Web is v1-limited.** The converter and screen map cover mobile (Android/iOS/Flutter). Web record/learn/export is designed around Playwright but the exporter is deferred to v2.
- **Recording captures five core actions** (`tap`, `long_press`, `swipe`, `type_text`, `key_press`). Compound actions executed inside `batch` or `interact_screen` are not expanded into individual recording steps yet.
- **The LLM is the planner, not the runner.** An in-server planner is deferred to a Phase 10 decision and does not exist yet; the host agent plans each step at record time.

## Project structure

```text
test-orbit/
  README.md                  # this file
  LICENSE                    # MIT
  package.json               # bins: test-orbit, orbit, skill-gen
  config.example.yaml        # project config example
  src/
    cli/                     # test-orbit CLI (mcp, doctor, setup, skill-gen, ...)
    mcp/                     # MCP server entry point (stdio)
    tools/                   # one TypeScript module per MCP tool, grouped by workflow
      device/ emulator-management/ ui-automation/ debugging/
      project-discovery/ gradle-module/ session-management/
      doctor/ android-cli/ testing-intelligence/
      cross-platform-automation/ workflow-discovery/
    testorbit/               # the testing kit (layered)
      core/                  # pure logic: stable element ids, fingerprints, matching
      domain/                # schemas: recordings, test cases, Maestro, screen map
      application/           # use cases: learn, record, convert, run, copy, check
      infrastructure/        # adapters: filesystem, adb, WebDriverAgent, Patrol, Maestro
      cli/                   # orbit CLI commands
      config/                # test-orbit config
      test-fixtures/         # unit-test fixtures (test data, never example tests)
    automation/              # the recorder (writes .test-orbit/<platform>/recordings/)
    testing-intelligence/    # change-aware test planning, evidence, reports
    session/ config/ platform/ utils/ workflows.ts
  docs/
    designs/                 # approved design summaries + SITEMAP.md index
    md-files/                # workflow docs, agent setup, testing framework, ...
    generated-tool-inventory.md  # the full 121-tool inventory
    images/                  # terminal screenshots used by this README
  examples/
    cross-platform/          # login-smoke.json, android-lifecycle.json (format examples)
    test-orbit-pilot/        # one folder per pilot app, created at testing time
    mcp-config.example.json
  scripts/                   # tooling (e.g. generate-tool-inventory.mjs)
```

TypeScript compiles from `src/` to generated `build/` (ignored by Git, along with `dist/`, `node_modules/`, `.test-orbit/`, and `coverage/`). Do not commit generated output.

## How it's built

- **UI automation:** JavaScript/TypeScript plus Android SDK platform-tools (`adb`) only. The optional Python `uiautomator2` bridge has been removed; no Python runtime is required.
- **Device targeting:** emulators and physical devices are unified through ADB. Explicit target, session default, then single connected target are tried in that order.
- **MCP transport:** stdio for local coding agents. Streamable HTTP is not implemented yet.
- **Tools:** one TypeScript module per tool under `src/tools/<workflow>/`.
- **Quality bar:** strict TypeScript, Zod at every parse boundary, no `any`, co-located tests (`<source>.test.ts`), functions ≤ 50 lines, files ≤ 300 lines, JSDoc on public functions, no `console.log` in shipped code.

## Examples

- [`examples/cross-platform/login-smoke.json`](examples/cross-platform/login-smoke.json) — a cross-platform login smoke suite (Android, Flutter, iOS, web) in the suite format. Placeholder app ids; replace them with your own.
- [`examples/cross-platform/android-lifecycle.json`](examples/cross-platform/android-lifecycle.json) — an Android lifecycle suite in the same format.
- [`examples/test-orbit-pilot/README.md`](examples/test-orbit-pilot/README.md) — where pilot apps live at testing time: one folder per app, platform-wise, inside the project folder only.
- [`examples/mcp-config.example.json`](examples/mcp-config.example.json) — example MCP client configuration.
- [`config.example.yaml`](config.example.yaml) — the project config example, quoted in full above.

No flows are shipped in this repo. Test flows come only from recording the actual flow of a real app, once the codebase is ready, at testing time, on your apps. Unit-test fixtures for the pure logic (element id, matcher, fingerprint, converter) live in `src/testorbit/test-fixtures/` — they are test data, never pretend flows and never shipped as example tests.

## Troubleshooting

Run `test-orbit doctor` first — it names the exact problem.

| Symptom | What it means | Fix |
| --- | --- | --- |
| `adb: Executable not found on PATH` | Android platform-tools are not installed or not on PATH | Install the Android SDK platform-tools and put `adb` on PATH |
| `java: Executable not found on PATH` | No JDK on PATH | Install a JDK |
| `ANDROID_HOME: (not set ...)` | The SDK location is unknown | Set `ANDROID_HOME` / `ANDROID_SDK_ROOT`, or `paths.androidHome` in `.test-orbit/config.yaml` |
| `Maestro: Executable not found on PATH` | Maestro is not installed | Install Maestro (`maestro --version` should work); replay runs `maestro test` |
| `Playwright: npm error ...` | Playwright is not installed | Install Playwright; doctor checks it with `npx --no-install playwright --version` |
| `WebDriverAgent (iOS): fetch failed` | WDA is not answering on its default local port | Start WebDriverAgent on the Mac before iOS runs |
| `config: ... does not parse` | `.test-orbit/config.yaml` is invalid | Fix the YAML; `test-orbit doctor` validates it |
| Replay stops at the first failed step | That is the default | Pass `continueOnFailure` to keep going, or fix the failing step first |
| `Recording "<flowId>" already exists` | Recordings are never overwritten | Use a new `flowId` for each capture |
| Re-learning a screen is refused | A learned screen already exists | Re-learn with `force: true`; the previous files are kept as `.bak` and the element diff is reported |
| A recorded tap hits the wrong element | An ambiguous selector matched more than one element | test-orbit fails rather than tapping an arbitrary element — learn the screen again or narrow the selector |
| Typed text will not replay | The text was redacted (password/OTP-like fields are redacted automatically) | Edit the recording JSON to supply the value safely — redacted text cannot be replayed as-is |
| `orbit record` wrote nothing | It is a dry-run by default | It prints the plan that would be recorded; live recording happens through the `orbit_start_recording` MCP tool |
| The Maestro YAML looks stale | It is generated, never edited by hand | Re-run `orbit convert`; CI regenerates the YAML and fails on diff |

## Development

```bash
npm ci
npm run build
npm run typecheck
npm run lint
npm test
npm run test-orbit:ci   # typecheck, lint, layout check, tests, coverage — the local CI
```

The GitHub workflow is a handover copy (the App token cannot push workflow files): add it manually as `.github/workflows/test-orbit.yml`. Its device jobs are gated on pilot-app inputs that do not exist yet — there is no pilot app, no APK, no demo flow in this repo.

Design docs live under `docs/designs/` with a `SITEMAP.md` index. The full implementation plan (132 KB, Parts A–F, Phases 0–10) lives outside the repo; the design docs are short summaries + pointers, and where a doc and the plan disagree, the plan wins.

## Contributing

Small, reviewable commits (Conventional Commits: `feat:`, `fix:`, `docs:`, `test:`, ...). Run `npm run test-orbit:ci` before pushing — typecheck, lint, layout, tests, and coverage all have to pass. Verify every claim against live code before saying it is done, and name limits honestly: live device proofs need a real app on a real device, and this environment has none.

## License

MIT — see [LICENSE](LICENSE).