$ show jackwener/OpenCLI
OpenCLI is a large-scale CLI framework that provides over 100 structured commands for interacting with diverse web services (social media, e-commerce, finance, academic databases, AI tools, etc.) via browser automation or direct HTTP APIs. It is designed for AI agents and developers who need deterministic, machine-readable access to websites. The architecture centers on a command registry pattern where each command declares metadata (site, name, access level, auth strategy, arguments, output columns) and either a function or a declarative pipeline of steps (navigate, evaluate, map, filter, sort, limit). Authentication is handled per-site via a shared helper that registers login/whoami commands. The tool manages browser sessions through a Chrome extension (Browser Bridge) and CDP, with a daemon for persistent connections. It includes a plugin system, shell completion, observation/tracing with redaction, and a skill system for AI agent documentation. The codebase is actively maintained with frequent releases, extensive unit tests, and e2e tests, but its heavy reliance on site-specific DOM selectors and API endpoints introduces fragility and maintenance burden.
The LLM identified 5 files worth highlighting for reuse:
Defines a hierarchy of custom error classes (ArgumentError, CommandExecutionError, EmptyResultError, AuthRequiredError, TimeoutError, CliError) with machine-readable codes and Unix exit codes. Used consistently across all adapters and core modules. This is a standalone, well-crafted pattern that can be extracted into any CLI project to provide structured error handling for AI agents and programmatic consumers.
Implements reusable data transformation steps (select, map, filter, sort, limit) for the pipeline system. Each step is a pure function that takes a data array and parameters, returning a transformed array. These steps are decoupled from browser automation and can be extracted and reused in any data processing pipeline (e.g., ETL, API response shaping). Demonstrates clean functional composition.
Provides a reusable `registerSiteAuthCommands` function that generates `whoami` and `login` commands for any site using cookie-based authentication. It accepts a site name, cookie name, and a probe function to verify login state. This pattern is used by dozens of adapters and can be extracted to standardize auth command registration across any CLI tool that manages multiple authenticated services.
Implements a disk-based network request cache with 24-hour TTL, file permissions (0o600), and key derivation from request method/URL/headers. Used to persist captured browser network responses for replay and analysis. The caching logic is self-contained and could be reused in any Node.js application that needs to cache HTTP responses with security-conscious file handling.
Provides a comprehensive redaction system for sensitive data in network requests and responses. It scrubs headers (cookies, authorization), tokens, JWTs, and PII patterns from URLs, bodies, and query parameters. The redaction logic is modular, configurable, and can be extracted into any application that needs to sanitize logs or captured traffic for security or privacy compliance.