Repository navigation
feat: image-generate skill for Claude Code, pi and Hermes - #152
Merged
Merged
Conversation
A stdlib agent tool: it sends one FLUX.2 klein text-to-image job to ComfyUI through comfy.grehg2.xyz, saves the PNG and prints the prompt, seed and a MEDIA: line, so a follow-up can reuse the seed and Hermes can attach the file. Inside Hermes it saves to /opt/data/cache/images, the only place Hermes' strict media check accepts. A sleeping moria, an unreachable server and a failed render each say so plainly.
The skill makes the calling agent write the detailed prompt, since it is the one that sees the conversation, and makes follow-ups edit the last prompt and keep its seed, so "make them zebras" changes only that. It says how each harness delivers the image: Hermes attaches the MEDIA: line, Claude Code reads the PNG, pi gives the path.
From review: only the submit was guarded, so a 502 or timeout while polling, a non-JSON page and a render with no image all ended in a traceback a bot would relay. Every request now goes through one function that fails with a sentence, the timeout can be set for tests, and fail() is NoReturn.
From review: the examples double-quoted the prompt while the skill double-quotes words to render, so a model following both splits the shell command. Prompts are now single-quoted with no apostrophes. The reply starts with the prompt and seed, so a follow-up finds them in the conversation even after Hermes compresses the tool output, and the example now meets the 40-word minimum it sets.
Hermes' terminal tool stops a command after 300 s; polling for 300 s could outlast it, so the user saw a killed tool instead of this script's own explanation. A normal image takes 15-25 s.
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.
What
An image-generation tool every agent can use, on top of ComfyUI on moria (#151).
bin/comfy-image.py: a stdlib agent tool. It sends one FLUX.2 klein text-to-image job tohttps://comfy.grehg2.xyz, saves the PNG, and prints the prompt, the seed and aMEDIA:line.--seedkeeps a composition across edits, and--width/--heightset the shape. Inside Hermes it saves to/opt/data/cache/images, the only place Hermes' strict media check accepts; elsewhere it uses~/Pictures/comfy.skills/image-generate: tells the calling agent to write the detailed prompt itself, because it is the one that sees the conversation. Follow-ups ("make them zebras") edit the last prompt and keep its seed. It also says how each harness delivers the image: Hermes ends its reply with theMEDIA:line, Claude Code reads the PNG, pi gives the path.CLAUDE.mdpoints at it.Hermes' grant and the Slack upload are in https://github.com/GregHilston/home-lab/pull/123.
Testing
tests/test_comfy_image.pyruns against a fake ComfyUI API: the image is saved and the prompt and seed are printed; size reaches the workflow and bad sizes are refused; a sleeping moria (on submit or mid-render), an unreachable server, a non-JSON page, a render with no image, a timeout and a failed render each give a plain error, not a traceback;COMFY_IMAGE_DIRdecides where it saves.test_skillspasses; ruff is clean.comfy.grehg2.xyz: a watercolor of bison playing basketball in 22 s, then the same seed with "zebras" kept the composition.uvshebang works, the image lands in/opt/data/cache/images, and Hermes' ownvalidate_media_delivery_pathaccepts it.Deploy order
This must be merged and pulled on dungeon before https://github.com/GregHilston/home-lab/pull/123: its skill mount uses
create_host_path: false, so Hermes refuses to start ifskills/image-generateis missing.A subagent reviewed this PR. Its should-fixes (shell quoting in the skill, tracebacks on every request but the first, the seed missing from the reply) are fixed in the last three commits, and the tool now gives up at 240 s, inside Hermes' 300 s terminal limit.