opencode-sync-plugin 0.1.2 → 0.1.5

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 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
@@ -2,23 +2,32 @@
2
2
  import Conf from "conf";
3
3
  import { homedir } from "os";
4
4
  import { join } from "path";
5
- var config = new Conf({
6
- projectName: "opencode-sync",
7
- cwd: join(homedir(), ".config", "opencode-sync"),
8
- configName: "config"
9
- });
5
+ var _config = null;
6
+ function getConfInstance() {
7
+ if (!_config) {
8
+ _config = new Conf({
9
+ projectName: "opencode-sync",
10
+ cwd: join(homedir(), ".config", "opencode-sync"),
11
+ configName: "config"
12
+ });
13
+ }
14
+ return _config;
15
+ }
10
16
  function getConfig() {
11
- const url = config.get("convexUrl");
12
- const key = config.get("apiKey");
17
+ const conf = getConfInstance();
18
+ const url = conf.get("convexUrl");
19
+ const key = conf.get("apiKey");
13
20
  if (!url) return null;
14
21
  return { convexUrl: url, apiKey: key || "" };
15
22
  }
16
23
  function setConfig(cfg) {
17
- config.set("convexUrl", cfg.convexUrl);
18
- config.set("apiKey", cfg.apiKey);
24
+ const conf = getConfInstance();
25
+ conf.set("convexUrl", cfg.convexUrl);
26
+ conf.set("apiKey", cfg.apiKey);
19
27
  }
20
28
  function clearConfig() {
21
- config.clear();
29
+ const conf = getConfInstance();
30
+ conf.clear();
22
31
  }
23
32
  function getApiKey() {
24
33
  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-LXC2JAKD.js";
6
+ } from "./chunk-PAZWJPY7.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 your opencode.json:");
63
- console.log(' { "plugin": ["opencode-sync-plugin"] }\n');
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: { "plugin": ["opencode-sync-plugin"] }
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
@@ -3,7 +3,7 @@ import {
3
3
  clearConfig,
4
4
  getConfig,
5
5
  setConfig
6
- } from "./chunk-LXC2JAKD.js";
6
+ } from "./chunk-PAZWJPY7.js";
7
7
  export {
8
8
  OpenCodeSyncPlugin,
9
9
  clearConfig,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "opencode-sync-plugin",
3
- "version": "0.1.2",
3
+ "version": "0.1.5",
4
4
  "description": "Sync your OpenCode sessions to the cloud",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",