feat: plugin-hook-example, reference plugin for transform_llm_output#1
Open
mvanhorn wants to merge 1 commit into
Open
feat: plugin-hook-example, reference plugin for transform_llm_output#1mvanhorn wants to merge 1 commit into
mvanhorn wants to merge 1 commit into
Conversation
…hook Adds a new reference plugin that fills the gap in the showcase: every existing plugin's plugin.yaml has hooks: [] and only registers a slash command. The lifecycle-hook surface is documented in the hermes-agent developer-guide but has no companion example. plugin-hook-example demonstrates the smallest production-shaped plugin code that uses the transform_llm_output hook: - declares `hooks: [transform_llm_output]` in plugin.yaml - redact.py: pure-function redaction for SSN (with SSA-invalid block filtering), Luhn-valid credit cards (13-19 digits), OpenAI/Anthropic keys, AWS access keys, and GitHub tokens. Patterns favour high precision so false positives stay rare in normal prose. - __init__.py: register(ctx) wires a single transform_llm_output hook that returns redacted text and emits one logger.info audit line per scan with kind counts (e.g. `redacted 2 span(s) from 1284-char output [openai_key=1, ssn=1]`). - README.md mirrors plugin-llm-example shape (what / why / how it works / try it / license). Stays under the README's ~200 LOC ceiling for plugin code (76 LOC in __init__.py, 108 in redact.py). Single-surface: one ctx.register_hook call, no commands or other registrations. No new dependencies. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
99fe6ee to
99f7397
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds a new reference plugin that fills the gap in the showcase: every
existing plugin's
plugin.yamlhashooks: []and only registers aslash command. The lifecycle-hook surface is documented in the
hermes-agent developer-guide but has no companion example here.
Demo
12 seconds: input text with SSN + API key ->
transform_llm_outputhook -> redacted output -> audit log entry.What it does
plugin-hook-exampledemonstrates the smallest production-shapedplugin code that uses
transform_llm_output:hooks: [transform_llm_output]inplugin.yamlredact.py: pure-function redaction for SSN (with SSA-invalidblock filtering), Luhn-valid credit cards, OpenAI/Anthropic keys,
AWS access keys, and GitHub tokens. Patterns favour high precision
so false positives stay rare in normal prose.
__init__.py:register(ctx)wires a singletransform_llm_outputhook that returns redacted text and emits one
logger.infoauditline per scan with kind counts.
README.mdmirrorsplugin-llm-exampleshape: what / why / how itworks / audit output / try it.
Stays inside the contribution rules
ctx.register_hookcall, no commands.ceiling. README + manifest add 132 lines on top.
resolution, Luhn check, conservative regexes.
Note on process
The README asks contributors to open an issue first when proposing a
new surface, in case the docs page should land first. I went straight
to PR for review feedback on the shape. Happy to close this and file
an issue instead if you'd rather discuss the surface there first, or
to wait until the
Plugin Hooksdocs page is ready and align theplugin to whatever final shape that page settles on.
Built with Claude Code (Opus 4.7).