Turn any website into a CLI using browser session reuse and AI-powered command discovery
triggers
["use opencli to scrape a website","make a CLI command for a website","automate browser with opencli","add a new opencli adapter","extract data from website using CLI","opencli explore and synthesize commands","create yaml adapter for opencli","opencli browser automation"]
OpenCLI turns any website into a command-line interface by reusing Chrome's logged-in browser session. It supports 19 sites and 80+ commands out of the box, and lets you add new adapters via TypeScript or YAML dropped into the clis/ folder.
Installation
# Install globally via npm
npm install -g @jackwener/opencli
# One-time setup: discovers Playwright MCP token and distributes to all tools
opencli setup
# Verify everything is working
opencli doctor --live
Prerequisites
Node.js >= 18.0.0
Chrome browser running and logged into the target site
Pattern: Authenticated API Extraction (Cookie Injection)
// When a site exposes a JSON API but requires login cookiesasyncrun(options, browser) {
const page = await browser.currentPage();
// Navigate first to ensure cookies are activeawait page.goto("https://api.example.com");
const data = await page.evaluate(async () => {
const res = awaitfetch("/api/v1/feed?limit=20", {
credentials: "include", // reuse browser cookies
});
return res.json();
});
return data.items;
}
# Diagnose token and config across all tools
opencli doctor
# Test live browser connectivity
opencli doctor --live
# Fix mismatched configs interactively
opencli doctor --fix
# Fix all configs non-interactively
opencli doctor --fix -y
Testing
npm run build
# Run all tests
npx vitest run
# Unit tests only
npx vitest run src/
# E2E tests only
npx vitest run tests/e2e/
# Headless browser mode for CI
OPENCLI_HEADLESS=1 npx vitest run tests/e2e/
Troubleshooting
Symptom
Fix
Failed to connect to Playwright MCP Bridge
Ensure extension is enabled in Chrome; restart Chrome after install
Empty data / Unauthorized
Open Chrome, navigate to the site, log in or refresh the page
Node API errors
Upgrade to Node.js >= 18
Token not found
Run opencli setup or opencli doctor --fix
Stale login session
Visit the target site in Chrome and interact with it to prove human presence
Debug Verbose Mode
# See full pipeline execution steps
opencli bilibili hot -v
# Check what explore discoveredcat .opencli/explore/mysite/endpoints.json
cat .opencli/explore/mysite/auth.json
Project Structure (for Adapter Authors)
opencli/
├── clis/ # Drop .ts or .yaml adapters here (auto-registered)
│ ├── bilibili.ts
│ ├── twitter.ts
│ └── hackernews.yaml
├── src/
│ ├── types.ts # CLIAdapter, Command interfaces
│ ├── browser.ts # Playwright MCP bridge wrapper
│ ├── loader.ts # Dynamic adapter loader
│ └── output.ts # table/json/yaml/md/csv formatters
├── tests/
│ └── e2e/ # E2E tests per site
└── CLI-EXPLORER.md # Full AI agent exploration workflow