Skip to content

feat: image-generate skill for Claude Code, pi and Hermes - #152

Merged
GregHilston merged 6 commits into
mainfrom
feat/image-generate-skill
Oct 11, 2026
Merged

GregHilston merged 6 commits into
mainfrom
feat/image-generate-skill

Conversation

@GregHilston

@GregHilston GregHilston commented Oct 11, 2026 •

Copy link
Copy Markdown
Owner

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 to https://comfy.grehg2.xyz, saves the PNG, and prints the prompt, the seed and a MEDIA: line. --seed keeps a composition across edits, and --width/--height set 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 the MEDIA: line, Claude Code reads the PNG, pi gives the path.
  • Root CLAUDE.md points at it.

Hermes' grant and the Slack upload are in https://github.com/GregHilston/home-lab/pull/123.

Testing

  • tests/test_comfy_image.py runs 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_DIR decides where it saves. test_skills passes; ruff is clean.
  • Live against comfy.grehg2.xyz: a watercolor of bison playing basketball in 22 s, then the same seed with "zebras" kept the composition.
  • Inside the running Hermes container: the uv shebang works, the image lands in /opt/data/cache/images, and Hermes' own validate_media_delivery_path accepts 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 if skills/image-generate is 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.

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.
@GregHilston
GregHilston merged commit f721bd9 into main Oct 11, 2026
1 check passed
@GregHilston
GregHilston deleted the feat/image-generate-skill branch October 11, 2026 19:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant