An OpenCode plugin that silently spell-checks your prompts using Harper before they reach the LLM. The model never knows spell checking happened; it just the fixed text.
The spell checking is quite aggressive. It can often make mistakes, but I haven't seen any way to make the decisions dynamic/user triggered.
Add the plugin path to your opencode.json:
{
"plugin": ["/path/to/opencode-harper/index.ts"]
}Or place index.ts directly in your global plugins directory (~/.config/opencode/plugins/) or project plugins directory (.opencode/plugins/).
- Intercepts user prompts via
chat.messagehook (when a new user message is created, before it's saved) - Skips messages from non-primary agents - only processes messages where
input.agentis"build"or"plan". Subagent messages ("explore","general", etc.) and internal agents ("compaction","title","summary") are ignored. - Filters to original user text only - skips parts marked
synthetic(system-injected content like file reads, tool output summaries) andignoredparts - Runs
harper-cli lint --format jsonon each user text part viaBun.spawn() - Applies all Harper corrections (spelling, grammar, style, typos)
- Shows a toast notification with changes made
Note: Only user's chat input is spell checked: model output is untouched.
Corrections are skipped inside:
- Fenced code blocks (
```...```) - Inline code (
`...`) - Double-quoted strings (
"...", including smart quotes) - Single-quoted strings (
'...', including smart quotes) — contractions likeit's,don'tare preserved via lookbehind/lookahead regex - File paths (absolute
/home/user/..., home-relative~/..., relative./...and../...) - Filenames with common extensions (
*.ts,*.py,*.json, etc.)
- OpenCode
- Harper CLI installed and available in
PATH
bun test.tsMIT