Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 43 additions & 0 deletions AGENTS.md
Original file line number Diff line number Diff line change
@@ -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
10 changes: 6 additions & 4 deletions index.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -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"
Expand Down
Loading