opencode-sync-plugin 0.1.2 → 0.1.6
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 +52 -0
- package/dist/{chunk-LXC2JAKD.js → chunk-46RJJUZ6.js} +31 -13
- package/dist/cli.js +80 -4
- package/dist/index.js +1 -1
- package/package.json +1 -4
package/README.md
CHANGED
|
@@ -74,6 +74,28 @@ mkdir -p ~/.config/opencode && echo '{
|
|
|
74
74
|
|
|
75
75
|
> **Note:** If you already have an `opencode.json` with other settings, edit the file manually and add `"plugin": ["opencode-sync-plugin"]` to preserve your existing configuration. OpenCode merges configs, so you can keep your theme, model, and other settings.
|
|
76
76
|
|
|
77
|
+
### 4. Verify installation
|
|
78
|
+
|
|
79
|
+
```bash
|
|
80
|
+
opencode-sync verify
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
This checks that both your credentials and OpenCode config are set up correctly. You should see:
|
|
84
|
+
|
|
85
|
+
```
|
|
86
|
+
OpenSync Setup Verification
|
|
87
|
+
|
|
88
|
+
Credentials: OK
|
|
89
|
+
Convex URL: https://your-project.convex.cloud
|
|
90
|
+
API Key: osk_****...****
|
|
91
|
+
|
|
92
|
+
OpenCode Config: OK
|
|
93
|
+
Config file: ~/.config/opencode/opencode.json
|
|
94
|
+
Plugin registered: opencode-sync-plugin
|
|
95
|
+
|
|
96
|
+
Ready! Start OpenCode and the plugin will load automatically.
|
|
97
|
+
```
|
|
98
|
+
|
|
77
99
|
## How it works
|
|
78
100
|
|
|
79
101
|
The plugin hooks into OpenCode events and syncs data automatically:
|
|
@@ -93,6 +115,7 @@ Data is stored in your Convex deployment. You can view, search, and share sessio
|
|
|
93
115
|
| Command | Description |
|
|
94
116
|
|---------|-------------|
|
|
95
117
|
| `opencode-sync login` | Configure with Convex URL and API Key |
|
|
118
|
+
| `opencode-sync verify` | Verify credentials and OpenCode config |
|
|
96
119
|
| `opencode-sync logout` | Clear stored credentials |
|
|
97
120
|
| `opencode-sync status` | Show authentication status |
|
|
98
121
|
| `opencode-sync config` | Show current configuration |
|
|
@@ -137,6 +160,35 @@ export const OpenCodeSyncPlugin: Plugin = async ({ project, client, $, directory
|
|
|
137
160
|
|
|
138
161
|
## Troubleshooting
|
|
139
162
|
|
|
163
|
+
### OpenCode won't start or shows blank screen
|
|
164
|
+
|
|
165
|
+
If OpenCode hangs or shows a blank screen after adding the plugin, remove the plugin config:
|
|
166
|
+
|
|
167
|
+
**Step 1: Open a new terminal window**
|
|
168
|
+
|
|
169
|
+
**Step 2: Remove the plugin from your config**
|
|
170
|
+
|
|
171
|
+
```bash
|
|
172
|
+
# Option A: Delete the entire config (if you only have the plugin configured)
|
|
173
|
+
rm ~/.config/opencode/opencode.json
|
|
174
|
+
|
|
175
|
+
# Option B: Edit the file to remove the plugin line
|
|
176
|
+
nano ~/.config/opencode/opencode.json
|
|
177
|
+
# Remove the "plugin": ["opencode-sync-plugin"] line and save
|
|
178
|
+
```
|
|
179
|
+
|
|
180
|
+
**Step 3: Clear the plugin cache**
|
|
181
|
+
|
|
182
|
+
```bash
|
|
183
|
+
rm -rf ~/.cache/opencode/node_modules/opencode-sync-plugin
|
|
184
|
+
```
|
|
185
|
+
|
|
186
|
+
**Step 4: Restart OpenCode**
|
|
187
|
+
|
|
188
|
+
```bash
|
|
189
|
+
opencode
|
|
190
|
+
```
|
|
191
|
+
|
|
140
192
|
### "Not authenticated" errors
|
|
141
193
|
|
|
142
194
|
```bash
|
|
@@ -1,24 +1,42 @@
|
|
|
1
1
|
// src/index.ts
|
|
2
|
-
import Conf from "conf";
|
|
3
2
|
import { homedir } from "os";
|
|
4
3
|
import { join } from "path";
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
4
|
+
import { readFileSync, writeFileSync, mkdirSync, existsSync } from "fs";
|
|
5
|
+
var CONFIG_DIR = join(homedir(), ".config", "opencode-sync");
|
|
6
|
+
var CONFIG_FILE = join(CONFIG_DIR, "config.json");
|
|
7
|
+
function readConfigFile() {
|
|
8
|
+
try {
|
|
9
|
+
if (!existsSync(CONFIG_FILE)) return null;
|
|
10
|
+
const content = readFileSync(CONFIG_FILE, "utf8");
|
|
11
|
+
return JSON.parse(content);
|
|
12
|
+
} catch {
|
|
13
|
+
return null;
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
function writeConfigFile(config) {
|
|
17
|
+
try {
|
|
18
|
+
if (!existsSync(CONFIG_DIR)) {
|
|
19
|
+
mkdirSync(CONFIG_DIR, { recursive: true });
|
|
20
|
+
}
|
|
21
|
+
writeFileSync(CONFIG_FILE, JSON.stringify(config, null, 2), "utf8");
|
|
22
|
+
} catch {
|
|
23
|
+
}
|
|
24
|
+
}
|
|
10
25
|
function getConfig() {
|
|
11
|
-
const
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
return { convexUrl: url, apiKey: key || "" };
|
|
26
|
+
const config = readConfigFile();
|
|
27
|
+
if (!config || !config.convexUrl) return null;
|
|
28
|
+
return config;
|
|
15
29
|
}
|
|
16
30
|
function setConfig(cfg) {
|
|
17
|
-
|
|
18
|
-
config.set("apiKey", cfg.apiKey);
|
|
31
|
+
writeConfigFile(cfg);
|
|
19
32
|
}
|
|
20
33
|
function clearConfig() {
|
|
21
|
-
|
|
34
|
+
try {
|
|
35
|
+
if (existsSync(CONFIG_FILE)) {
|
|
36
|
+
writeFileSync(CONFIG_FILE, "{}", "utf8");
|
|
37
|
+
}
|
|
38
|
+
} catch {
|
|
39
|
+
}
|
|
22
40
|
}
|
|
23
41
|
function getApiKey() {
|
|
24
42
|
const cfg = getConfig();
|
package/dist/cli.js
CHANGED
|
@@ -3,9 +3,12 @@ import {
|
|
|
3
3
|
clearConfig,
|
|
4
4
|
getConfig,
|
|
5
5
|
setConfig
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-46RJJUZ6.js";
|
|
7
7
|
|
|
8
8
|
// src/cli.ts
|
|
9
|
+
import { readFileSync, existsSync } from "fs";
|
|
10
|
+
import { homedir } from "os";
|
|
11
|
+
import { join } from "path";
|
|
9
12
|
var args = process.argv.slice(2);
|
|
10
13
|
var command = args[0];
|
|
11
14
|
async function main() {
|
|
@@ -13,6 +16,9 @@ async function main() {
|
|
|
13
16
|
case "login":
|
|
14
17
|
await login();
|
|
15
18
|
break;
|
|
19
|
+
case "verify":
|
|
20
|
+
verify();
|
|
21
|
+
break;
|
|
16
22
|
case "logout":
|
|
17
23
|
logout();
|
|
18
24
|
break;
|
|
@@ -59,8 +65,16 @@ async function login() {
|
|
|
59
65
|
console.log("\nLogin successful!\n");
|
|
60
66
|
console.log(" Convex URL:", convexUrl);
|
|
61
67
|
console.log(" API Key:", apiKey.slice(0, 8) + "..." + apiKey.slice(-4));
|
|
62
|
-
console.log("\n Add the plugin to
|
|
63
|
-
console.log(
|
|
68
|
+
console.log("\n Next step: Add the plugin to OpenCode\n");
|
|
69
|
+
console.log(" Run this command (copy/paste into terminal):\n");
|
|
70
|
+
console.log(` mkdir -p ~/.config/opencode && echo '{
|
|
71
|
+
"$schema": "https://opencode.ai/config.json",
|
|
72
|
+
"plugin": ["opencode-sync-plugin"]
|
|
73
|
+
}' > ~/.config/opencode/opencode.json`);
|
|
74
|
+
console.log("\n Then verify your setup:\n");
|
|
75
|
+
console.log(" opencode-sync verify\n");
|
|
76
|
+
console.log(" Note: If you have existing opencode.json settings, manually add");
|
|
77
|
+
console.log(' "plugin": ["opencode-sync-plugin"] to preserve your config.\n');
|
|
64
78
|
} catch (e) {
|
|
65
79
|
console.error("\nFailed to connect to OpenSync backend.");
|
|
66
80
|
console.error("Please verify your Convex URL is correct.");
|
|
@@ -71,6 +85,66 @@ function logout() {
|
|
|
71
85
|
clearConfig();
|
|
72
86
|
console.log("\nLogged out successfully\n");
|
|
73
87
|
}
|
|
88
|
+
function verify() {
|
|
89
|
+
console.log("\n OpenSync Setup Verification\n");
|
|
90
|
+
let hasErrors = false;
|
|
91
|
+
const config = getConfig();
|
|
92
|
+
if (!config || !config.apiKey) {
|
|
93
|
+
console.log(" Credentials: MISSING");
|
|
94
|
+
console.log(" Run: opencode-sync login\n");
|
|
95
|
+
hasErrors = true;
|
|
96
|
+
} else {
|
|
97
|
+
console.log(" Credentials: OK");
|
|
98
|
+
console.log(" Convex URL:", config.convexUrl);
|
|
99
|
+
console.log(" API Key:", config.apiKey.slice(0, 8) + "..." + config.apiKey.slice(-4));
|
|
100
|
+
console.log();
|
|
101
|
+
}
|
|
102
|
+
const opencodeConfigPath = join(homedir(), ".config", "opencode", "opencode.json");
|
|
103
|
+
const projectConfigPath = join(process.cwd(), "opencode.json");
|
|
104
|
+
let configFound = false;
|
|
105
|
+
let configPath = "";
|
|
106
|
+
let pluginRegistered = false;
|
|
107
|
+
for (const path of [opencodeConfigPath, projectConfigPath]) {
|
|
108
|
+
if (existsSync(path)) {
|
|
109
|
+
configFound = true;
|
|
110
|
+
configPath = path;
|
|
111
|
+
try {
|
|
112
|
+
const content = readFileSync(path, "utf8");
|
|
113
|
+
const parsed = JSON.parse(content);
|
|
114
|
+
if (parsed.plugin && Array.isArray(parsed.plugin) && parsed.plugin.includes("opencode-sync-plugin")) {
|
|
115
|
+
pluginRegistered = true;
|
|
116
|
+
break;
|
|
117
|
+
}
|
|
118
|
+
} catch {
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
if (!configFound) {
|
|
123
|
+
console.log(" OpenCode Config: MISSING");
|
|
124
|
+
console.log(" Run this command to create it:\n");
|
|
125
|
+
console.log(` mkdir -p ~/.config/opencode && echo '{
|
|
126
|
+
"$schema": "https://opencode.ai/config.json",
|
|
127
|
+
"plugin": ["opencode-sync-plugin"]
|
|
128
|
+
}' > ~/.config/opencode/opencode.json
|
|
129
|
+
`);
|
|
130
|
+
hasErrors = true;
|
|
131
|
+
} else if (!pluginRegistered) {
|
|
132
|
+
console.log(" OpenCode Config: FOUND but plugin not registered");
|
|
133
|
+
console.log(" Config file:", configPath);
|
|
134
|
+
console.log(' Add "plugin": ["opencode-sync-plugin"] to your config\n');
|
|
135
|
+
hasErrors = true;
|
|
136
|
+
} else {
|
|
137
|
+
console.log(" OpenCode Config: OK");
|
|
138
|
+
console.log(" Config file:", configPath);
|
|
139
|
+
console.log(" Plugin registered: opencode-sync-plugin");
|
|
140
|
+
console.log();
|
|
141
|
+
}
|
|
142
|
+
if (hasErrors) {
|
|
143
|
+
console.log(" Setup incomplete. Fix the issues above and run verify again.\n");
|
|
144
|
+
} else {
|
|
145
|
+
console.log(" Ready! Start OpenCode and the plugin will load automatically.\n");
|
|
146
|
+
}
|
|
147
|
+
}
|
|
74
148
|
function status() {
|
|
75
149
|
const config = getConfig();
|
|
76
150
|
console.log("\n OpenSync Status\n");
|
|
@@ -110,6 +184,7 @@ function help() {
|
|
|
110
184
|
|
|
111
185
|
Commands:
|
|
112
186
|
login Configure with Convex URL and API Key
|
|
187
|
+
verify Verify credentials and OpenCode config
|
|
113
188
|
logout Clear stored credentials
|
|
114
189
|
status Show current authentication status
|
|
115
190
|
config Show current configuration
|
|
@@ -119,7 +194,8 @@ function help() {
|
|
|
119
194
|
2. Generate an API Key (starts with osk_)
|
|
120
195
|
3. Run: opencode-sync login
|
|
121
196
|
4. Enter your Convex URL and API Key
|
|
122
|
-
5. Add plugin to opencode.json
|
|
197
|
+
5. Add plugin to opencode.json (see instructions after login)
|
|
198
|
+
6. Run: opencode-sync verify
|
|
123
199
|
`);
|
|
124
200
|
}
|
|
125
201
|
function prompt(question) {
|
package/dist/index.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "opencode-sync-plugin",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.6",
|
|
4
4
|
"description": "Sync your OpenCode sessions to the cloud",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -35,9 +35,6 @@
|
|
|
35
35
|
"url": "https://github.com/waynesutton/opencode-sync-plugin"
|
|
36
36
|
},
|
|
37
37
|
"license": "MIT",
|
|
38
|
-
"dependencies": {
|
|
39
|
-
"conf": "^12.0.0"
|
|
40
|
-
},
|
|
41
38
|
"devDependencies": {
|
|
42
39
|
"@types/node": "^20.0.0",
|
|
43
40
|
"tsup": "^8.0.0",
|