OpenCode plugin that replaces Unicode characters in AI output with plain ASCII equivalents.
AI models frequently generate text with curly/smart quotes, em dashes, en dashes, ellipsis, arrow symbols, and invisible characters (zero-width spaces, joins, BOM). I prefer to replace these in my code, which is the purpose of this plugin.
- Replaces smart quotes -> straight quotes
- Replaces em dashes ->
-, en dashes ->- - Replaces arrows (right arrow ->
->, double right arrow ->=>, etc.) - Strips invisible characters (zero-width, BOM, soft hyphens)
- Normalizes double spaces
- Hooks into AI response text and file writes (Write/Edit tools)
- Configurable replacements - customize via
opencode.json
npx opencode-replace-textThen add to your opencode.json:
{
"plugin": ["opencode-replace-text"]
}Copy src/index.ts to your OpenCode plugins directory:
# Project-local
mkdir -p .opencode/plugins
cp src/index.ts .opencode/plugins/replace-text.ts
# Or global
cp src/index.ts ~/.config/opencode/plugins/replace-text.tsThen register in opencode.json:
Restart OpenCode after installing.
Coming soon - configure which replacements to apply and add your own via opencode.json.
{ // Project-local: "plugin": ["./plugins/replace-text.ts"], // Global: // "plugin": ["./plugins/replace-text.ts"] }