opencode-sync-plugin 0.1.5 → 0.1.7

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
@@ -158,6 +158,8 @@ export const OpenCodeSyncPlugin: Plugin = async ({ project, client, $, directory
158
158
  };
159
159
  ```
160
160
 
161
+ This plugin exports both a named and default export so OpenCode can load it from npm reliably.
162
+
161
163
  ## Troubleshooting
162
164
 
163
165
  ### OpenCode won't start or shows blank screen
@@ -189,6 +191,8 @@ rm -rf ~/.cache/opencode/node_modules/opencode-sync-plugin
189
191
  opencode
190
192
  ```
191
193
 
194
+ If the issue persists, reinstall the latest version and clear the cache again.
195
+
192
196
  ### "Not authenticated" errors
193
197
 
194
198
  ```bash
@@ -1,33 +1,48 @@
1
1
  // src/index.ts
2
- import Conf from "conf";
3
2
  import { homedir } from "os";
4
3
  import { join } from "path";
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
- });
4
+ import { readFileSync, writeFileSync, mkdirSync, existsSync } from "fs";
5
+ async function safeLog(client, entry) {
6
+ try {
7
+ await client?.app?.log?.(entry);
8
+ } catch {
9
+ }
10
+ }
11
+ var CONFIG_DIR = join(homedir(), ".config", "opencode-sync");
12
+ var CONFIG_FILE = join(CONFIG_DIR, "config.json");
13
+ function readConfigFile() {
14
+ try {
15
+ if (!existsSync(CONFIG_FILE)) return null;
16
+ const content = readFileSync(CONFIG_FILE, "utf8");
17
+ return JSON.parse(content);
18
+ } catch {
19
+ return null;
20
+ }
21
+ }
22
+ function writeConfigFile(config) {
23
+ try {
24
+ if (!existsSync(CONFIG_DIR)) {
25
+ mkdirSync(CONFIG_DIR, { recursive: true });
26
+ }
27
+ writeFileSync(CONFIG_FILE, JSON.stringify(config, null, 2), "utf8");
28
+ } catch {
13
29
  }
14
- return _config;
15
30
  }
16
31
  function getConfig() {
17
- const conf = getConfInstance();
18
- const url = conf.get("convexUrl");
19
- const key = conf.get("apiKey");
20
- if (!url) return null;
21
- return { convexUrl: url, apiKey: key || "" };
32
+ const config = readConfigFile();
33
+ if (!config || !config.convexUrl) return null;
34
+ return config;
22
35
  }
23
36
  function setConfig(cfg) {
24
- const conf = getConfInstance();
25
- conf.set("convexUrl", cfg.convexUrl);
26
- conf.set("apiKey", cfg.apiKey);
37
+ writeConfigFile(cfg);
27
38
  }
28
39
  function clearConfig() {
29
- const conf = getConfInstance();
30
- conf.clear();
40
+ try {
41
+ if (existsSync(CONFIG_FILE)) {
42
+ writeFileSync(CONFIG_FILE, "{}", "utf8");
43
+ }
44
+ } catch {
45
+ }
31
46
  }
32
47
  function getApiKey() {
33
48
  const cfg = getConfig();
@@ -49,7 +64,7 @@ async function syncSession(session, client) {
49
64
  const apiKey = getApiKey();
50
65
  const siteUrl = getSiteUrl();
51
66
  if (!apiKey || !siteUrl) {
52
- await client.app.log({
67
+ await safeLog(client, {
53
68
  service: "opencode-sync",
54
69
  level: "warn",
55
70
  message: "Not authenticated. Run: opencode-sync login"
@@ -77,14 +92,14 @@ async function syncSession(session, client) {
77
92
  });
78
93
  if (!response.ok) {
79
94
  const errorText = await response.text();
80
- await client.app.log({
95
+ await safeLog(client, {
81
96
  service: "opencode-sync",
82
97
  level: "error",
83
98
  message: `Session sync failed: ${errorText}`
84
99
  });
85
100
  }
86
101
  } catch (e) {
87
- await client.app.log({
102
+ await safeLog(client, {
88
103
  service: "opencode-sync",
89
104
  level: "error",
90
105
  message: `Session sync error: ${e}`
@@ -117,14 +132,14 @@ async function syncMessage(sessionId, message, client) {
117
132
  });
118
133
  if (!response.ok) {
119
134
  const errorText = await response.text();
120
- await client.app.log({
135
+ await safeLog(client, {
121
136
  service: "opencode-sync",
122
137
  level: "error",
123
138
  message: `Message sync failed: ${errorText}`
124
139
  });
125
140
  }
126
141
  } catch (e) {
127
- await client.app.log({
142
+ await safeLog(client, {
128
143
  service: "opencode-sync",
129
144
  level: "error",
130
145
  message: `Message sync error: ${e}`
@@ -181,13 +196,13 @@ var syncedSessions = /* @__PURE__ */ new Set();
181
196
  var OpenCodeSyncPlugin = async ({ project, client, $, directory, worktree }) => {
182
197
  const cfg = getConfig();
183
198
  if (!cfg || !cfg.apiKey) {
184
- await client.app.log({
199
+ await safeLog(client, {
185
200
  service: "opencode-sync",
186
201
  level: "warn",
187
202
  message: "Not configured. Run: opencode-sync login"
188
203
  });
189
204
  } else {
190
- await client.app.log({
205
+ await safeLog(client, {
191
206
  service: "opencode-sync",
192
207
  level: "info",
193
208
  message: "Plugin initialized",
@@ -242,10 +257,12 @@ var OpenCodeSyncPlugin = async ({ project, client, $, directory, worktree }) =>
242
257
  }
243
258
  };
244
259
  };
260
+ var index_default = OpenCodeSyncPlugin;
245
261
 
246
262
  export {
247
263
  getConfig,
248
264
  setConfig,
249
265
  clearConfig,
250
- OpenCodeSyncPlugin
266
+ OpenCodeSyncPlugin,
267
+ index_default
251
268
  };
package/dist/cli.js CHANGED
@@ -3,7 +3,7 @@ import {
3
3
  clearConfig,
4
4
  getConfig,
5
5
  setConfig
6
- } from "./chunk-PAZWJPY7.js";
6
+ } from "./chunk-GVXT3A2F.js";
7
7
 
8
8
  // src/cli.ts
9
9
  import { readFileSync, existsSync } from "fs";
package/dist/index.d.ts CHANGED
@@ -39,4 +39,4 @@ declare function clearConfig(): void;
39
39
  */
40
40
  declare const OpenCodeSyncPlugin: Plugin;
41
41
 
42
- export { OpenCodeSyncPlugin, clearConfig, getConfig, setConfig };
42
+ export { OpenCodeSyncPlugin, clearConfig, OpenCodeSyncPlugin as default, getConfig, setConfig };
package/dist/index.js CHANGED
@@ -2,11 +2,13 @@ import {
2
2
  OpenCodeSyncPlugin,
3
3
  clearConfig,
4
4
  getConfig,
5
+ index_default,
5
6
  setConfig
6
- } from "./chunk-PAZWJPY7.js";
7
+ } from "./chunk-GVXT3A2F.js";
7
8
  export {
8
9
  OpenCodeSyncPlugin,
9
10
  clearConfig,
11
+ index_default as default,
10
12
  getConfig,
11
13
  setConfig
12
14
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "opencode-sync-plugin",
3
- "version": "0.1.5",
3
+ "version": "0.1.7",
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",