aifmt
Make visual text content just work.
An MCP server + Copilot CLI plugin that fixes, validates, and generates visual text content β boxes, tables, bars, tree diagrams β for AI coding assistants.
The Problem
LLMs generate text token-by-token with no concept of column alignment. len("π¦") returns 1, but the character renders wider on screen. This causes every AI-generated box, table, and tree diagram to be misaligned.
Before (LLM output β borders donβt line up):
ββββββββββββββββββββββ
β Status: deployed β
β Tests: 142 passing β
β Coverage: 98.5% β
ββββββββββββββββββββββ
After fix(content, mode="boxes"):
ββββββββββββββββββββββ
β Status: deployed β
β Tests: 142 passing β
β Coverage: 98.5% β
ββββββββββββββββββββββ
aifmt replaces len() with rendering-profile-aware visual width measurement so alignment is always correct.
Key Discovery: GitHub Emoji = 2.5 Columns
Through empirical testing, we discovered that GitHub renders emoji at 2.5 monospace columns β not the 2.0 that Unicode specifies and terminals use.
| Platform | Emoji width | CJK width |
|---|---|---|
| Terminal emulators | 2.0 cols | 2.0 cols |
| GitHub markdown | 2.5 cols | 2.0 cols |
This has a critical consequence:
- Even emoji count per line (0, 2, 4β¦) β integer total β β perfect alignment
- Odd emoji count per line (1, 3, 5β¦) β fractional total β β impossible to align
aifmt detects this and emits β warnings instead of silently producing broken output.
Read the full discovery story β
MCP Tools
| Tool | Description |
|---|---|
fix |
Repair misaligned boxes, tables, bars, and tree diagrams |
validate |
Check for alignment issues without modifying |
generate |
Create diagrams via Mermaid or PlantUML |
targets |
List rendering profiles (GitHub, terminal, custom) |
Quick Links
- Getting Started β Install and configure
- Tools Reference β Detailed tool documentation with examples
- The 2.5 Discovery β How we found the fractional emoji width
- Python API β Use the library directly
- Contributing β Development setup and guidelines