opencode-code-simplifier 1.0.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 (3) hide show
  1. package/README.md +60 -0
  2. package/dist/plugin.js +12421 -0
  3. package/package.json +30 -0
package/README.md ADDED
@@ -0,0 +1,60 @@
1
+ # opencode-code-simplifier
2
+
3
+ Code simplifier plugin for [OpenCode](https://opencode.ai). Simplifies and refines code for clarity while preserving functionality.
4
+
5
+ ## Features
6
+
7
+ - Reduces nesting and complexity
8
+ - Removes debug artifacts (unconditional console.log, debugger, commented code)
9
+ - Removes obvious comments that describe what code does
10
+ - Preserves conditional logging (logs behind `if (debug)`, `if (isDev)`, etc.)
11
+ - Converts nested ternaries to if/else chains
12
+ - Applies language-specific best practices
13
+
14
+ ## Install
15
+
16
+ Add to your `opencode.json`:
17
+
18
+ ```json
19
+ {
20
+ "plugin": ["opencode-code-simplifier"]
21
+ }
22
+ ```
23
+
24
+ Or place the plugin file in:
25
+ - `.opencode/plugins/` (project-level)
26
+ - `~/.config/opencode/plugins/` (global)
27
+
28
+ ## Usage
29
+
30
+ ### Automatic
31
+
32
+ The plugin logs when code is modified. Run simplification manually or ask OpenCode to simplify.
33
+
34
+ ### Manual
35
+
36
+ Use the `simplify-code` tool:
37
+
38
+ ```
39
+ /simplify-code file=path/to/file.js
40
+ ```
41
+
42
+ ### Via Command
43
+
44
+ The plugin works with the `/simplify` command if you have a corresponding command file.
45
+
46
+ ## What Gets Removed
47
+
48
+ | Type | Action |
49
+ |------|--------|
50
+ | `console.log('debug')` | Removed |
51
+ | `if (debug) console.log(...)` | Kept |
52
+ | `debugger` | Removed |
53
+ | Commented-out code | Removed |
54
+ | Obvious comments | Removed |
55
+ | `console.error` | Kept |
56
+ | Logger calls with levels | Kept |
57
+
58
+ ## License
59
+
60
+ MIT