opencode-enhancer-plugin 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.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 OpenCode Enhancer Plugin Contributors
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,237 @@
1
+ # πŸš€ OpenCode Enhancer Plugin
2
+
3
+ [![npm version](https://img.shields.io/npm/v/opencode-enhancer-plugin.svg)](https://www.npmjs.com/package/opencode-enhancer-plugin)
4
+ [![License](https://img.shields.io/badge/license-MIT-green.svg)](LICENSE)
5
+ [![OpenCode](https://img.shields.io/badge/OpenCode-Plugin-purple.svg)](https://opencode.ai)
6
+
7
+ > **Universal Technical Architect & Prompt Enhancer** - Transform vague ideas into precise, context-aware engineering specifications.
8
+
9
+ ## ✨ What is Enhancer?
10
+
11
+ The **Enhancer** is a third primary agent mode for OpenCode that sits alongside **Plan** and **Build**. It acts as your technical architect, analyzing your codebase and generating detailed, actionable prompts that you can execute in Build mode.
12
+
13
+ ### 🎯 Key Features
14
+
15
+ - **πŸ” Intelligent Context Analysis** - Automatically explores your project structure, tech stack, and relevant files
16
+ - **🧠 Intent Classification** - Categorizes requests as FIX, FEAT, REFACTOR, TEST, or EXPLAIN
17
+ - **πŸ“š Context7 Integration** - Conditionally includes `use context7` when documentation-heavy frameworks are detected
18
+ - **🎨 Style-Aware** - Mimics your project's coding style and patterns
19
+ - **⚑ One-Click Workflow** - Generates copy-pasteable prompts ready for Build mode
20
+
21
+ ## πŸš€ Quick Start
22
+
23
+ ### Installation
24
+
25
+ #### From npm (Recommended)
26
+
27
+ Add to your OpenCode config (`~/.config/opencode/opencode.json`):
28
+
29
+ ```json
30
+ {
31
+ "$schema": "https://opencode.ai/config.json",
32
+ "plugin": [
33
+ "opencode-enhancer-plugin@latest"
34
+ ]
35
+ }
36
+ ```
37
+
38
+ **Restart OpenCode** and press `Tab` to cycle through modes:
39
+ ```
40
+ Plan β†’ Build β†’ Enhancer β†’ Plan
41
+ ```
42
+
43
+ #### From Source (Development)
44
+
45
+ 1. **Clone** this repository:
46
+ ```bash
47
+ git clone https://github.com/MaansenV/opencode-enhancer-plugin.git
48
+ cd opencode-enhancer-plugin
49
+ ```
50
+
51
+ 2. **Install dependencies** and build:
52
+ ```bash
53
+ npm install
54
+ npm run build
55
+ ```
56
+
57
+ 3. **Add to your OpenCode config** using the local path:
58
+ ```json
59
+ {
60
+ "plugin": [
61
+ "file:///path/to/opencode-enhancer-plugin/dist/index.js"
62
+ ]
63
+ }
64
+ ```
65
+
66
+ ### Version Management
67
+
68
+ - **Latest version**: `"opencode-enhancer-plugin@latest"`
69
+ - **Specific version**: `"opencode-enhancer-plugin@1.0.0"`
70
+ - **Update**: OpenCode auto-updates plugins on startup, or run `opencode --update-plugins`
71
+
72
+ ### Uninstall
73
+
74
+ Remove from your `opencode.json`:
75
+ ```json
76
+ {
77
+ "plugin": []
78
+ }
79
+ ```
80
+
81
+ ## πŸ“– How It Works
82
+
83
+ ```
84
+ β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
85
+ β”‚ User │────▢│ Enhancer │────▢│ Build β”‚
86
+ β”‚ Request β”‚ β”‚ Agent β”‚ β”‚ Mode β”‚
87
+ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
88
+ β”‚
89
+ β–Ό
90
+ β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
91
+ β”‚ Explore- β”‚
92
+ β”‚ Context β”‚
93
+ β”‚ (Subagent) β”‚
94
+ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
95
+ ```
96
+
97
+ ### Workflow
98
+
99
+ 1. **Select Enhancer Mode** (Tab to cycle)
100
+ 2. **Describe your goal** - "Fix the login bug" or "Add user authentication"
101
+ 3. **Enhancer analyzes** - Calls explore-context to map your codebase
102
+ 4. **Receive enhanced prompt** - Structured markdown with context, instructions, and technical requirements
103
+ 5. **Copy & Execute** - Switch to Build mode and run the generated prompt
104
+
105
+ ## 🎨 Example Output
106
+
107
+ ```markdown
108
+ # Task: Fix Authentication Token Validation
109
+
110
+ ## Context
111
+ Detected **React + TypeScript + Express** project. Authentication logic located in `src/auth/middleware.ts` and `src/utils/token.ts`.
112
+
113
+ ## Instructions
114
+ use context7
115
+ 1. Modify `src/auth/middleware.ts`:
116
+ - Locate function `validateToken` (line 45)
117
+ - Add null check for `req.headers.authorization`
118
+ - Implement JWT verification using existing `verify()` pattern
119
+ 2. Update `src/utils/token.ts`:
120
+ - Add error handling for expired tokens
121
+ - Return structured error object instead of throwing
122
+ 3. Testing:
123
+ - Run `npm test` to verify auth flow
124
+ - Check edge cases: missing token, expired token, malformed token
125
+
126
+ ## Technical Requirements
127
+ - **Style**: Follow existing async/await patterns
128
+ - **Error Handling**: Use `try/catch` with custom AuthError class
129
+ - **TypeScript**: Maintain strict typing, add interfaces for token payload
130
+ ```
131
+
132
+ ## πŸ› οΈ Architecture
133
+
134
+ ### Components
135
+
136
+ | Component | Type | Description |
137
+ |-----------|------|-------------|
138
+ | **Enhancer** | Primary Agent | Main interface, intent classification, prompt generation |
139
+ | **Explore-Context** | Subagent | Read-only codebase analysis, tech stack detection |
140
+ | **check_context7** | Tool | Decides if libraries need Context7 documentation |
141
+
142
+ ### Supported Tech Stacks
143
+
144
+ - **Web**: React, Vue, Angular, Svelte, Next.js, Nuxt, Vite
145
+ - **Backend**: Express, Django, Flask, FastAPI, Rails, Laravel, Spring
146
+ - **Game Engines**: Unity, Godot, Unreal Engine
147
+ - **Data/ML**: TensorFlow, PyTorch, NumPy, Pandas
148
+ - **Infrastructure**: Docker, Kubernetes, Terraform
149
+ - **And more...**
150
+
151
+ ## βš™οΈ Configuration
152
+
153
+ ### Agent Configuration
154
+
155
+ The plugin automatically registers both agents via the `config` hook:
156
+
157
+ ```typescript
158
+ // Enhancer (Primary Agent)
159
+ {
160
+ mode: "primary",
161
+ model: "opencode/kimi-k2.5-free",
162
+ description: "Universal Technical Architect & Prompt Enhancer",
163
+ color: "#9C27B0",
164
+ steps: 15,
165
+ tools: { task: true, read: true }
166
+ }
167
+
168
+ // Explore-Context (Subagent)
169
+ {
170
+ mode: "subagent",
171
+ hidden: true,
172
+ model: "opencode/kimi-k2.5-free",
173
+ tools: { list: true, read: true, grep: true, bash: true }
174
+ }
175
+ ```
176
+
177
+ ### Context7 Integration
178
+
179
+ The plugin automatically detects libraries that benefit from Context7:
180
+
181
+ ```typescript
182
+ // Libraries triggering "use context7"
183
+ ["react", "django", "unity", "tensorflow", "docker", ...]
184
+ ```
185
+
186
+ ## πŸ”§ Development
187
+
188
+ ### Project Structure
189
+
190
+ ```
191
+ opencode-enhancer-plugin/
192
+ β”œβ”€β”€ src/
193
+ β”‚ └── index.ts # Source TypeScript
194
+ β”œβ”€β”€ dist/ # Compiled output (published to npm)
195
+ β”‚ β”œβ”€β”€ index.js
196
+ β”‚ └── index.d.ts
197
+ β”œβ”€β”€ package.json # Package metadata
198
+ β”œβ”€β”€ tsconfig.json # TypeScript config
199
+ └── README.md # This file
200
+ ```
201
+
202
+ ### Hooks
203
+
204
+ - **`config`** - Registers both agents on startup
205
+ - **`tool.execute.before`** - Logs explore-context calls
206
+ - **`message.updated`** - Appends Build mode hint to outputs
207
+
208
+ ## 🀝 Contributing
209
+
210
+ Contributions are welcome! Please feel free to submit a Pull Request.
211
+
212
+ ### Ideas for Contributions
213
+
214
+ - Add more tech stack detectors
215
+ - Improve Context7 heuristics
216
+ - Add support for additional intent types
217
+ - Enhance prompt templates
218
+
219
+ ## πŸ“„ License
220
+
221
+ MIT License - see [LICENSE](LICENSE) file for details.
222
+
223
+ ## πŸ™ Acknowledgments
224
+
225
+ - Built for [OpenCode](https://opencode.ai)
226
+ - Inspired by the need for better context-aware AI assistance
227
+ - Thanks to the OpenCode community for feedback and ideas
228
+
229
+ ---
230
+
231
+ <div align="center">
232
+
233
+ **[⬆ Back to Top](#-opencode-enhancer-plugin)**
234
+
235
+ Made with ❀️ for the OpenCode community
236
+
237
+ </div>
@@ -0,0 +1,4 @@
1
+ import type { Plugin } from "@opencode-ai/plugin";
2
+ export declare const EnhancerPlugin: Plugin;
3
+ export default EnhancerPlugin;
4
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAA;AAEjD,eAAO,MAAM,cAAc,EAAE,MA0E5B,CAAA;AAED,eAAe,cAAc,CAAA"}
package/dist/index.js ADDED
@@ -0,0 +1,70 @@
1
+ export const EnhancerPlugin = async ({ client }) => {
2
+ client.app.log({
3
+ service: "enhancer",
4
+ level: "info",
5
+ message: "Enhancer plugin initialized"
6
+ }).catch(() => { });
7
+ return {
8
+ config: async (input) => {
9
+ if (!input.agent) {
10
+ input.agent = {};
11
+ }
12
+ input.agent["explore-context"] = {
13
+ mode: "subagent",
14
+ hidden: true,
15
+ model: "opencode/kimi-k2.5-free",
16
+ prompt: `You are the UNIVERSAL CONTEXT DETECTIVE. Map the codebase and extract technical context.`,
17
+ tools: {
18
+ list: true,
19
+ read: true,
20
+ grep: true,
21
+ bash: true
22
+ }
23
+ };
24
+ input.agent.enhancer = {
25
+ mode: "primary",
26
+ model: "opencode/kimi-k2.5-free",
27
+ description: "Universal Technical Architect & Prompt Enhancer",
28
+ color: "#9C27B0",
29
+ steps: 15,
30
+ tools: {
31
+ task: true,
32
+ read: true,
33
+ bash: false,
34
+ edit: false,
35
+ write: false
36
+ },
37
+ prompt: `You are the CHIEF ARCHITECT (Enhancer). Translate user wishes into precise engineering specifications.`
38
+ };
39
+ },
40
+ "tool.execute.before": async (input, output) => {
41
+ if (input.tool === "task") {
42
+ const args = output.args;
43
+ if (args?.subagent_type === "explore-context") {
44
+ client.app.log({
45
+ service: "enhancer",
46
+ level: "debug",
47
+ message: "Calling explore-context subagent"
48
+ }).catch(() => { });
49
+ }
50
+ }
51
+ },
52
+ "message.updated": async (input, output) => {
53
+ if (input.session?.agent?.name !== "enhancer") {
54
+ return;
55
+ }
56
+ const content = input.message?.content || "";
57
+ if (content.includes("Build mode") || content.includes("Build Mode")) {
58
+ return;
59
+ }
60
+ if (content.includes("```markdown") || content.includes("# Task:")) {
61
+ const hint = "\n\n---\n**Next Step**: Copy this entire block and run it in **Build** mode to execute the plan.";
62
+ if (output && typeof output === "object") {
63
+ output.content = content + hint;
64
+ }
65
+ }
66
+ }
67
+ };
68
+ };
69
+ export default EnhancerPlugin;
70
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAEA,MAAM,CAAC,MAAM,cAAc,GAAW,KAAK,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE;IACzD,MAAM,CAAC,GAAG,CAAC,GAAG,CAAC;QACb,OAAO,EAAE,UAAU;QACnB,KAAK,EAAE,MAAM;QACb,OAAO,EAAE,6BAA6B;KACvC,CAAC,CAAC,KAAK,CAAC,GAAG,EAAE,GAAE,CAAC,CAAC,CAAA;IAElB,OAAO;QACL,MAAM,EAAE,KAAK,EAAE,KAAK,EAAE,EAAE;YACtB,IAAI,CAAC,KAAK,CAAC,KAAK,EAAE,CAAC;gBACjB,KAAK,CAAC,KAAK,GAAG,EAAE,CAAA;YAClB,CAAC;YAED,KAAK,CAAC,KAAK,CAAC,iBAAiB,CAAC,GAAG;gBAC/B,IAAI,EAAE,UAAU;gBAChB,MAAM,EAAE,IAAI;gBACZ,KAAK,EAAE,yBAAyB;gBAChC,MAAM,EAAE,0FAA0F;gBAClG,KAAK,EAAE;oBACL,IAAI,EAAE,IAAI;oBACV,IAAI,EAAE,IAAI;oBACV,IAAI,EAAE,IAAI;oBACV,IAAI,EAAE,IAAI;iBACX;aACF,CAAA;YAED,KAAK,CAAC,KAAK,CAAC,QAAQ,GAAG;gBACrB,IAAI,EAAE,SAAS;gBACf,KAAK,EAAE,yBAAyB;gBAChC,WAAW,EAAE,iDAAiD;gBAC9D,KAAK,EAAE,SAAS;gBAChB,KAAK,EAAE,EAAE;gBACT,KAAK,EAAE;oBACL,IAAI,EAAE,IAAI;oBACV,IAAI,EAAE,IAAI;oBACV,IAAI,EAAE,KAAK;oBACX,IAAI,EAAE,KAAK;oBACX,KAAK,EAAE,KAAK;iBACb;gBACD,MAAM,EAAE,wG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
2
+ "name": "opencode-enhancer-plugin",
3
+ "version": "1.0.0",
4
+ "description": "Universal Technical Architect & Prompt Enhancer for OpenCode",
5
+ "type": "module",
6
+ "main": "dist/index.js",
7
+ "types": "dist/index.d.ts",
8
+ "files": [
9
+ "dist"
10
+ ],
11
+ "scripts": {
12
+ "build": "tsc",
13
+ "clean": "rm -rf dist",
14
+ "prepublishOnly": "npm run build",
15
+ "typecheck": "tsc --noEmit"
16
+ },
17
+ "keywords": [
18
+ "opencode",
19
+ "plugin",
20
+ "enhancer",
21
+ "prompt",
22
+ "context",
23
+ "ai",
24
+ "agent",
25
+ "openai",
26
+ "anthropic",
27
+ "gemini"
28
+ ],
29
+ "author": "",
30
+ "license": "MIT",
31
+ "repository": {
32
+ "type": "git",
33
+ "url": "git+https://github.com/MaansenV/opencode-enhancer-plugin.git"
34
+ },
35
+ "bugs": {
36
+ "url": "https://github.com/MaansenV/opencode-enhancer-plugin/issues"
37
+ },
38
+ "homepage": "https://github.com/MaansenV/opencode-enhancer-plugin#readme",
39
+ "devDependencies": {
40
+ "@opencode-ai/plugin": "^1.1.39",
41
+ "typescript": "^5.9.3"
42
+ }
43
+ }