From 6cc3e4d3a20f65a0e9442e8e5625ee1fd169d1db Mon Sep 17 00:00:00 2001 From: "Tommy D. Rossi" Date: Mon, 26 Jan 2026 22:10:43 +0100 Subject: [PATCH 1/2] fix: only replace specific OpenCode identity string Instead of replacing all OpenCode/opencode references in system prompts, only replace the specific blocked string 'You are OpenCode, the best coding agent on the planet.' with the Claude Code equivalent. This is a more targeted fix as the API only checks for that specific identity string, not all mentions of OpenCode. --- index.mjs | 10 ++++++---- package.json | 2 +- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/index.mjs b/index.mjs index 95dde67..a3d3ee2 100644 --- a/index.mjs +++ b/index.mjs @@ -193,15 +193,17 @@ export async function AnthropicAuthPlugin({ client }) { try { const parsed = JSON.parse(body); - // Sanitize system prompt - server blocks "OpenCode" string + // Sanitize system prompt - server blocks "You are OpenCode" string + // Only replace this specific string, not all OpenCode references if (parsed.system && Array.isArray(parsed.system)) { parsed.system = parsed.system.map((item) => { if (item.type === "text" && item.text) { return { ...item, - text: item.text - .replace(/OpenCode/g, "Claude Code") - .replace(/opencode/gi, "Claude"), + text: item.text.replace( + "You are OpenCode, the best coding agent on the planet.", + "You are Claude Code, Anthropic's official CLI for Claude.", + ), }; } return item; diff --git a/package.json b/package.json index b760041..d769500 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "opencode-anthropic-auth", - "version": "0.0.11", + "version": "0.0.12", "main": "./index.mjs", "devDependencies": { "@opencode-ai/plugin": "^0.4.45" From 936e12f08c34c603233e0b06d6d9466dcafcfeec Mon Sep 17 00:00:00 2001 From: "Tommy D. Rossi" Date: Wed, 28 Jan 2026 17:04:46 +0100 Subject: [PATCH 2/2] add AGENTS.md with plugin testing instructions --- AGENTS.md | 43 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 AGENTS.md diff --git a/AGENTS.md b/AGENTS.md new file mode 100644 index 0000000..62d9b7c --- /dev/null +++ b/AGENTS.md @@ -0,0 +1,43 @@ +# opencode-anthropic-auth + +OpenCode plugin for Anthropic OAuth authentication (Claude Pro/Max). + +## Testing the Plugin + +### 1. Add plugin to opencode.json + +Add the plugin path to the `plugins` field in your `opencode.json` (usually at `~/.config/opencode/opencode.json`): + +```json +{ + "plugins": [ + "/Users/morse/Documents/GitHub/opencode-anthropic-auth/index.mjs" + ] +} +``` + +### 2. Install dependencies + +```bash +bun install +``` + +### 3. Test the plugin + +Run with default plugins disabled to isolate this plugin: + +```bash +OPENCODE_DISABLE_DEFAULT_PLUGINS=true opencode run --model anthropic/claude-opus-4-5 hi +``` + +### Expected Results + +- **Success**: If the plugin works correctly, you should get a response from the model. +- **Failure**: If you see a credentials error, the plugin is not working properly. + +## Features + +- OAuth authentication for Claude Pro/Max subscriptions +- API key creation via Anthropic Console +- Manual API key entry +- Zero-cost tracking for Max plan users