opencode-cliproxyapi-sync 1.1.3 → 1.2.0
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 +46 -9
- package/dist/index.js +17 -21
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -48,8 +48,19 @@ Add to your `opencode.jsonc` plugin array:
|
|
|
48
48
|
|
|
49
49
|
### 2. Create Plugin Config File
|
|
50
50
|
|
|
51
|
-
Create the config file
|
|
51
|
+
Create the config file in the **same directory** as your `opencode.json`:
|
|
52
52
|
|
|
53
|
+
**Standard location:**
|
|
54
|
+
```
|
|
55
|
+
~/.config/opencode/opencode-cliproxyapi-sync/config.json
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
**With OCX profile:**
|
|
59
|
+
```
|
|
60
|
+
~/.config/opencode/profiles/<profilename>/opencode-cliproxyapi-sync/config.json
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
**Config content:**
|
|
53
64
|
```json
|
|
54
65
|
{
|
|
55
66
|
"dashboardUrl": "https://dashboard.yourdomain.com",
|
|
@@ -92,21 +103,43 @@ If only `oh-my-opencode.json` changes, no notification is shown (those changes a
|
|
|
92
103
|
|
|
93
104
|
## File Locations
|
|
94
105
|
|
|
95
|
-
|
|
106
|
+
**Standard (no profile):**
|
|
107
|
+
- **Plugin Config**: `~/.config/opencode/opencode-cliproxyapi-sync/config.json`
|
|
96
108
|
- **OpenCode Config**: `~/.config/opencode/opencode.json`
|
|
97
109
|
- **Oh My OpenCode Config**: `~/.config/opencode/oh-my-opencode.json`
|
|
98
110
|
|
|
99
|
-
|
|
111
|
+
**With OCX profile:**
|
|
112
|
+
- **Plugin Config**: `~/.config/opencode/profiles/<name>/opencode-cliproxyapi-sync/config.json`
|
|
113
|
+
- **OpenCode Config**: `~/.config/opencode/profiles/<name>/opencode.json`
|
|
114
|
+
- **Oh My OpenCode Config**: `~/.config/opencode/profiles/<name>/oh-my-opencode.json`
|
|
115
|
+
|
|
116
|
+
(Respects `XDG_CONFIG_HOME` and `OPENCODE_CONFIG_DIR` environment variables)
|
|
100
117
|
|
|
101
118
|
## OCX Profile Support
|
|
102
119
|
|
|
103
|
-
When using [OCX](https://github.com/kdcokenny/ocx) profiles, the plugin
|
|
120
|
+
When using [OCX](https://github.com/kdcokenny/ocx) profiles, the plugin uses **per-profile configuration**. This means:
|
|
121
|
+
|
|
122
|
+
1. **Each profile has its own plugin config** - you can sync different profiles to different dashboards or disable sync for some profiles
|
|
123
|
+
2. **Syncing only affects the active profile** - starting `ocx oc -p work` will only update configs in the `work` profile directory
|
|
124
|
+
3. **No cross-profile interference** - the standard config is never touched when using a profile
|
|
104
125
|
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
126
|
+
**Setup for OCX profiles:**
|
|
127
|
+
```bash
|
|
128
|
+
# Create config for your profile
|
|
129
|
+
mkdir -p ~/.config/opencode/profiles/myprofile/opencode-cliproxyapi-sync
|
|
130
|
+
cat > ~/.config/opencode/profiles/myprofile/opencode-cliproxyapi-sync/config.json << 'EOF'
|
|
131
|
+
{
|
|
132
|
+
"dashboardUrl": "https://dashboard.yourdomain.com",
|
|
133
|
+
"syncToken": "your-token-here",
|
|
134
|
+
"lastKnownVersion": null
|
|
135
|
+
}
|
|
136
|
+
EOF
|
|
137
|
+
|
|
138
|
+
# Now start with profile - only this profile syncs
|
|
139
|
+
ocx oc -p myprofile
|
|
140
|
+
```
|
|
108
141
|
|
|
109
|
-
|
|
142
|
+
**Disable sync for a profile:** Simply don't create a `config.json` in that profile's `opencode-cliproxyapi-sync` folder.
|
|
110
143
|
|
|
111
144
|
## Troubleshooting
|
|
112
145
|
|
|
@@ -114,7 +147,11 @@ No additional configuration needed - just use `ocx oc -p myprofile` as usual.
|
|
|
114
147
|
|
|
115
148
|
**Check config file exists and is valid**:
|
|
116
149
|
```bash
|
|
117
|
-
|
|
150
|
+
# Standard location
|
|
151
|
+
cat ~/.config/opencode/opencode-cliproxyapi-sync/config.json
|
|
152
|
+
|
|
153
|
+
# Or with OCX profile
|
|
154
|
+
cat ~/.config/opencode/profiles/<profilename>/opencode-cliproxyapi-sync/config.json
|
|
118
155
|
```
|
|
119
156
|
|
|
120
157
|
**Check OpenCode logs** for sync messages:
|
package/dist/index.js
CHANGED
|
@@ -9,9 +9,13 @@ import { readFileSync, writeFileSync, existsSync, mkdirSync, chmodSync } from "f
|
|
|
9
9
|
import { homedir } from "os";
|
|
10
10
|
import { join } from "path";
|
|
11
11
|
function getConfigDir() {
|
|
12
|
+
const ocxConfigDir = process.env.OPENCODE_CONFIG_DIR;
|
|
13
|
+
if (ocxConfigDir) {
|
|
14
|
+
return join(ocxConfigDir, "opencode-cliproxyapi-sync");
|
|
15
|
+
}
|
|
12
16
|
const xdgConfigHome = process.env.XDG_CONFIG_HOME;
|
|
13
17
|
const baseDir = xdgConfigHome || join(homedir(), ".config");
|
|
14
|
-
return join(baseDir, "opencode-cliproxyapi-sync");
|
|
18
|
+
return join(baseDir, "opencode", "opencode-cliproxyapi-sync");
|
|
15
19
|
}
|
|
16
20
|
function getConfigPath() {
|
|
17
21
|
return join(getConfigDir(), "config.json");
|
|
@@ -166,16 +170,6 @@ var ConfigSyncPlugin = async (ctx) => {
|
|
|
166
170
|
console.log("[cliproxyapi-sync] No config found. Skipping sync.");
|
|
167
171
|
return {};
|
|
168
172
|
}
|
|
169
|
-
setTimeout(() => {
|
|
170
|
-
ctx.client.tui.showToast({
|
|
171
|
-
body: {
|
|
172
|
-
title: "CLIProxyAPI Sync",
|
|
173
|
-
message: "Connected to dashboard",
|
|
174
|
-
variant: "success",
|
|
175
|
-
duration: 3000
|
|
176
|
-
}
|
|
177
|
-
});
|
|
178
|
-
}, 1000);
|
|
179
173
|
const versionResult = await checkVersion(config.dashboardUrl, config.syncToken);
|
|
180
174
|
if (!versionResult) {
|
|
181
175
|
console.error("[cliproxyapi-sync] Failed to check version. Skipping sync.");
|
|
@@ -198,18 +192,20 @@ var ConfigSyncPlugin = async (ctx) => {
|
|
|
198
192
|
await writeConfigAtomic(ohMyConfigPath, JSON.stringify(bundle.ohMyOpencode, null, 2));
|
|
199
193
|
}
|
|
200
194
|
const newOpencodeHash = await readFileHash(opencodeConfigPath);
|
|
201
|
-
if (oldOpencodeHash !== null && oldOpencodeHash !== newOpencodeHash) {
|
|
202
|
-
ctx.client.tui.showToast({
|
|
203
|
-
body: {
|
|
204
|
-
title: "Config Sync",
|
|
205
|
-
message: "opencode.json updated. Restart OpenCode to apply provider changes.",
|
|
206
|
-
variant: "warning",
|
|
207
|
-
duration: 8000
|
|
208
|
-
}
|
|
209
|
-
});
|
|
210
|
-
}
|
|
211
195
|
config.lastKnownVersion = bundle.version;
|
|
212
196
|
savePluginConfig(config);
|
|
197
|
+
if (oldOpencodeHash !== null && oldOpencodeHash !== newOpencodeHash) {
|
|
198
|
+
setTimeout(() => {
|
|
199
|
+
ctx.client.tui.showToast({
|
|
200
|
+
body: {
|
|
201
|
+
title: "CLIProxyAPI Config Updated",
|
|
202
|
+
message: "Restart OpenCode to apply changes",
|
|
203
|
+
variant: "warning",
|
|
204
|
+
duration: 8000
|
|
205
|
+
}
|
|
206
|
+
});
|
|
207
|
+
}, 1000);
|
|
208
|
+
}
|
|
213
209
|
console.log(`[cliproxyapi-sync] Synced to version ${bundle.version}`);
|
|
214
210
|
} catch (error) {
|
|
215
211
|
console.error("[cliproxyapi-sync] Sync error:", error);
|