Skip to content

Buster210/opencode-fmt

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

38 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

OpenCode FMT

Bun Version License: MIT GitHub Repository

A unified text optimization plugin for OpenCode that sanitizes emojis and formats markdown tables. Built for high-performance pipelines where minimal latency is a requirement.


Features

  • Deterministic Emoji Sanitizer: Removes emojis from AI outputs without altering the surrounding whitespace or layout.
  • Isolated Table Aligner: Formats Markdown tables by calculating maximum column widths and applying deterministic padding, ensuring visual correctness.
  • Low-Latency Engine: Processes AI output efficiently without a full AST-based parser, maintaining near-linear time processing.
  • Concealment-Aware Widths: Intelligently calculates table widths by accounting for markdown markers like bold, italics, bold, or italics which are hidden in many views.
  • Flat Configuration: Simple, flat boolean configuration file with nested-object validation.

Quick Start

Add the plugin name to your OpenCode config file plugins section in ~/.config/opencode/config.json:

{
  "plugins": [
    "opencode-fmt"
  ]
}

Plugin Configuration

The plugin automatically initializes a default configuration at ~/.config/opencode/fmt/config.json on its first run if it doesn't already exist.

{
  "stripEmojis": true,
  "alignTables": true,
  "concealmentAware": true,
  "logging": false
}

Note

All configuration keys are booleans. Top-level arrays and unknown keys in config.json are accepted for forward compatibility, but current core behavior only uses the documented keys below. Nested objects are strictly prohibited.

Key Default Description
stripEmojis true Removes all emojis from the output.
alignTables true Dynamically aligns Markdown tables for visual consistency.
concealmentAware true Accounts for hidden markdown markers (e.g. **, _) in column widths.
logging false Enables duration and raw/clean output logging to opencode-fmt.log.

Examples

Emoji Sanitization

The sanitizer removes pictographic and dingbat symbols from the text stream.

Before: Hello [hand-wave], our launch [rocket] was a success [party]!
After: Hello , our launch was a success !

(Note: Surrounding whitespaces are strictly preserved for deterministic layout stability, which may result in double spaces where an emoji was removed).

Note

If a response contains only emojis (and optional whitespace characters), opencode-fmt will replace it with a redaction placeholder:
[Only emojis received and redacted by opencode-fmt]

Table Alignment

The aligner intelligently pads columns based on the longest cell in each column.

Before:

| Header 1 | H2 |
|---|---|
| Val | Long Value |

After:

| Header 1 | H2         |
| -------- | ---------- |
| Val      | Long Value |

Architectural Constraints

This plugin is governed by strict technical rules to preserve its performance:

  1. AST-Free Processing: No heavyweight parsing into an Abstract Syntax Tree.
  2. Zero Runtime Dependencies: Built purely on native Bun/Node APIs and the core plugin hook.
  3. Flat Config: No nested objects are allowed in config.json to prevent parsing overhead. The configuration is stored in ~/.config/opencode/fmt/config.json. Top-level arrays are permitted for list-based features. Any unknown keys are merged but ignored by core logic.
  4. Diff Stability: Non-target text (pure paragraphs) is preserved byte-for-byte in the output.

Inspiration

This plugin was inspired by two community plugins that pioneered single-feature plugin design:

Both showed that focused, lightweight plugins can solve specific pain points elegantly. This plugin follows the same philosophy: one concern, done well.


License

This project is licensed under the MIT License. See the LICENSE file for details.

© 2026 Ritesh Kumar Pal

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors