@astralyn/minicpa
v0.5.2
Published
Manage, run, and update one local CLIProxyAPI instance
Maintainers
Readme
MiniCPA
MiniCPA provides a cross-platform cpa command to bootstrap, manage, inspect, and update a local CLIProxyAPI instance.
Architecture & Principles
MiniCPA is designed as an un-opinionated process supervisor and binary manager around a single local CLIProxyAPI (CPA) instance:
- Ownership Boundary: MiniCPA creates a minimal bootstrap
config.yamlonly on first initialization. After that, configuration, provider credentials, routing, and Web panel provisioning belong entirely to CLIProxyAPI. MiniCPA treats configuration as opaque data and never parses, modifies, or synchronizes it. - Two-Phase Binary Updates: Binary downloads, integrity checks, and unpacking occur in an isolated staging workspace without stopping the running service. The lifecycle lock is only acquired during the brief atomic commit phase.
- Kernel-Level Concurrency: Concurrency control relies on operating-system-level kernel leases (Named Pipes on Windows, Abstract Unix Sockets on Linux, and Loopback listeners on macOS). Lock files serve solely as diagnostic records and cannot cause deadlock or lock stealing.
- Process Safety: Process management tracks both PIDs and platform-specific process start markers to prevent misdirected signals caused by OS PID recycling. Outbound child process environments are automatically stripped of sensitive credentials.
Installation
Requires Node.js 24+.
npm install -g @astralyn/minicpaOr inspect without a global install:
npx @astralyn/minicpa --helpQuick Start
cpa init # Create the minimal bootstrap config and install the latest CPA binary
cpa start # Start CLIProxyAPI in the background
cpa web # Open the management Web panel in your browser
cpa status # Check the service, versions, and any detected problemsThe bootstrap configuration listens on 127.0.0.1:8317 with default bootstrap credentials (sk-cliproxyapi client key, CLIPROXYAPI management password) and enables native file logging. cpa init prints both credentials once; CLIProxyAPI hashes the management password on first start, so change both in the Web panel before exposing the instance beyond this machine. The bootstrap config also selects the CPA-Manager-Plus Web panel, which CLIProxyAPI downloads and keeps updated; see docs/security.md for this trust decision and how to change it. All subsequent configuration is performed directly inside CLIProxyAPI.
Connection Target
MiniCPA defaults to connecting via http://127.0.0.1:8317. If you configure a custom port, reverse proxy, or HTTPS in CLIProxyAPI, specify the target explicitly before any command:
cpa --api-url https://127.0.0.1:9443 start
cpa --api-url https://127.0.0.1:9443 status
cpa --api-url https://127.0.0.1:9443 webAlternatively, set the MINICPA_API_URL environment variable.
Updates & Upgrades
MiniCPA maintains a strict distinction between the managed daemon and the management CLI:
CLIProxyAPI Binary Updates (
cpa update): Fetches, verifies, and stages the latest or pinned CLIProxyAPI binary release from upstream GitHub, restarting the service only if the binary was replaced.cpa update cpa update --version 8.0.47MiniCPA CLI Upgrades (
cpa upgrade): Checks the npm registry and installs that exact latest version of the globally installed@astralyn/minicpanpm package in place. It never stops, restarts, or updates CLIProxyAPI.cpa upgrade
Commands Overview
| Command | Category | Purpose |
|---------|----------|---------|
| cpa init | Lifecycle | Create the bootstrap config once and install CLIProxyAPI |
| cpa start | Lifecycle | Start CLIProxyAPI in the background and wait for readiness |
| cpa stop | Lifecycle | Stop the running CLIProxyAPI |
| cpa restart | Lifecycle | Restart CLIProxyAPI |
| cpa status | Lifecycle | Show status, uptime, endpoints, autostart, versions, home, and detected problems |
| cpa auto [on\|off] | Lifecycle | Show or set login autostart (Windows Task/Registry, systemd, launchd) |
| cpa web | Interfaces | Print and open the management Web panel |
| cpa tui | Interfaces | Attach to the native CLIProxyAPI terminal UI |
| cpa logs | Interfaces | Show native CLIProxyAPI logs (-f follow, -n <lines>, --err request-error logs) |
| cpa update | Updates | Update the CLIProxyAPI binary (--version, --force) |
| cpa upgrade | Updates | Upgrade the MiniCPA npm package |
cpa status exits with 0 only when CLIProxyAPI is running and answering HTTP, so scripts can use it as a health check.
Directory Layout
| Path Target | Windows | macOS | Linux |
|-------------|---------|-------|-------|
| Root | %LOCALAPPDATA%\MiniCPA | ~/Library/Application Support/MiniCPA | $XDG_DATA_HOME/MiniCPA |
| Instance | <root>\instance | <root>/instance | <root>/instance |
| Temp | <root>\temp | <root>/temp | <root>/temp |
Instance data (configuration, authentication credentials, native logs) resides permanently under <root>/instance; cpa status prints its exact path. Uninstalling MiniCPA never removes your instance data or credentials.
For detailed architecture, concurrency, and security models, see docs/README.md.
Development
git clone https://github.com/ming-kang/MiniCPA.git
cd MiniCPA
npm ci
npm run hooks:install
npm run checknpm run check: Run linter, type checks, test suite, and build.npm test: Run test suite withnode:test.npm run dev -- <command>: Execute development entry withtsx.
Follow RELEASING.md for release workflows and see CHANGELOG.md for version history.
