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 diff --git a/index.mjs b/index.mjs index cb6728d..1e07f5f 100644 --- a/index.mjs +++ b/index.mjs @@ -195,15 +195,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 1a828dd..20eb386 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "opencode-anthropic-auth", - "version": "0.0.13", + "version": "0.0.14", "main": "./index.mjs", "devDependencies": { "@opencode-ai/plugin": "^0.4.45"