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

@suncreation/opencode-claude-patch

v0.1.13

Published

Anthropic OAuth provider bridge and Claude request patch for OpenCode

Downloads

945

Readme

opencode-anthropic-oauth-patch

Installable OpenCode plugin that restores Anthropic provider visibility, reads the working OpenCode OAuth token file, refreshes Anthropic access tokens, and patches Claude request shape for OpenCode/oh-my-opencode.

This is meant for OpenCode/oh-my-opencode-style integrations where Claude OAuth requests break because extra Anthropic-incompatible fields are injected into the request path.

What it patches automatically as an OpenCode plugin

  • Registers an Anthropic auth/provider bridge for OpenCode using ~/.local/share/opencode/auth.json
  • Refreshes Anthropic OAuth access tokens through https://console.anthropic.com/v1/oauth/token
  • Removes thinking, output_config, and related Anthropic-problematic option fields from OpenCode provider options
  • Rewrites OpenCode system prompt strings into a single Claude-Code-compatible system string
  • Sets Claude-Code-compatible Anthropic headers by default
  • Installs a targeted global fetch patch that sanitizes outbound Anthropic OAuth message bodies, including final system[*].cache_control removal

How the automatic patch works

The root plugin uses two layers:

  1. OpenCode hooks (chat.params, chat.headers, experimental.chat.system.transform) for public-ABI-safe fixes
  2. a narrowly targeted globalThis.fetch wrapper that only patches https://api.anthropic.com/v1/messages... requests carrying Authorization: Bearer ...

That second layer is what makes the package automatic for the cache_control problem too.

Install

Add the package to your opencode.json plugin list:

{
  "$schema": "https://opencode.ai/config.json",
  "plugin": [
    "@suncreation/opencode-claude-patch"
  ]
}

Install it from this repository:

npm install /Users/admin/Projects/npm/opencode-anthropic-oauth-patch

If you later publish it, keep the same plugin entry and install with:

npm install @suncreation/opencode-claude-patch

One-line npx installer

To both download the package and register it in your OpenCode plugin config automatically:

npx -y @suncreation/opencode-claude-patch install

This command now does both:

  • installs the package into OpenCode's runtime cache
  • adds the plugin entry to ~/.config/opencode/opencode.json

Useful variants:

npx -y @suncreation/opencode-claude-patch status
npx -y @suncreation/opencode-claude-patch remove
npx -y @suncreation/opencode-claude-patch install --config ~/.config/opencode/opencode.json
npx -y @suncreation/opencode-claude-patch install --runtime ~/.cache/opencode --version latest

Anthropic login commands

The package can also manage Anthropic OAuth credentials directly in ~/.local/share/opencode/auth.json.

npx -y @suncreation/opencode-claude-patch login
npx -y @suncreation/opencode-claude-patch status
npx -y @suncreation/opencode-claude-patch refresh
npx -y @suncreation/opencode-claude-patch logout

Useful login options:

npx -y @suncreation/opencode-claude-patch login --mode max
npx -y @suncreation/opencode-claude-patch login --mode console
npx -y @suncreation/opencode-claude-patch login --no-open
npx -y @suncreation/opencode-claude-patch login --code '<code#state>'
npx -y @suncreation/opencode-claude-patch status --auth-path ~/.local/share/opencode/auth.json

OpenCode will auto-install npm plugins referenced in opencode.json at startup.

What the root package export does

The root package export is an OpenCode plugin function. Once installed and listed in opencode.json, it auto-applies:

  • Anthropic auth/provider loading backed by the OpenCode OAuth token file
  • chat.params patching for Anthropic/Claude models
  • chat.headers patching for Claude-compatible headers
  • experimental.chat.system.transform patching for a single Claude-Code-style system prompt
  • a targeted globalThis.fetch patch for final Anthropic OAuth request-body cleanup

No extra wiring is needed.

Optional environment toggles

OPENCODE_ANTHROPIC_OAUTH_SET_HEADERS=0
OPENCODE_ANTHROPIC_OAUTH_SYSTEM_PREFIX="You are Claude Code, Anthropic's official CLI for Claude."

Helper subpath for lower-level integrations

import {
  createAnthropicOAuthPatchedFetch,
  mergePatchHeaders,
  normalizeAnthropicSystemStrings,
  sanitizeAnthropicOptions
} from "@suncreation/opencode-claude-patch/helpers";

// if published:
// import { ... } from "@suncreation/opencode-anthropic-oauth-patch/helpers";

const options = sanitizeAnthropicOptions({
  thinking: { type: "adaptive" },
  output_config: { effort: "max" }
});

const headers = mergePatchHeaders({});
const system = normalizeAnthropicSystemStrings([
  "Be concise.",
  "Answer in Korean."
]);

const patchedFetch = createAnthropicOAuthPatchedFetch(fetch, {
  ensureClaudeCodeSystem: true,
  normalizeSystemToUserMessage: true
});

console.log(options, headers, system, typeof patchedFetch);

Notes

  • The root export is safe for opencode.json -> plugin installation.
  • The ./helpers subpath is for deeper interceptors or forks.
  • It does not mint OAuth tokens or bypass account-level/provider policy restrictions.
  • This package is targeted at Claude OAuth / oh-my-opencode-style setups. If you use Anthropic API keys and want native reasoning features, do not enable it globally.