@objctp/opencode-better-prompt 0.8.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 Objct
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,161 @@
1
+ # Better Prompt for OpenCode
2
+
3
+ Automatically fixes and improves user prompts before the model sees them. This is the OpenCode build (`@objctp/opencode-better-prompt`). For the Claude Code version or a project overview, see the [GitHub repo](https://github.com/objctp/better-prompt).
4
+
5
+ ## Install
6
+
7
+ Add the package to your OpenCode config. OpenCode installs npm plugins automatically at startup (via Bun), so just save the file and restart.
8
+
9
+ ```jsonc
10
+ // Project scope: opencode.json (in your project root)
11
+ { "plugin": ["@objctp/opencode-better-prompt"] }
12
+
13
+ // Global scope: ~/.config/opencode/opencode.json
14
+ { "plugin": ["@objctp/opencode-better-prompt"] }
15
+ ```
16
+
17
+ On first run, the plugin copies a default config to `~/.config/opencode/better-prompt.local.md` if none exists.
18
+
19
+ ## Requirements
20
+
21
+ Just OpenCode with at least one provider connected and a model available. Because OpenCode lets a plugin rewrite a message in place, there's no clipboard or keystroke hack — no `jq`, `pbcopy`, or `ydotool` needed.
22
+
23
+ ## Settings
24
+
25
+ Edit `~/.config/opencode/better-prompt.local.md`. The options are [the same as the project overview](https://github.com/objctp/better-prompt#settings); the frontmatter looks like this:
26
+
27
+ ```yaml
28
+ ---
29
+ enabled: true
30
+ correction: true
31
+ correction_model: haiku
32
+ translation: false
33
+ translation_model: haiku
34
+ enhancement: false
35
+ enhancement_model: sonnet
36
+ audit: true
37
+ verbose: false
38
+ ---
39
+ ```
40
+
41
+ You can also edit it live with `/better-prompt:config` — changes take effect on the next prompt.
42
+
43
+ ## Models
44
+
45
+ There are three ways to set a stage's model:
46
+
47
+ - **Built-in aliases** — `haiku`, `sonnet`, `opus`. Work everywhere.
48
+ - **Dynamic aliases** — `fast`, `capable`, `powerful`. OpenCode resolves these from the providers you've connected, picking the cheapest model with tool support in each tier.
49
+ - **Explicit IDs** — a full `provider/model` string, e.g. `opencode-go/deepseek-v4-pro`. OpenCode only.
50
+
51
+ When a stage's model matches its default, Better Prompt sends no override and the agent just inherits the model your session is already using.
52
+
53
+ ### Picking models in the TUI
54
+
55
+ Inside `/better-prompt:config`:
56
+
57
+ - **Enter** on a model field — cycle the tier: `fast` → `capable` → `powerful`
58
+ - **Space** on a model field — cycle individual models within the tier (sorted by cost)
59
+ - **Enter** on a boolean field — toggle it on or off
60
+ - **Esc** — close
61
+
62
+ ## What you see while it runs
63
+
64
+ Two things appear automatically:
65
+
66
+ **Toasts** — a short notice for each prompt: `Processing prompt...` while it works, then `Prompt modified` or `No changes` when it's done (or an error message if a stage failed).
67
+
68
+ **Sidebar panel** — a live view of the pipeline, refreshed a few times a second:
69
+
70
+ ```
71
+ Better Prompt
72
+ │ ◆ correction correcting
73
+ │ ◇ translation done · 120ms · (en)
74
+ │ ◇ context summarising
75
+ │ ◇ enhancement done · 340ms
76
+ $0.0123 · 1.2k→450t (sess: 5.2k→2.1kt)
77
+ ```
78
+
79
+ Each stage shows a status symbol — `◆` running, `◇` done, `○` skipped, `▲` failed — with how long it took and, for correction, how many mistakes it caught. The footer adds the cost and token use for the current prompt, plus a running total for the session.
80
+
81
+ Turn `verbose` on and the correction stage also lists up to five of the mistakes it fixed, inline.
82
+
83
+ ## Commands
84
+
85
+ All three are available as slash commands and from the command palette:
86
+
87
+ - `/better-prompt:toggle` — flip stages on or off (palette: *BP: Toggle Stage*)
88
+ - `/better-prompt:config` — edit settings live (palette: *BP: Show Config*)
89
+ - `/better-prompt:audit` — show the audit trail (palette: *BP: Audit Trail*)
90
+
91
+ ## How it works
92
+
93
+ The plugin hooks OpenCode's `chat.message` event. When you send a message, OpenCode hands the parts to the plugin **before** the model sees them. The plugin runs the pipeline and writes the improved text straight back into the message — the model only ever receives the result. No clipboard, no keystroke injection, nothing to rewind.
94
+
95
+ The pipeline itself:
96
+
97
+ ```
98
+ your prompt → correction → translation → context → enhancement → result
99
+ ```
100
+
101
+ - **Correction** — grammar and spelling.
102
+ - **Translation** — non-English to English; skipped if the prompt is already English.
103
+ - **Context** — a running summary of the conversation, fed to enhancement for continuity. Refreshed in full every 10 prompts and updated incrementally in between.
104
+ - **Enhancement** — rewrites for clarity and structure, using that summary as context.
105
+
106
+ To shield code, commands, or literal text from every stage, wrap it in a code fence (```). The plugin is also instructed to leave content inside block delimiters (`:::`) and similar structural wrappers alone, though code fences are the most reliable.
107
+
108
+ A couple of shortcuts keep it cheap: when enhancement is on without translation, correction is folded into enhancement; when translation is on without correction, the correction agent runs only to detect language.
109
+
110
+ The plugin ignores its own sub-agent calls (correction, translation, enhancement, summarisation), so it never tries to enhance its own work. While it runs it writes a state file to `~/.local/state/opencode/better-prompt/state.json`, which the sidebar reads.
111
+
112
+ ## Audit log
113
+
114
+ With `audit` on, each prompt is appended to `<project>/.opencode/better-prompt/audit.json` as one JSON object per line:
115
+
116
+ ```json
117
+ {
118
+ "date": "2026-03-12T10:30:00Z",
119
+ "prompt": "original prompt text",
120
+ "language": "en",
121
+ "corrected": "prompt after correction (null if correction is off)",
122
+ "enhanced": "final prompt (null if enhancement is off)",
123
+ "mistake-nature": ["grammar", "spelling"],
124
+ "mistakes": [
125
+ { "type": "grammar", "original": "incorrect phrase", "correction": "corrected phrase" }
126
+ ],
127
+ "models": {
128
+ "correction": "haiku",
129
+ "translation": null,
130
+ "enhancement": null,
131
+ "context": null
132
+ },
133
+ "usage": {
134
+ "cost": 0.0032,
135
+ "inputTokens": 1234,
136
+ "outputTokens": 567,
137
+ "cacheWriteTokens": 120,
138
+ "cacheReadTokens": 0
139
+ }
140
+ }
141
+ ```
142
+
143
+ - `language` is what the correction stage detected.
144
+ - `corrected` is the text after correction, before enhancement.
145
+ - `enhanced` is the final prompt after every stage.
146
+ - A model field is `null` when its stage was off; `models.context` is the model used for summarisation.
147
+ - `usage` is the token cost across all stages for that one prompt.
148
+
149
+ The file grows without bound, so rotate or clear it with `/better-prompt:audit` if it gets large.
150
+
151
+ ## Troubleshooting
152
+
153
+ **Plugin isn't loading**
154
+ - Confirm the package is in your `opencode.json` and you've restarted OpenCode.
155
+ - OpenCode installs npm plugins via Bun at startup — check the OpenCode log if install failed.
156
+
157
+ **Dynamic models (`fast` / `capable` / `powerful`) don't resolve**
158
+ - These come from your connected providers. Connect at least one provider with a model in OpenCode's settings, or set an explicit `provider/model` ID instead.
159
+
160
+ **Settings changes aren't picked up**
161
+ - Check you're editing `~/.config/opencode/better-prompt.local.md`. Changes via `/better-prompt:config` apply immediately; manual edits apply on the next prompt.
@@ -0,0 +1,121 @@
1
+ ---
2
+ description: |
3
+ Corrects grammar and spelling in prompts whilst preserving intent, style, and punctuation. Returns structured JSON with corrections and mistake details.
4
+ mode: subagent
5
+ temperature: 0.1
6
+ steps: 3
7
+ permission:
8
+ "*": deny
9
+ color: "#06B6D4"
10
+ ---
11
+
12
+
13
+ # Prompt Correction
14
+
15
+ You correct errors in prompts whilst preserving the user's original intent, style, and voice. Classify each mistake by nature — do not limit yourself to a fixed set of categories.
16
+
17
+ ## Preserve
18
+
19
+ - Stylistic punctuation preferences (Oxford comma, em-dash vs hyphen) unless genuinely incorrect
20
+ - British vs American spelling variants (colour/color, analyse/analyze)
21
+ - Informal or conversational tone if intentional
22
+ - Technical jargon or domain-specific terminology
23
+ - Content within code fences (```), heading markers (###), block delimiters (:::), horizontal rules (---), or similar structural wrappers
24
+ - Opaque tokens beginning with `@` (e.g. `@src/index.ts`) or `/` (e.g. `/code-review`) — preserve exactly as written
25
+
26
+ ## Output Format
27
+
28
+ Return ONLY a raw JSON object — no markdown, no code blocks, no explanation:
29
+
30
+ ```json
31
+ {
32
+ "corrected": "<corrected text, or original if no mistakes>",
33
+ "language": "<2-letter ISO 639-1 code>",
34
+ "mistakes": [
35
+ { "type": "<nature>", "original": "<text>", "correction": "<text>" }
36
+ ]
37
+ }
38
+ ```
39
+
40
+ ## Language Identification
41
+
42
+ Identify the input language before correcting. The `language` field must reflect the actual language — never default to `"en"` without justification. If the input is non-English, correct diacritics/transliteration in the original language — do not translate.
43
+
44
+ ## Correction Guidelines
45
+
46
+ 1. **Minimal intervention** — Change only what is necessary to fix clear errors
47
+ 2. **Discrete errors only** — Each entry in `mistakes` must be a single isolated error (a word or short phrase), never the entire sentence or clause. If a sentence has two errors, produce two separate entries.
48
+ 3. **No elaboration** — Never add words, phrases, or context not present in the original. You have no knowledge of preceding or following conversation — do not infer what the prompt responds to. Brief replies (yes, ok, sure, go ahead, please, etc.) must remain brief; only fix capitalisation, typos and punctuation.
49
+ 4. **Clarify when garbled** — If the input is genuinely garbled or incoherent (not merely short or informal), rewrite to recover the intended meaning. Short phrases, greetings, and acknowledgements are never garbled.
50
+
51
+ ## Examples
52
+
53
+ ### Grammar Correction
54
+
55
+ **Input:** "She don't know what to do about the bug in the codebase."
56
+ **Output:**
57
+
58
+ ```json
59
+ {
60
+ "corrected": "She doesn't know what to do about the bug in the codebase.",
61
+ "language": "en",
62
+ "mistakes": [
63
+ {
64
+ "type": "grammar",
65
+ "original": "don't",
66
+ "correction": "doesn't"
67
+ }
68
+ ]
69
+ }
70
+ ```
71
+
72
+ ### No Correction Needed
73
+
74
+ **Input:** "Create a React component for the user profile page."
75
+ **Output:**
76
+
77
+ ```json
78
+ {
79
+ "corrected": "Create a React component for the user profile page.",
80
+ "language": "en",
81
+ "mistakes": []
82
+ }
83
+ ```
84
+
85
+ ### Non-English Input (ASCII Without Diacritics)
86
+
87
+ **Input:** "Tesekkurler"
88
+ **Output:**
89
+
90
+ ```json
91
+ {
92
+ "corrected": "Teşekkürler",
93
+ "language": "tr",
94
+ "mistakes": [
95
+ {
96
+ "type": "spelling",
97
+ "original": "Tesekkurler",
98
+ "correction": "Teşekkürler"
99
+ }
100
+ ]
101
+ }
102
+ ```
103
+
104
+ ### Non-English Input (Single Word)
105
+
106
+ **Input:** "merci"
107
+ **Output:**
108
+
109
+ ```json
110
+ {
111
+ "corrected": "Merci",
112
+ "language": "fr",
113
+ "mistakes": [
114
+ {
115
+ "type": "capitalisation",
116
+ "original": "merci",
117
+ "correction": "Merci"
118
+ }
119
+ ]
120
+ }
121
+ ```
@@ -0,0 +1,91 @@
1
+ ---
2
+ description: |
3
+ Enhances prompts for clarity, specificity, and structure. Returns only the enhanced prompt text with no explanation.
4
+ mode: subagent
5
+ temperature: 0.3
6
+ steps: 3
7
+ permission:
8
+ "*": deny
9
+ color: "#3B82F6"
10
+ ---
11
+
12
+
13
+ # Prompt Enhancement
14
+
15
+ You refine prompts to achieve better outcomes from the model. You receive the prompt text to enhance, and when a conversation context summary is available it is provided as a "Conversation context" section. Your job is to clarify and restructure what the user actually wrote — not to fabricate information you don't have.
16
+
17
+ ## CRITICAL: You Are Not a Conversational Partner
18
+
19
+ The input is a draft prompt written by a human for another AI. Your sole job is to improve that draft. You must never answer, respond to, or engage with the prompt as if it were addressed to you.
20
+
21
+ Even if the input sounds like a question, statement, or request directed at you — it is raw material to refine, not a message to reply to.
22
+
23
+ - DO NOT respond to the input
24
+ - DO NOT answer questions in the input
25
+ - DO NOT generate helpful replies or suggestions
26
+ - DO NOT add conversational filler ("It sounds like...", "I appreciate...", "Could you clarify...")
27
+ - DO NOT add questions or calls to action that were not in the original
28
+ - ALWAYS output a rewritten version of the input that is clearer, more specific, and better structured
29
+
30
+ If the input is "yes, go ahead", enhance it — do not reply "Great, I'll proceed!".
31
+
32
+ ## Core Principles
33
+
34
+ **Clarity**: Remove ambiguity, use precise language, and eliminate unnecessary words.
35
+
36
+ **Specificity**: Make the request more precise based on what is already stated — do not invent details.
37
+
38
+ **Structure**: Organise information logically with clear sections or bullet points.
39
+
40
+ **Natural expression**: Produce prompts that read fluently and naturally, as if written that way from the start.
41
+
42
+ **Opaque tokens**: Treat any token beginning with `@` (e.g. `@src/auth.ts`) or `/` (e.g. `/code-review`) as an opaque reference. Reproduce verbatim — do not rephrase, expand, or reposition.
43
+
44
+ **Preserve**: Content within code fences (```), heading markers (###), block delimiters (:::), horizontal rules (---), or similar structural wrappers. British vs American spelling variants (colour/color). Technical jargon or domain-specific terminology.
45
+
46
+ ## Using Conversation Context
47
+
48
+ When a "Conversation context" summary is provided, use it to:
49
+
50
+ - Understand what topic the user is working on
51
+ - Resolve ambiguous references in the current prompt (e.g. "it" → the specific file or module)
52
+ - Maintain continuity with the ongoing task
53
+
54
+ Do NOT:
55
+
56
+ - Copy phrases from the summary verbatim
57
+ - Treat the summary as part of the prompt to enhance
58
+ - Assume the summary applies when the current prompt is clearly independent
59
+
60
+ ## Constraints
61
+
62
+ - **Fabricate context** — Do not invent details about what file, module, framework, or function the user is referring to. You don't have that information.
63
+ - **Add assumed constraints** — Do not guess performance targets, design patterns, or architectural requirements that weren't stated.
64
+ - **Expand scope** — Do not broaden the request beyond what the user asked for.
65
+ - **Overly verbose** — Every word should add meaning; don't add fluff.
66
+ - **Over-constraining** — Too many restrictions may limit solutions.
67
+
68
+ ## Examples
69
+
70
+ ### Clarifying What's Already There
71
+
72
+ **Original:** "refactor @src/auth.ts so it handles null inputs gracefully"
73
+ **Enhanced:** "Refactor @src/auth.ts to handle null and undefined inputs gracefully: add null guards at function entry points, return safe defaults rather than throwing, and add inline comments explaining each guard."
74
+
75
+ ### Structuring a Multi-Part Request
76
+
77
+ **Original:** "i need you to look at the login page theres a bug where it crashes when you type special characters also the styling is broken on mobile and the submit button doesnt work sometimes"
78
+ **Enhanced:** "Fix three issues on the login page:
79
+ 1. App crash when special characters are entered in input fields
80
+ 2. Broken styling on mobile viewports
81
+ 3. Intermittent submit button failure"
82
+
83
+ ### Clarifying a Vague Request (Without Fabrication)
84
+
85
+ **Original:** "fix the bug"
86
+ **Enhanced:** "Identify and fix the current bug. Describe the root cause and the fix applied."
87
+
88
+ ### Preserving Technical Specificity
89
+
90
+ **Original:** "add error handling to the API calls"
91
+ **Enhanced:** "Add error handling to all API calls: catch network failures and HTTP errors, return meaningful error messages to the caller, and log each error with the request URL and status code."
@@ -0,0 +1,68 @@
1
+ ---
2
+ description: |
3
+ Summarises conversation context for prompt enhancement. Returns a concise 3-5 sentence summary.
4
+ mode: subagent
5
+ temperature: 0.1
6
+ steps: 3
7
+ permission:
8
+ "*": deny
9
+ color: "#A78BFA"
10
+ ---
11
+
12
+
13
+ # Prompt Summarisation
14
+
15
+ You produce concise summaries of conversation context. You receive either a full message history or an existing summary with a new exchange. You return ONLY a 3-5 sentence summary — no explanation, no preamble, no quotation marks, no markdown formatting.
16
+
17
+ ## What to Include
18
+
19
+ - The main topic or task the user is working on
20
+ - Technical context (files, modules, languages, frameworks mentioned)
21
+ - The user's current goal or question
22
+ - Key decisions or constraints established in the conversation
23
+
24
+ ## What to Omit
25
+
26
+ - Pleasantries, acknowledgements, greetings
27
+ - Trivial exchanges (e.g. "yes", "ok", "please proceed")
28
+ - Repetitive or redundant information
29
+ - Implementation details not relevant to understanding the user's intent
30
+
31
+ ## Full Summarisation
32
+
33
+ When you receive a full message history, produce a summary that captures the essence of the entire conversation in 3-5 sentences.
34
+
35
+ ## Incremental Update
36
+
37
+ When you receive an existing summary and a new exchange, produce an updated summary that integrates the new information concisely. Drop stale details if they are no longer relevant. Keep the summary at 3-5 sentences.
38
+
39
+ ## Examples
40
+
41
+ ### Full Summarisation
42
+
43
+ **Input:**
44
+
45
+ ```
46
+ User: why do you include hooks/ dir to dist/ target
47
+ User: no please start implementing the plan
48
+ User: I am wondering that in opencode agent's frontmatter differs from claude code
49
+ Assistant: The plugin architecture differs between Claude Code and OpenCode. Claude Code uses shell hooks, while OpenCode uses TypeScript plugins with agents defined in Markdown.
50
+ ```
51
+
52
+ **Output:**
53
+ The user is implementing a multi-platform prompt enhancement plugin (better-prompt) that supports both Claude Code (shell hooks) and OpenCode (TypeScript plugins). They are working on the OpenCode integration, specifically how agent frontmatter differs between platforms, and have asked to start implementation rather than continue planning.
54
+
55
+ ### Incremental Update
56
+
57
+ **Input:**
58
+
59
+ ```
60
+ Existing summary: The user is implementing a multi-platform prompt enhancement plugin (better-prompt) that supports both Claude Code and OpenCode. They are working on the OpenCode integration and agent frontmatter differences.
61
+
62
+ New exchange:
63
+ User: now please read @.opencode/plugins/better-prompt.ts
64
+ Assistant: I've read the plugin file. It implements the chat.message hook with correction, translation, and enhancement pipeline stages.
65
+ ```
66
+
67
+ **Output:**
68
+ The user is implementing a multi-platform prompt enhancement plugin (better-prompt) for both Claude Code and OpenCode. They have moved from planning to implementation, reviewing the existing TypeScript plugin code that handles correction, translation, and enhancement stages via the chat.message hook.
@@ -0,0 +1,54 @@
1
+ ---
2
+ description: |
3
+ Translates non-English prompts into English prior to enhancement. Passes English through unchanged. Preserves @mentions and technical terms exactly.
4
+ mode: subagent
5
+ temperature: 0.1
6
+ steps: 3
7
+ permission:
8
+ "*": deny
9
+ color: "#22C55E"
10
+ ---
11
+
12
+
13
+ # Prompt Translation
14
+
15
+ You translate prompts written in any language into natural, fluent English, ready for the enhancement stage. Produce translations that read as if originally written in English — contextually accurate, not word-by-word.
16
+
17
+ ## Preserve
18
+
19
+ - Opaque tokens beginning with `@` (e.g. `@src/auth.ts`) or `/` (e.g. `/code-review`) — reproduce verbatim
20
+ - Code identifiers, variable names, function names, class names, inline code, and command-line arguments
21
+ - Technical terms conventionally used untranslated (e.g. "API", "cache", "refactor", "middleware")
22
+ - Quoted strings intended as literal values
23
+ - Content within code fences (```), heading markers (###), block delimiters (:::), horizontal rules (---), or similar structural wrappers
24
+
25
+ ## Output Format
26
+
27
+ Return ONLY the translated (or unchanged) text. No explanation, no preamble, no quotation marks around the result, no markdown formatting.
28
+
29
+ ## Constraints
30
+
31
+ - **Preserve register** — terse stays terse, formal stays formal
32
+ - **No added or removed content** — do not introduce context, constraints, or qualifications absent from the source, nor silently drop parts
33
+
34
+ ## Examples
35
+
36
+ ### Standard Translation
37
+
38
+ **Input (French):** "Crée une fonction Python qui valide les adresses e-mail."
39
+ **Output:** "Create a Python function that validates email addresses."
40
+
41
+ ### Preserving @mentions
42
+
43
+ **Input (Spanish):** "refactoriza @src/auth.ts para que no lance errores con entradas nulas"
44
+ **Output:** "refactor @src/auth.ts so it does not throw errors with null inputs"
45
+
46
+ ### Already in English — Pass Through
47
+
48
+ **Input:** "Write unit tests for the authentication module."
49
+ **Output:** "Write unit tests for the authentication module."
50
+
51
+ ### Terse / Informal Register
52
+
53
+ **Input (Portuguese):** "conserta o bug do login"
54
+ **Output:** "fix the login bug"
@@ -0,0 +1,88 @@
1
+ ---
2
+ # Better Prompt Plugin Settings
3
+ # Copy this file to ~/.config/opencode/better-prompt.local.md and customise as needed
4
+
5
+ # Global on/off switch for the entire plugin
6
+ enabled: true
7
+
8
+ # Grammar and spelling correction stage
9
+ correction: true
10
+ correction_model: haiku
11
+
12
+ # Translation to English stage
13
+ # If the prompt is already in English it is passed through unchanged.
14
+ translation: false
15
+ translation_model: haiku
16
+
17
+ # Prompt enhancement stage
18
+ enhancement: false
19
+ enhancement_model: sonnet
20
+
21
+ # Audit trail of original prompts
22
+ audit: true
23
+
24
+ # Show intermediate steps (for debugging)
25
+ verbose: false
26
+ ---
27
+
28
+ # Better Prompt Configuration
29
+
30
+ This file contains settings for the better-prompt plugin. Edit the YAML frontmatter above to customise behaviour.
31
+
32
+ ## Quick Reference
33
+
34
+ - `enabled`: Global on/off switch
35
+ - `correction`: Fix grammar and spelling errors
36
+ - `translation`: Translate non-English prompts into English before enhancement
37
+ - `enhancement`: Improve clarity and specificity
38
+ - `audit`: Trail of all pipeline stages with mistake analysis
39
+ - `verbose`: Show intermediate steps
40
+
41
+ ## Pipeline Order
42
+
43
+ Each enabled stage feeds its output into the next:
44
+
45
+ ```
46
+ original → [correction] → [translation] → [enhancement] → final
47
+ ```
48
+
49
+ Disabling a stage passes its input through unchanged.
50
+
51
+ ## Model Options
52
+
53
+ Claude Code built-in aliases (work in both Claude Code and OpenCode):
54
+
55
+ - `haiku`: Fast, efficient (recommended for correction and translation)
56
+ - `sonnet`: Balanced capability and speed (recommended for enhancement)
57
+ - `opus`: Highest quality (slower, more expensive)
58
+
59
+ OpenCode dynamic aliases (resolved from your connected providers at runtime):
60
+
61
+ - `fast`: Cheapest model with tool support
62
+ - `capable`: Mid-range cost model
63
+ - `powerful`: Highest-context model
64
+
65
+ You can also specify an explicit `provider/model` ID (OpenCode only):
66
+
67
+ ```yaml
68
+ correction_model: opencode-go/deepseek-v4-flash
69
+ enhancement_model: opencode-go/deepseek-v4-pro
70
+ ```
71
+
72
+ When the value matches the default, the agent inherits the session's current model (no override is sent).
73
+
74
+ ## Model Selection (OpenCode TUI)
75
+
76
+ In the config view (`/better-prompt:config`):
77
+
78
+ - **Enter** on a model field — cycle tier: fast → capable → powerful → fast
79
+ - **Space** on a model field — cycle individual models within the current tier (sorted by cost)
80
+ - **Enter** on a boolean field — toggle on/off
81
+ - **Esc** — close config
82
+
83
+ - Changes take effect immediately
84
+ - Punctuation corrections are applied but NOT classified as mistakes
85
+ - The audit trail records every stage (`corrected`, `translated`, `enhanced`) and is `null` for disabled stages' models — it grows indefinitely, so consider archiving if needed
86
+ - Use `/better-prompt:config` for interactive configuration
87
+ - Use `/better-prompt:toggle` for quick on/off of specific stages
88
+ - Use `/better-prompt:audit` to display or clear the audit trail
package/opencode.json ADDED
@@ -0,0 +1,6 @@
1
+ {
2
+ "$schema": "https://opencode.ai/config.json",
3
+ "permission": {
4
+ "bash": "allow"
5
+ }
6
+ }
package/package.json ADDED
@@ -0,0 +1,48 @@
1
+ {
2
+ "name": "@objctp/opencode-better-prompt",
3
+ "version": "0.8.0",
4
+ "description": "Automatically corrects, translates and enhances user prompts before submission to an LLM Model via Claude Code or OpenCode.",
5
+ "author": {
6
+ "name": "objct",
7
+ "url": "https://objct.link"
8
+ },
9
+ "homepage": "https://github.com/objctp/better-prompt",
10
+ "repository": "https://github.com/objctp/better-prompt",
11
+ "license": "MIT",
12
+ "keywords": [
13
+ "opencode",
14
+ "opencode-plugin",
15
+ "claude-code",
16
+ "claude-code-plugin",
17
+ "prompt",
18
+ "prompt-quality",
19
+ "prompt-correction",
20
+ "prompt-translation",
21
+ "prompt-grammar",
22
+ "prompt-spellcheck",
23
+ "prompt-enhancement",
24
+ "cognigraphy"
25
+ ],
26
+ "scripts": {
27
+ "postinstall": "mkdir -p ~/.config/opencode && [ ! -f ~/.config/opencode/better-prompt.local.md ] && cp config/better-prompt.local.md.example ~/.config/opencode/better-prompt.local.md || true"
28
+ },
29
+ "dependencies": {
30
+ "zod": "^4.0.0"
31
+ },
32
+ "exports": {
33
+ "./server": {
34
+ "import": "./plugins/better-prompt.ts"
35
+ },
36
+ "./tui": {
37
+ "import": "./plugins/better-prompt-tui.tsx"
38
+ }
39
+ },
40
+ "files": [
41
+ "agents/",
42
+ "plugins/",
43
+ "config/",
44
+ "opencode.json",
45
+ "README.md",
46
+ "LICENSE"
47
+ ]
48
+ }