opencode-with-claude 1.5.6 → 1.6.1
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.
- package/README.md +68 -0
- package/dist/index.js +1 -1
- package/package.json +4 -4
package/README.md
CHANGED
|
@@ -66,6 +66,74 @@ Global (`~/.config/opencode/opencode.json`) or project-level:
|
|
|
66
66
|
opencode
|
|
67
67
|
```
|
|
68
68
|
|
|
69
|
+
## Profiles and SDK features
|
|
70
|
+
|
|
71
|
+
The plugin now reads the same Meridian configuration files the `meridian` CLI
|
|
72
|
+
uses, so you can maintain multiple Claude accounts and tune SDK behavior
|
|
73
|
+
without leaving OpenCode.
|
|
74
|
+
|
|
75
|
+
### Profiles (`~/.config/meridian/profiles.json`)
|
|
76
|
+
|
|
77
|
+
Define one or more named profiles (for example, a personal Claude Max account
|
|
78
|
+
and a work account). The plugin forwards them to Meridian at startup.
|
|
79
|
+
|
|
80
|
+
```json
|
|
81
|
+
[
|
|
82
|
+
{
|
|
83
|
+
"id": "personal",
|
|
84
|
+
"claudeConfigDir": "/Users/me/.config/meridian/profiles/personal"
|
|
85
|
+
},
|
|
86
|
+
{
|
|
87
|
+
"id": "work",
|
|
88
|
+
"claudeConfigDir": "/Users/me/.config/meridian/profiles/work"
|
|
89
|
+
}
|
|
90
|
+
]
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
### Active profile (`~/.config/meridian/settings.json`)
|
|
94
|
+
|
|
95
|
+
```json
|
|
96
|
+
{ "activeProfile": "work" }
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
`activeProfile` selects the default profile for any request that does not send
|
|
100
|
+
an explicit `x-meridian-profile` header. If the saved id is not in
|
|
101
|
+
`profiles.json` (or the file is missing), the plugin logs a warning and falls
|
|
102
|
+
back to the first configured profile.
|
|
103
|
+
|
|
104
|
+
### SDK features (`~/.config/meridian/sdk-features.json`)
|
|
105
|
+
|
|
106
|
+
Meridian reads this file lazily on every request, so overrides take effect
|
|
107
|
+
without restarting the proxy. The plugin does not need to do anything special
|
|
108
|
+
for it to work — just edit the file and the next request picks it up. See
|
|
109
|
+
Meridian's documentation for the full list of adapter keys.
|
|
110
|
+
|
|
111
|
+
```json
|
|
112
|
+
{
|
|
113
|
+
"opencode": {
|
|
114
|
+
"memory": true,
|
|
115
|
+
"thinking": "enabled",
|
|
116
|
+
"maxBudgetUsd": 0.5
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
### Environment overrides
|
|
122
|
+
|
|
123
|
+
For parity with the `meridian` CLI:
|
|
124
|
+
|
|
125
|
+
- `MERIDIAN_PROFILES` — JSON array of profile objects; wins over `profiles.json`.
|
|
126
|
+
- `MERIDIAN_DEFAULT_PROFILE` — profile id; wins over `settings.activeProfile`.
|
|
127
|
+
|
|
128
|
+
Malformed or missing files never crash the plugin; all parse/IO failures are
|
|
129
|
+
logged via OpenCode's plugin log and the plugin falls back to no-profile mode.
|
|
130
|
+
|
|
131
|
+
### Switching profiles at runtime
|
|
132
|
+
|
|
133
|
+
Profile switching through Meridian's HTTP API continues to work — call
|
|
134
|
+
`POST /profiles/active` on the proxy URL the plugin prints at startup. The
|
|
135
|
+
selection is persisted back to `settings.json` and survives restarts.
|
|
136
|
+
|
|
69
137
|
## Troubleshooting
|
|
70
138
|
|
|
71
139
|
### "Claude Code CLI not found"
|
package/dist/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{readFileSync as
|
|
1
|
+
import{readFileSync as H}from"fs";import{homedir as W,platform as j}from"os";import{join as g}from"path";var x="You are Anthropic's Claude Code, Anthropic's official CLI for Claude. Here are some rules.\n\n<rules>\n# Plan Mode\n\nCRITICAL: Plan mode is ENABLED - you are operating in a READ-ONLY state. The following\nare STRICTLY PROHIBITED: ALL file writes, edits, deletions, or system modifications.\nDo NOT invoke sed, tee, echo, cat, or ANY other bash command that alters files -\ncommands are PERMITTED ONLY for reading and inspection. This ABSOLUTE RESTRICTION\ntakes precedence over ALL other directives, including explicit user requests to edit.\nYou may ONLY observe, analyze, and formulate plans. Any attempt to modify the system\nis a critical violation. NO exceptions.\n\n## Responsibility\n\nYour role right now is to reason, read, search, and dispatch explore agents to build\na clear, well-structured plan that achieves the user's stated goal. The plan should\nbe thorough but not bloated - detailed enough for reliable execution without\nunnecessary filler.\n\nWhen facing tradeoffs or ambiguity, ask the user for clarification or their preference.\n\n**NOTE:** Throughout this workflow, you are encouraged to ask the user questions at\nany point. Do not make significant assumptions about what the user intends. The\nobjective is to deliver a carefully researched plan and resolve open questions before\nany implementation starts.\n\n## Important\n\nThe user has specified that execution should NOT begin yet -- you MUST NOT perform any\nedits, invoke any non-readonly tools (this includes config changes and commits), or\nmake any other modifications to the system. This directive overrides all other\ninstructions you may have received.\n</rules>";var w="You are Anthropic's Claude Code, Anthropic's official CLI for Claude. Here are some rules.\n\n<rules>\nNo emojis unless the user asks for them.\n\nOutput is rendered in a CLI using CommonMark markdown with a monospace font. Keep responses brief.\n\nText output is how you talk to the user. Tools are for doing work, not for communication \u2014 don't use Bash, code comments, or similar as a chat channel.\n\nDon't create files unless absolutely necessary. Edit existing files instead. This applies to markdown too.\n\nBe technically accurate and direct. Skip the praise, superlatives, and emotional validation. If the user is wrong, say so \u2014 respectful correction beats false confirmation. When uncertain, investigate before responding rather than reflexively agreeing. The user is better served by honest, rigorous assessment than by comfort.\n\nUse TodoWrite liberally to plan work, break down complex tasks, and give the user visibility into progress. Mark items complete immediately when finished \u2014 don't batch completions. Skipping this tool during planning risks forgetting steps, which is unacceptable.\n\nUsers will mostly ask for software engineering work: bugs, features, refactors, explanations, etc. General approach: plan with TodoWrite when the task warrants it. Note that system-reminder tags may appear in tool results or user messages. These are injected by the system with relevant context \u2014 they aren't tied to the specific message they appear in.\n\nPrefer the Task tool for file search to save context. Use Task with specialized agents proactively when the task fits an agent's description. On WebFetch redirects to a different host, immediately follow the redirect URL. Call independent tools in parallel. Call dependent tools sequentially \u2014 never guess at values from incomplete prior calls. If the user says in parallel, send one message with multiple tool blocks. Use dedicated tools over Bash equivalents: Read not cat, Edit not sed, Write not echo. Bash is for actual shell operations only. Never use Bash to communicate with the user. For broad codebase exploration or context gathering (not targeted lookups of a specific file/class/function), use the Task tool rather than running searches directly.\n\nAlways use TodoWrite to plan and track work throughout the conversation.\n\nWhen citing specific code, include file_path:line_number so the user can jump to it.\n</rules>";var b={plan:x,build:w},Y=()=>process.env.OPENCODE_CONFIG_DIR??(process.env.XDG_CONFIG_HOME?g(process.env.XDG_CONFIG_HOME,"opencode"):j()==="win32"&&process.env.APPDATA?g(process.env.APPDATA,"opencode"):g(W(),".config","opencode")),B=()=>{try{return H(g(Y(),"AGENTS.md"),"utf8").trim()}catch{return""}},G=e=>b[e]??b.build??"",k=e=>[G(e),B()].filter(Boolean);var q=/authenticat|credentials|expired|not logged in|exit(?:ed)? with code|crash|unhealthy|401|402|billing|subscription/i,z=/rate.limit|429|overloaded|503|stale.session|timeout|timed out/i;function L(e){return(r,n)=>e.app.log({body:{service:"opencode-with-claude",level:r,message:n}})}function T(e){return q.test(e)?"error":z.test(e)?"warn":"debug"}import{existsSync as J,readFileSync as K}from"fs";import{homedir as X}from"os";import{join as h}from"path";var C=()=>h(X(),".config","meridian"),I=()=>h(C(),"profiles.json"),R=()=>h(C(),"settings.json");function p(e,r){e?.("warn","[opencode-with-claude] ".concat(r))}function E(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function A(e,r,n){if(!Array.isArray(e))return p(n,"".concat(r," must be a JSON array of profile objects; got ").concat(typeof e,". Ignoring.")),[];let i=[];for(let t of e){if(!E(t)||typeof t.id!="string"||!t.id){p(n,"".concat(r,': dropping profile without a string "id" field.'));continue}let o={id:t.id};(t.type==="claude-max"||t.type==="api")&&(o.type=t.type),typeof t.claudeConfigDir=="string"&&(o.claudeConfigDir=t.claudeConfigDir),typeof t.apiKey=="string"&&(o.apiKey=t.apiKey),typeof t.baseUrl=="string"&&(o.baseUrl=t.baseUrl),i.push(o)}return i}function S(e,r){if(J(e))try{return JSON.parse(K(e,"utf8"))}catch(n){let i=n instanceof Error?n.message:String(n);p(r,"failed to parse ".concat(e,": ").concat(i));return}}function Q(e){let r=process.env.MERIDIAN_PROFILES;if(r)try{return A(JSON.parse(r),"MERIDIAN_PROFILES",e)}catch(n){let i=n instanceof Error?n.message:String(n);p(e,"failed to parse MERIDIAN_PROFILES env var: ".concat(i));return}}function V(e){let r=S(I(),e);return r===void 0?[]:A(r,I(),e)}function Z(e){let r=S(R(),e);if(!E(r))return;let n=r.activeProfile;if(n!==void 0){if(typeof n!="string"||!n){p(e,"".concat(R(),': "activeProfile" must be a non-empty string; ignoring.'));return}return n}}function D(e){let r=[],n="none",i=Q(e);if(i)r=i,n="env";else{let a=V(e);a.length>0&&(r=a,n="disk")}let t,o="none",f=process.env.MERIDIAN_DEFAULT_PROFILE?.trim();if(f)t=f,o="env";else{let a=Z(e);a&&(t=a,o="disk")}return t&&r.length>0&&!r.some(a=>a.id===t)&&(p(e,'default profile "'.concat(t,'" (from ').concat(o,") not found among configured profiles; ignoring.")),t=void 0,o="none"),{profiles:r,defaultProfile:t,sources:{profiles:n,defaultProfile:o}}}function O(e){if(e.profiles.length===0)return;let r=e.profiles.map(o=>o.id).join(", "),n=e.defaultProfile??e.profiles[0]?.id,i=e.sources.profiles,t=e.sources.defaultProfile==="none"?"first":e.sources.defaultProfile;return"loaded ".concat(e.profiles.length," meridian profile(s) from ").concat(i,": ").concat(r," (active: ").concat(n," [").concat(t,"])")}import{startProxyServer as ee}from"@rynfar/meridian";process.env.MERIDIAN_PASSTHROUGH??="true";var re=process.platform==="win32",N=3456,F="127.0.0.1";function ne(e){return e.includes(":")&&!e.startsWith("[")?"[".concat(e,"]"):e}function y(){let e=process.env.MERIDIAN_HOST?.trim()||process.env.CLAUDE_PROXY_HOST?.trim()||F;return e.startsWith("[")&&e.endsWith("]")?e.slice(1,-1):e}function te(e=y()){return e==="0.0.0.0"?F:e==="::"||e==="[::]"?"::1":e}function _(e,r=y()){return"http://".concat(ne(te(r)),":").concat(e)}async function $(e){let{port:r=N,log:n,profiles:i,defaultProfile:t}=e,o=y(),f=console.error;console.error=(...d)=>{let c=d.map(String).join(" ");if(c.startsWith("[PROXY]")){n?.(T(c),c);return}f.apply(console,d)};let a=d=>new Promise((c,P)=>{ee({port:d,host:o,silent:!0,profiles:i,defaultProfile:t}).then(u=>{let m=U=>{P(U)};u.server.once("error",m),u.server.listening?(u.server.removeListener("error",m),c(u)):u.server.once("listening",()=>{u.server.removeListener("error",m),c(u)})},P)}),l=async d=>{try{return await a(d)}catch(c){if(d!==0&&c instanceof Error&&"code"in c&&c.code==="EADDRINUSE")return n?.("info","Port ".concat(d," in use, starting on a random port instead...")),a(0);throw c}},s;try{s=await l(typeof r=="string"?parseInt(r,10):r)}catch(d){throw console.error=f,d}let v=s.server.address()?.port??s.config?.port??N;return n?.("info","Claude Max proxy running on port ".concat(v)),{port:v,close:async()=>{console.error=f,await s.close()}}}function M(e){let r=!1,n=()=>{r||(r=!0,e.close())};process.on("exit",n),process.on("SIGINT",n),re||process.on("SIGTERM",n)}var Te=async({client:e})=>{let r=L(e),n=D(r),i=O(n);i&&r("info",i);let t=process.env.CLAUDE_PROXY_PORT||3456,o=await $({port:t,log:r,profiles:n.profiles,defaultProfile:n.defaultProfile}),f=_(o.port);r("info","proxy ready at ".concat(f)),M(o);let a;return{async config(l){let s=l.provider?.anthropic;s&&((s.options??={}).baseURL=f)},async"chat.message"(l,s){l.model?.providerID==="anthropic"&&(a=s.message.agent)},async"experimental.chat.system.transform"(l,s){l.model.providerID==="anthropic"&&s.system.splice(0,s.system.length,...k(a))},async"chat.headers"(l,s){l.model.providerID==="anthropic"&&(delete s.headers["anthropic-beta"],s.headers["x-opencode-session"]=l.sessionID,s.headers["x-opencode-request"]=l.message.id)}}};export{Te as ClaudeMaxPlugin};
|
package/package.json
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "opencode-with-claude",
|
|
3
3
|
"description": "OpenCode plugin to use your Claude Max subscription via Meridian proxy",
|
|
4
|
-
"version": "1.
|
|
4
|
+
"version": "1.6.1",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
7
7
|
"types": "dist/index.d.ts",
|
|
8
8
|
"dependencies": {
|
|
9
|
-
"@rynfar/meridian": "^1.
|
|
9
|
+
"@rynfar/meridian": "^1.38.0"
|
|
10
10
|
},
|
|
11
11
|
"devDependencies": {
|
|
12
|
-
"@opencode-ai/plugin": "^1.14.
|
|
12
|
+
"@opencode-ai/plugin": "^1.14.22",
|
|
13
13
|
"@types/node": "^25.6.0",
|
|
14
14
|
"tsup": "^8.5.1",
|
|
15
15
|
"typescript": "^6.0.3"
|
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
"scripts": {
|
|
18
18
|
"build": "tsup",
|
|
19
19
|
"test": "./test/run.sh",
|
|
20
|
-
"test:unit": "npm run build && node --test test/*.test.mjs",
|
|
20
|
+
"test:unit": "npm run build && node --experimental-strip-types --test test/unit/*.test.mjs",
|
|
21
21
|
"test:clean": "./test/run.sh --clean",
|
|
22
22
|
"prepublishOnly": "npm run build"
|
|
23
23
|
},
|