opencode-code-simplifier 1.1.0 → 1.2.0

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/install.js +21 -10
  2. package/package.json +1 -1
package/install.js CHANGED
@@ -13,8 +13,8 @@ const os = require('os');
13
13
  const sourceDir = __dirname;
14
14
 
15
15
  // Target directories
16
- const projectDir = path.join(process.cwd(), '.opencode');
17
16
  const globalDir = path.join(os.homedir(), '.config', 'opencode');
17
+ const projectDir = path.join(process.cwd(), '.opencode');
18
18
 
19
19
  function copyDir(src, dest) {
20
20
  if (!fs.existsSync(dest)) {
@@ -32,18 +32,18 @@ function copyDir(src, dest) {
32
32
  } else {
33
33
  if (!fs.existsSync(destPath)) {
34
34
  fs.copyFileSync(srcPath, destPath);
35
- console.log(` ✓ ${path.relative(process.cwd(), destPath)}`);
35
+ console.log(` ✓ ${destPath}`);
36
36
  } else {
37
- console.log(` ⊘ ${path.relative(process.cwd(), destPath)} (exists, skipped)`);
37
+ console.log(` ⊘ ${destPath} (exists, skipped)`);
38
38
  }
39
39
  }
40
40
  }
41
41
  }
42
42
 
43
- function install(targetDir) {
43
+ function install(targetDir, label) {
44
44
  const dirs = ['skills', 'rules', 'commands'];
45
45
 
46
- console.log(`\n📦 Installing opencode-code-simplifier to ${targetDir}\n`);
46
+ console.log(`\n📦 Installing opencode-code-simplifier to ${label}: ${targetDir}\n`);
47
47
 
48
48
  for (const dir of dirs) {
49
49
  const src = path.join(sourceDir, dir);
@@ -58,10 +58,21 @@ function install(targetDir) {
58
58
  console.log('\n✅ Done! Restart OpenCode to use the plugin.\n');
59
59
  }
60
60
 
61
- // Install to project .opencode directory
62
- if (fs.existsSync(projectDir)) {
63
- install(projectDir);
61
+ // Check if this is a global install
62
+ const isGlobal = process.env.npm_config_global === 'true' ||
63
+ process.env.npm_config_global === true ||
64
+ __dirname.includes('global') ||
65
+ __dirname.includes('.cache/opencode');
66
+
67
+ if (isGlobal) {
68
+ // Global install - copy to ~/.config/opencode/
69
+ install(globalDir, 'global');
70
+ } else if (fs.existsSync(projectDir)) {
71
+ // Project install - copy to .opencode/
72
+ install(projectDir, 'project');
64
73
  } else {
65
- console.log('\n⚠️ No .opencode directory found in current project.');
66
- console.log(' Run this in your project root, or install globally.\n');
74
+ console.log('\n⚠️ No .opencode directory found.');
75
+ console.log(' Creating project .opencode directory...\n');
76
+ fs.mkdirSync(projectDir, { recursive: true });
77
+ install(projectDir, 'project');
67
78
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "opencode-code-simplifier",
3
- "version": "1.1.0",
3
+ "version": "1.2.0",
4
4
  "description": "Code simplifier plugin for OpenCode - simplifies and refines code for clarity while preserving functionality",
5
5
  "main": "dist/plugin.js",
6
6
  "types": "dist/plugin.d.ts",