Hermes Agent plugin: replace em dashes with appropriate punctuation using structural heuristics
Find a file
BarnacleBoy fa01b7a6f0 fix: register transform_llm_output hook as fallback
Adds a real hook registration so em dashes are caught even when the
barnacleboy-output wrapper plugin fails to load or import this module.
The barnacleboy-output plugin is still the PRIMARY transform owner -
it chains em-dash-sub + spongebob-vocab + safety-net. This registration
is a fallback that fires independently.

Both hooks run on every turn. The turn_finalizer uses the first non-None
result, so barnacleboy-output's chained transform wins when healthy.
2026-09-14 15:34:41 +00:00
.gitignore chore: add .gitignore, remove __pycache__ from tracking 2026-08-10 14:11:18 +00:00
__init__.py fix: register transform_llm_output hook as fallback 2026-09-14 15:34:41 +00:00
plugin.yaml Initial commit: em-dash-sub Hermes plugin 2026-08-10 14:10:47 +00:00
README.md docs: add debugging instructions and multiple plugin coexistence docs 2026-08-26 15:25:03 +00:00
test_integration.py feat: add comma substitution, paired dash detection, and conjunction handling 2026-08-25 12:56:36 +00:00
test_new_features.py feat: add comma substitution, paired dash detection, and conjunction handling 2026-08-25 12:56:36 +00:00
test_plugin.py feat: add comma substitution, paired dash detection, and conjunction handling 2026-08-25 12:56:36 +00:00

Em Dash Sub

A Hermes Agent plugin that replaces em dashes () with typographically appropriate punctuation.

Uses the transform_llm_output hook — zero inference tokens, pure regex post-processing.

How it works

Three-pass substitution:

  1. Paired em dashes — Detects — text — patterns and wraps them:
    • Non-restrictive clauses (starting with which, who, that, where, when) → , commas,
    • Removable asides and appositives → (parentheses)
  2. Single em dashes — Heuristic substitution based on the word that follows:
    • Coordinating conjunction (but, yet, so, nor) → ,
    • Weak starter (that, which, who, whom, whose, where, when) → ,
    • Contrasting clause (pronoun or auxiliary verb follows) → ;
    • Explanation (article, preposition, or infinitive follows) → :
    • Everything else → : (safe default)
  3. Whitespace hygiene — Cleans up double spaces, leading punctuation, and spacing around parens.

Code blocks, inline code, URLs, and file paths are preserved.

Installation

git clone https://git.jezzahehn.com/KrustyPlanet/em-dash-sub.git ~/.hermes/plugins/em-dash-sub
hermes plugins enable em-dash-sub

Requires a /reset or gateway restart.

Configuration

Env var Effect
EM_DASH_SUB_DISABLED=1 Disable the plugin
EM_DASH_PREFER_SEMICOLON=1 Use semicolons for all single em dashes (skip heuristic)

Debugging

The plugin logs at INFO level when it fires:

  • em-dash-sub: no em dash found in text — text has no em dashes, passes through
  • em-dash-sub: transforming N chars with em dashes — em dashes found and replaced

Check logs with:

grep "em-dash-sub" ~/.hermes/logs/agent.log

Stale .pyc files: If the plugin stops working after a code change, the gateway process may be holding a stale .pyc in memory. Restart the gateway:

sudo systemctl restart hermes-gateway

Multiple Plugin Coexistence

The transform_llm_output hook uses a "first non-empty string wins" approach. Multiple plugins can register for the same hook; the first callback to return a non-None string is used as the final response.

This plugin is registered before spongebob-vocab, so it takes priority when em dashes are detected. When no em dashes are present, it returns None and the next plugin's output is used.

Examples

Before After
The key insight — it's all about scale. The key insight: it's all about scale.
My mentor — a seasoned developer — disagreed. My mentor (a seasoned developer) disagreed.
The system — which handles 10K requests — crashed. The system, which handles 10K requests, crashed.
I thought it was working — it wasn't. I thought it was working; it wasn't.
Three things — speed, cost, reliability. Three things: speed, cost, reliability.
It was hard — but we did it. It was hard, but we did it.
The theory — that morality is pluralistic — is influential. The theory, that morality is pluralistic, is influential.

License

MIT