npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

opencode-cliproxyapi-sync

v1.3.0

Published

Auto-sync OpenCode configs from CLIProxyAPI Dashboard

Readme

opencode-cliproxyapi-sync

Auto-sync OpenCode configs from CLIProxyAPI Dashboard.

What it does

This plugin automatically syncs your OpenCode configuration (opencode.json and oh-my-opencode.json) from the CLIProxyAPI Dashboard. It checks for config updates on OpenCode startup and applies them automatically.

Features

  • 🔄 Automatic Sync: Checks for config updates on OpenCode startup
  • Fast: Only syncs when configs actually change (version-based)
  • 🔒 Secure: Uses sync tokens for authentication
  • 📝 Smart Notifications: Only shows toast when opencode.json changes (requiring restart)
  • 💾 Atomic Writes: Safe config file updates (no partial writes)

Installation

Option 1: NPX Install (Recommended)

npx opencode install opencode-cliproxyapi-sync

Option 2: Manual Configuration

Add to your opencode.jsonc plugin array:

{
  "plugin": [
    "opencode-cliproxyapi-sync@latest",
    "oh-my-opencode@latest"
  ]
}

Important: Place opencode-cliproxyapi-sync before oh-my-opencode in the plugins array to ensure config is synced before oh-my-opencode loads.

Setup

1. Generate Sync Token

  1. Open the CLIProxyAPI Dashboard
  2. Navigate to SettingsConfig Sync
  3. Click Generate Sync Token
  4. Copy the token (it starts with tok_...)

2. Create Plugin Config File

Create the plugin config file:

Standard location:

~/.config/opencode-cliproxyapi-sync/config.json

With OCX profile:

~/.config/opencode/profiles/<profilename>/opencode-cliproxyapi-sync/config.json

Config content:

{
  "dashboardUrl": "https://dashboard.yourdomain.com",
  "syncToken": "tok_abc123...",
  "lastKnownVersion": null
}

Config Fields:

  • dashboardUrl: Your CLIProxyAPI Dashboard URL (no trailing slash)
  • syncToken: The sync token from Step 1
  • lastKnownVersion: Leave as null (plugin manages this automatically)

Security: The plugin automatically sets restrictive permissions (chmod 600) on the config file.

How it works

  1. On OpenCode Startup: Plugin loads and checks your config
  2. Version Check: Fetches current config version from dashboard
  3. Compare: If version differs from lastKnownVersion, fetches full bundle
  4. Write Configs: Atomically writes opencode.json and oh-my-opencode.json
  5. Notify: Shows toast if opencode.json changed (requiring restart)
  6. Update Version: Saves new version to plugin config

Configuration Sync Behavior

  • Sync Timing: Only on OpenCode startup (not while running)
  • Network Timeout: 5s for version check, 10s for bundle download
  • Retries: Up to 2 retries with exponential backoff (1s, 2s)
  • Error Handling: All errors logged but never crash OpenCode

Notifications

The plugin shows a toast notification only when opencode.json changes:

⚠️ Config Sync
opencode.json updated. Restart OpenCode to apply provider changes.

If only oh-my-opencode.json changes, no notification is shown (those changes apply immediately on next session).

File Locations

Standard (no profile):

  • Plugin Config: ~/.config/opencode-cliproxyapi-sync/config.json
  • OpenCode Config: ~/.config/opencode/opencode.json
  • Oh My OpenCode Config: ~/.config/opencode/oh-my-opencode.json

With OCX profile:

  • Plugin Config: ~/.config/opencode/profiles/<name>/opencode-cliproxyapi-sync/config.json
  • OpenCode Config: ~/.config/opencode/profiles/<name>/opencode.json
  • Oh My OpenCode Config: ~/.config/opencode/profiles/<name>/oh-my-opencode.json

(Respects XDG_CONFIG_HOME and OPENCODE_CONFIG_DIR environment variables)

OCX Profile Support

When using OCX profiles, the plugin uses per-profile configuration. This means:

  1. Each profile has its own plugin config - you can sync different profiles to different dashboards or disable sync for some profiles
  2. Syncing only affects the active profile - starting ocx oc -p work will only update configs in the work profile directory
  3. No cross-profile interference - the standard config is never touched when using a profile

Setup for OCX profiles:

# Create config for your profile
mkdir -p ~/.config/opencode/profiles/myprofile/opencode-cliproxyapi-sync
cat > ~/.config/opencode/profiles/myprofile/opencode-cliproxyapi-sync/config.json << 'EOF'
{
  "dashboardUrl": "https://dashboard.yourdomain.com",
  "syncToken": "your-token-here",
  "lastKnownVersion": null
}
EOF

# Now start with profile - only this profile syncs
ocx oc -p myprofile

Disable sync for a profile: Simply don't create a config.json in that profile's opencode-cliproxyapi-sync folder.

Troubleshooting

Plugin doesn't sync

Check config file exists and is valid:

# Standard location
cat ~/.config/opencode-cliproxyapi-sync/config.json

# Or with OCX profile
cat ~/.config/opencode/profiles/<profilename>/opencode-cliproxyapi-sync/config.json

Check OpenCode logs for sync messages:

# Look for lines like:
[cliproxyapi-sync] Synced to version abc123...
[cliproxyapi-sync] Failed to check version. Skipping sync.

Authentication errors (401)

  • Verify your syncToken is correct
  • Check if token was revoked in Dashboard → Settings → Config Sync
  • Generate a new token if needed

Config not updating

  • Ensure dashboard URL is correct (no trailing slash)
  • Check firewall/network allows access to dashboard
  • Verify dashboard is running and accessible

Notification not showing

  • Notification only appears when opencode.json changes
  • If only oh-my-opencode.json changed, no notification is shown (expected)

Development

Build from source

cd plugin
bun install
bun build src/index.ts --outdir dist --target node

Local testing

  1. Build the plugin (see above)
  2. Link locally:
    cd plugin
    npm link
    cd ~/.config/opencode
    npm link opencode-cliproxyapi-sync
  3. Add "opencode-cliproxyapi-sync" to your opencode.json plugins array
  4. Restart OpenCode

License

MIT

Support

  • Dashboard Issues: https://github.com/itsmylife44/opencode-cliproxyapi-sync/issues
  • CLIProxyAPI: https://github.com/router-for-me/CLIProxyAPI
  • OpenCode: https://opencode.ai