toggle-oh-my 1.0.1 → 1.0.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.
Files changed (2) hide show
  1. package/index.js +17 -11
  2. package/package.json +1 -1
package/index.js CHANGED
@@ -31,27 +31,33 @@ function findConfig() {
31
31
  }
32
32
  }
33
33
 
34
- // user-level: ~/.config/opencode/opencode.jsonc (or opencode.json)
34
+ // user-level configs: check ALL known platform paths
35
35
  const home = homedir();
36
36
  const userCandidates = [
37
+ // Windows paths (opencode on Windows may use any of these)
37
38
  join(home, '.config', 'opencode', 'opencode.jsonc'),
38
39
  join(home, '.config', 'opencode', 'opencode.json'),
39
40
  join(home, '.opencode.json'),
40
41
  ];
41
- for (const fp of userCandidates) {
42
- if (!existsSync(fp)) continue;
43
- const raw = readFileSync(fp, 'utf-8');
44
- return { path: fp, raw, format: fp.endsWith('.jsonc') ? 'jsonc' : 'json' };
42
+ // Windows: %APPDATA%/opencode/config.json
43
+ if (platform() === 'win32' && process.env.APPDATA) {
44
+ userCandidates.push(
45
+ join(process.env.APPDATA, 'opencode', 'config.json'),
46
+ join(process.env.APPDATA, 'opencode', 'opencode.jsonc'),
47
+ );
45
48
  }
46
-
47
- // Linux/macOS fallback: $XDG_CONFIG_HOME/opencode/opencode.jsonc
49
+ // Linux/macOS: $XDG_CONFIG_HOME
48
50
  if (platform() !== 'win32') {
49
51
  const xdg = process.env.XDG_CONFIG_HOME || join(home, '.config');
50
- const fp = join(xdg, 'opencode', 'opencode.jsonc');
51
- if (existsSync(fp)) {
52
+ userCandidates.push(join(xdg, 'opencode', 'opencode.jsonc'));
53
+ }
54
+
55
+ for (const fp of userCandidates) {
56
+ if (!existsSync(fp)) continue;
57
+ try {
52
58
  const raw = readFileSync(fp, 'utf-8');
53
- return { path: fp, raw, format: 'jsonc' };
54
- }
59
+ return { path: fp, raw, format: fp.endsWith('.jsonc') ? 'jsonc' : 'json' };
60
+ } catch { /* permission issue, try next */ }
55
61
  }
56
62
 
57
63
  return null;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "toggle-oh-my",
3
- "version": "1.0.1",
3
+ "version": "1.0.2",
4
4
  "description": "Opencode plugin to toggle oh-my-opencode on/off with a /toggle-oh-my command",
5
5
  "type": "module",
6
6
  "main": "index.js",