@ex-machina/opencode-anthropic-auth 0.0.15 → 0.0.17

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -28,7 +28,4 @@ jobs:
28
28
  run: npm install
29
29
 
30
30
  - name: Publish
31
- run: npm publish --access public
32
- env:
33
- NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
34
- NPM_CONFIG_PROVENANCE: false
31
+ run: npm publish --access public --provenance
@@ -0,0 +1,104 @@
1
+ <component name="InspectionProjectProfileManager">
2
+ <profile version="1.0">
3
+ <option name="myName" value="Project Default" />
4
+ <inspection_tool class="ES6PreferShortImport" enabled="true" level="INFORMATION" enabled_by_default="true" />
5
+ <inspection_tool class="Eslint" enabled="true" level="WARNING" enabled_by_default="true" />
6
+ <inspection_tool class="HtmlUnknownAttribute" enabled="true" level="WARNING" enabled_by_default="true">
7
+ <option name="myValues">
8
+ <value>
9
+ <list size="1">
10
+ <item index="0" class="java.lang.String" itemvalue="css" />
11
+ </list>
12
+ </value>
13
+ </option>
14
+ <option name="myCustomValuesEnabled" value="true" />
15
+ </inspection_tool>
16
+ <inspection_tool class="HtmlUnknownTag" enabled="true" level="INFORMATION" enabled_by_default="true">
17
+ <option name="myValues">
18
+ <value>
19
+ <list size="6">
20
+ <item index="0" class="java.lang.String" itemvalue="nobr" />
21
+ <item index="1" class="java.lang.String" itemvalue="noembed" />
22
+ <item index="2" class="java.lang.String" itemvalue="comment" />
23
+ <item index="3" class="java.lang.String" itemvalue="noscript" />
24
+ <item index="4" class="java.lang.String" itemvalue="embed" />
25
+ <item index="5" class="java.lang.String" itemvalue="script" />
26
+ </list>
27
+ </value>
28
+ </option>
29
+ <option name="myCustomValuesEnabled" value="true" />
30
+ </inspection_tool>
31
+ <inspection_tool class="HttpUrlsUsage" enabled="true" level="WEAK WARNING" enabled_by_default="true">
32
+ <option name="ignoredUrls">
33
+ <list>
34
+ <option value="http://localhost" />
35
+ <option value="http://127.0.0.1" />
36
+ <option value="http://0.0.0.0" />
37
+ <option value="http://www.w3.org/" />
38
+ <option value="http://json-schema.org/draft" />
39
+ <option value="http://java.sun.com/" />
40
+ <option value="http://xmlns.jcp.org/" />
41
+ <option value="http://javafx.com/javafx/" />
42
+ <option value="http://javafx.com/fxml" />
43
+ <option value="http://maven.apache.org/xsd/" />
44
+ <option value="http://maven.apache.org/POM/" />
45
+ <option value="http://www.springframework.org/schema/" />
46
+ <option value="http://www.springframework.org/tags" />
47
+ <option value="http://www.springframework.org/security/tags" />
48
+ <option value="http://www.thymeleaf.org" />
49
+ <option value="http://www.jboss.org/j2ee/schema/" />
50
+ <option value="http://www.jboss.com/xml/ns/" />
51
+ <option value="http://www.ibm.com/webservices/xsd" />
52
+ <option value="http://activemq.apache.org/schema/" />
53
+ <option value="http://schema.cloudfoundry.org/spring/" />
54
+ <option value="http://schemas.xmlsoap.org/" />
55
+ <option value="http://cxf.apache.org/schemas/" />
56
+ <option value="http://primefaces.org/ui" />
57
+ <option value="http://tiles.apache.org/" />
58
+ <option value="http://broker" />
59
+ </list>
60
+ </option>
61
+ </inspection_tool>
62
+ <inspection_tool class="JSUnusedGlobalSymbols" enabled="true" level="INFORMATION" enabled_by_default="true" editorAttributes="INFORMATION_ATTRIBUTES" />
63
+ <inspection_tool class="JSXUnresolvedComponent" enabled="true" level="INFORMATION" enabled_by_default="true" />
64
+ <inspection_tool class="MarkdownIncorrectTableFormatting" enabled="true" level="INFORMATION" enabled_by_default="true" />
65
+ <inspection_tool class="MarkdownIncorrectlyNumberedListItem" enabled="true" level="INFORMATION" enabled_by_default="true" />
66
+ <inspection_tool class="PyArgumentListInspection" enabled="true" level="TEXT ATTRIBUTES" enabled_by_default="true" editorAttributes="TEXT_STYLE_SUGGESTION" />
67
+ <inspection_tool class="PyClassVarInspection" enabled="true" level="TEXT ATTRIBUTES" enabled_by_default="true" editorAttributes="CONSIDERATION_ATTRIBUTES" />
68
+ <inspection_tool class="PyCompatibilityInspection" enabled="true" level="WARNING" enabled_by_default="true">
69
+ <option name="ourVersions">
70
+ <value>
71
+ <list size="3">
72
+ <item index="0" class="java.lang.String" itemvalue="3.12" />
73
+ <item index="1" class="java.lang.String" itemvalue="3.13" />
74
+ <item index="2" class="java.lang.String" itemvalue="3.14" />
75
+ </list>
76
+ </value>
77
+ </option>
78
+ </inspection_tool>
79
+ <inspection_tool class="PyMethodParametersInspection" enabled="true" level="WARNING" enabled_by_default="true" editorAttributes="WARNING_ATTRIBUTES" />
80
+ <inspection_tool class="PyPep8NamingInspection" enabled="true" level="WEAK WARNING" enabled_by_default="true">
81
+ <option name="ignoredErrors">
82
+ <list>
83
+ <option value="N806" />
84
+ </list>
85
+ </option>
86
+ </inspection_tool>
87
+ <inspection_tool class="PyShadowingBuiltinsInspection" enabled="true" level="WEAK WARNING" enabled_by_default="true">
88
+ <option name="ignoredNames">
89
+ <list>
90
+ <option value="id" />
91
+ <option value="input" />
92
+ </list>
93
+ </option>
94
+ </inspection_tool>
95
+ <inspection_tool class="PyShadowingNamesInspection" enabled="true" level="INFORMATION" enabled_by_default="true" editorAttributes="CONSIDERATION_ATTRIBUTES" />
96
+ <inspection_tool class="PyTypeHintsInspection" enabled="true" level="TEXT ATTRIBUTES" enabled_by_default="true" editorAttributes="CONSIDERATION_ATTRIBUTES" />
97
+ <inspection_tool class="PyUnresolvedReferencesInspection" enabled="true" level="ERROR" enabled_by_default="true" editorAttributes="ERRORS_ATTRIBUTES" />
98
+ <inspection_tool class="TypeScriptValidateJSTypes" enabled="false" level="WEAK WARNING" enabled_by_default="false" />
99
+ <inspection_tool class="UnnecessaryLocalVariableJS" enabled="true" level="INFORMATION" enabled_by_default="true" editorAttributes="INFO_ATTRIBUTES">
100
+ <option name="m_ignoreImmediatelyReturnedVariables" value="false" />
101
+ <option name="m_ignoreAnnotatedVariables" value="false" />
102
+ </inspection_tool>
103
+ </profile>
104
+ </component>
package/.idea/misc.xml ADDED
@@ -0,0 +1,6 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <project version="4">
3
+ <component name="ProjectRootManager" version="2" project-jdk-name="uv (trading)" project-jdk-type="Python SDK">
4
+ <output url="file://$PROJECT_DIR$/out" />
5
+ </component>
6
+ </project>
@@ -0,0 +1,8 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <project version="4">
3
+ <component name="ProjectModuleManager">
4
+ <modules>
5
+ <module fileurl="file://$PROJECT_DIR$/.idea/opencode-anthropic-auth.iml" filepath="$PROJECT_DIR$/.idea/opencode-anthropic-auth.iml" />
6
+ </modules>
7
+ </component>
8
+ </project>
@@ -0,0 +1,9 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <module type="JAVA_MODULE" version="4">
3
+ <component name="NewModuleRootManager" inherit-compiler-output="true">
4
+ <exclude-output />
5
+ <content url="file://$MODULE_DIR$" />
6
+ <orderEntry type="inheritedJdk" />
7
+ <orderEntry type="sourceFolder" forTests="false" />
8
+ </component>
9
+ </module>
package/.idea/vcs.xml ADDED
@@ -0,0 +1,7 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <project version="4">
3
+ <component name="VcsDirectoryMappings">
4
+ <mapping directory="" vcs="Git" />
5
+ <mapping directory="$PROJECT_DIR$" vcs="Git" />
6
+ </component>
7
+ </project>
package/README.md ADDED
@@ -0,0 +1,60 @@
1
+ # @ex-machina/opencode-anthropic-auth
2
+
3
+ An [OpenCode](https://github.com/anomalyco/opencode) plugin that provides Anthropic OAuth authentication, enabling Claude Pro/Max users to use their subscription directly with OpenCode.
4
+
5
+ <details>
6
+ <summary>This solves the ".opencode" -> ".Claude" issues too!</summary>
7
+
8
+ ![renaming.jpg](images/renaming.jpg)
9
+ </details>
10
+
11
+ ## Installation
12
+
13
+ ```bash
14
+ npm install @ex-machina/opencode-anthropic-auth
15
+ ```
16
+
17
+ ## Usage
18
+
19
+ Add the plugin to your OpenCode configuration:
20
+
21
+ ```json
22
+ {
23
+ "plugins": ["@ex-machina/opencode-anthropic-auth"]
24
+ }
25
+ ```
26
+
27
+ ## Authentication Methods
28
+
29
+ The plugin provides three authentication options:
30
+
31
+ - **Claude Pro/Max** - OAuth flow via `claude.ai` for Pro/Max subscribers. Uses your existing subscription at no additional API cost.
32
+ - **Create an API Key** - OAuth flow via `console.anthropic.com` that creates an API key on your behalf.
33
+ - **Manually enter API Key** - Standard API key entry for users who already have one.
34
+
35
+ ## How It Works
36
+
37
+ For Claude Pro/Max authentication, the plugin:
38
+
39
+ 1. Initiates a PKCE OAuth flow against Anthropic's authorization endpoint
40
+ 2. Exchanges the authorization code for access and refresh tokens
41
+ 3. Automatically refreshes expired tokens
42
+ 4. Injects the required OAuth headers and beta flags into API requests
43
+ 5. Zeros out model costs (since usage is covered by the subscription)
44
+
45
+ ## Development
46
+
47
+ ### Publishing
48
+
49
+ Bump the version and push to `main` -- CI will publish to npm automatically:
50
+
51
+ ```bash
52
+ bun bump # patch bump (0.0.13 -> 0.0.14)
53
+ bun bump minor # minor bump (0.0.13 -> 0.1.0)
54
+ bun bump major # major bump (0.0.13 -> 1.0.0)
55
+ bun bump -- --dry-run # preview without changes
56
+ ```
57
+
58
+ ## License
59
+
60
+ MIT
Binary file
package/index.mjs CHANGED
@@ -195,22 +195,6 @@ export async function AnthropicAuthPlugin({ client }) {
195
195
  try {
196
196
  const parsed = JSON.parse(body);
197
197
 
198
- // Sanitize system prompt - server blocks "OpenCode" string
199
- // Note: (?<!\/) preserves paths like /path/to/opencode-foo
200
- if (parsed.system && Array.isArray(parsed.system)) {
201
- parsed.system = parsed.system.map((item) => {
202
- if (item.type === "text" && item.text) {
203
- return {
204
- ...item,
205
- text: item.text
206
- .replace(/OpenCode/g, "Claude Code")
207
- .replace(/(?<!\/)opencode/gi, "Claude"),
208
- };
209
- }
210
- return item;
211
- });
212
- }
213
-
214
198
  // Add prefix to tools definitions
215
199
  if (parsed.tools && Array.isArray(parsed.tools)) {
216
200
  parsed.tools = parsed.tools.map((tool) => ({
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ex-machina/opencode-anthropic-auth",
3
- "version": "0.0.15",
3
+ "version": "0.0.17",
4
4
  "main": "./index.mjs",
5
5
  "scripts": {
6
6
  "bump": "bun script/bump.ts"