opencode-synced 0.4.1 → 0.4.2

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
@@ -247,6 +247,25 @@ bun -e '
247
247
  - `bun run test`
248
248
  - `bun run lint`
249
249
 
250
+ ### Local testing (production-like)
251
+
252
+ To test the same artifact that would be published, install from a packed tarball
253
+ into OpenCode's cache:
254
+
255
+ ```bash
256
+ mise run local-pack-test
257
+ ```
258
+
259
+ Then set `~/.config/opencode/opencode.json` to use:
260
+
261
+ ```jsonc
262
+ {
263
+ "plugin": ["opencode-synced"]
264
+ }
265
+ ```
266
+
267
+ Restart OpenCode to pick up the cached install.
268
+
250
269
 
251
270
  ## Prefer a CLI version?
252
271
 
package/dist/index.d.ts CHANGED
@@ -1,2 +1,4 @@
1
1
  import type { Plugin } from '@opencode-ai/plugin';
2
2
  export declare const OpencodeConfigSync: Plugin;
3
+ export declare const OpencodeSynced: Plugin;
4
+ export default OpencodeConfigSync;
package/dist/index.js CHANGED
@@ -59,17 +59,29 @@ async function scanMdFiles(dir) {
59
59
  async function loadCommands() {
60
60
  const commands = [];
61
61
  const commandDir = path.join(getModuleDir(), 'command');
62
+ try {
63
+ const stats = await fs.stat(commandDir);
64
+ if (!stats.isDirectory()) {
65
+ return commands;
66
+ }
67
+ }
68
+ catch {
69
+ return commands;
70
+ }
62
71
  const files = await scanMdFiles(commandDir);
63
72
  for (const file of files) {
64
- const content = await fs.readFile(file, 'utf-8');
65
- const { frontmatter, body } = parseFrontmatter(content);
66
- const relativePath = path.relative(commandDir, file);
67
- const name = relativePath.replace(/\.md$/, '').replace(/\//g, '-');
68
- commands.push({
69
- name,
70
- frontmatter,
71
- template: body,
72
- });
73
+ try {
74
+ const content = await fs.readFile(file, 'utf-8');
75
+ const { frontmatter, body } = parseFrontmatter(content);
76
+ const relativePath = path.relative(commandDir, file);
77
+ const name = relativePath.replace(/\.md$/, '').replace(/\//g, '-');
78
+ commands.push({
79
+ name,
80
+ frontmatter,
81
+ template: body,
82
+ });
83
+ }
84
+ catch { }
73
85
  }
74
86
  return commands;
75
87
  }
@@ -180,6 +192,8 @@ export const OpencodeConfigSync = async (ctx) => {
180
192
  },
181
193
  };
182
194
  };
195
+ export const OpencodeSynced = OpencodeConfigSync;
196
+ export default OpencodeConfigSync;
183
197
  function formatError(error) {
184
198
  if (error instanceof Error)
185
199
  return error.message;
package/package.json CHANGED
@@ -1,13 +1,16 @@
1
1
  {
2
2
  "name": "opencode-synced",
3
- "version": "0.4.1",
3
+ "version": "0.4.2",
4
4
  "description": "Sync global OpenCode config across machines via GitHub.",
5
5
  "author": {
6
6
  "name": "Ian Hildebrand"
7
7
  },
8
8
  "type": "module",
9
+ "main": "./dist/index.js",
10
+ "types": "./dist/index.d.ts",
9
11
  "exports": {
10
12
  ".": {
13
+ "import": "./dist/index.js",
11
14
  "types": "./dist/index.d.ts",
12
15
  "default": "./dist/index.js"
13
16
  }
@@ -19,9 +22,7 @@
19
22
  "publishConfig": {
20
23
  "access": "public"
21
24
  },
22
- "files": [
23
- "dist"
24
- ],
25
+ "files": ["dist"],
25
26
  "dependencies": {
26
27
  "@opencode-ai/plugin": "1.0.85"
27
28
  },
@@ -38,6 +39,7 @@
38
39
  },
39
40
  "scripts": {
40
41
  "build": "rm -rf dist && tsc -p tsconfig.build.json && cp -r src/command dist/command",
42
+ "prepack": "bun run build",
41
43
  "test": "vitest run",
42
44
  "test:watch": "vitest",
43
45
  "lint": "biome lint .",
@@ -47,8 +49,6 @@
47
49
  "prepare": "husky"
48
50
  },
49
51
  "lint-staged": {
50
- "*.{js,ts,json}": [
51
- "biome check --write --no-errors-on-unmatched"
52
- ]
52
+ "*.{js,ts,json}": ["biome check --write --no-errors-on-unmatched"]
53
53
  }
54
54
  }