tack de394c3f26 feat(script-loader): add auto mode, file dropdown, quote-stripping
UX fixes driven by cross-machine testing feedback:

- mode="auto" (new default) picks the filled input automatically, so users
  no longer get "mode=file requires json_file" when they filled json_path
  without switching the mode dropdown.
- json_file now renders as a dropdown of .json files under ComfyUI's
  input/ directory (falls back to plain STRING if folder_paths or the
  directory is unavailable).
- Surrounding quotes on json_path/json_file are stripped automatically —
  Windows "Copy as Path" pastes quoted strings and that used to surface
  as an opaque "file not found".
- Clearer errors for "no input" / "multiple inputs" in auto mode, and a
  hint on path-not-found pointing at the quote issue.

Tests: 117 -> 121 (4 new auto-mode cases).
2026-04-23 16:57:39 +08:00

tk_comfyui_batch_image

ComfyUI custom node set for batch comic-page generation from an AI-authored JSON script.

Write a natural-language screenplay → an AI (acting as a manga panel composition expert) turns it into a JSON → this node runs every panel through your ComfyUI model/CLIP/VAE and composes the pages.


Install

Clone this repo into ComfyUI/custom_nodes/:

cd ComfyUI/custom_nodes
git clone https://github.com/tackcrypto1031/tk_comfyui_comic_tool.git
cd tk_comfyui_comic_tool
pip install Pillow jsonschema numpy

Restart ComfyUI. Four nodes appear under the comic/ category.

Nodes

Node Category Purpose
Comic Script Loader comic/io Load + validate JSON (Layer 1 schema + Layer 2 semantic); emits COMIC_SCRIPT. Modes: file / path / inline.
Comic Sampler Override comic/util Optional. Plug between loader and generator to temporarily override cfg / steps / sampler from node widgets without editing the JSON. Leave all widgets at sentinel ((keep) / 0 / 0.0 / -1.0) for passthrough.
Comic Batch Generator comic/core Inner for-loop. Connect MODEL / CLIP / VAE; no external KSampler needed. Panel-hash cache → modifying one panel's prompt only re-runs that panel on next queue. Retry + skip policy configurable.
Comic Page Composer comic/io Assemble panels into full pages. Outputs composed IMAGE batch + bbox metadata (JSON) + pass-through panels.

AI skill pack

The docs/skills/comic-script-authoring/ folder is a ready-to-use delivery for three audiences:

Audience Entry point
Claude Code + superpowers users copy SKILL.md into your skills dir; invoke via /skill comic-script-authoring
Generic LLM (ChatGPT / Gemini / Claude API / …) paste PROMPT_TEMPLATE.md into the system prompt
Humans reading about the tool read README.md in that folder

The schema.json is generated from tk_comfyui_batch_image/core/schema.py (single source of truth) and is referenced by all three audiences instead of duplicating field tables.

The examples/ subdirectory has 5 screenplay.md + output.json pairs covering minimal, multi-panel with align, per-panel sampler_override, rtl reading direction, and 4-layer prompt composition.

Standalone validator CLI

The AI (or you) can self-check a JSON without running ComfyUI:

python -m tk_comfyui_batch_image.validate my_script.json
python -m tk_comfyui_batch_image.validate my_script.json --json      # machine-readable
python -m tk_comfyui_batch_image.validate examples/*.json --max-errors 5

Exit codes: 0 all pass · 1 validation failed · 2 CLI usage error · 3 I/O error.

Example workflow

  1. Write a screenplay (Markdown or plain text).
  2. Give it to your AI along with docs/skills/comic-script-authoring/SKILL.md (or PROMPT_TEMPLATE.md).
  3. AI outputs a JSON and (if it can run shells) self-validates via the CLI.
  4. Drop the JSON into a ComfyUI workflow: ComicScriptLoader → (optional ComicSamplerOverride) → ComicBatchGenerator → ComicPageComposer.
  5. Queue.

A starter ComfyUI workflow lives at tk_comfyui_batch_image/examples/workflows/m1_basic_vertical_stack.json. Drop it into the ComfyUI canvas.

Put the JSON script at ComfyUI/input/comics/your_script.json and set ComicScriptLoader to file mode.

Running tests

pytest tk_comfyui_batch_image/tests/ -q           # 117 tests
ruff check tk_comfyui_batch_image

Current capabilities

  • Rectangle panels (shape.type="rect")
  • Vertical-stack layout (layout_mode="vertical_stack")
  • 4-layer prompt composition (style + character + page + scene) + per-panel sampler_override
  • Reading direction ltr / rtl
  • Panel-hash cache + resume
  • retry_then_skip / halt failure policies (placeholder PNG + manifest persisted on skip)
  • Layer 1 + Layer 2 JSON validation (schema + semantic rules: index continuity, layout fit, dimensional consistency)
  • AI skill pack with default canvas (1080 × 1920) and panel-size guidance table

Not yet supported

  • Diagonal split panels (shape.type="split" + sister-panel coline) — planned for M3
  • Arbitrary polygon panels (shape.type="polygon") — M4
  • Webtoon long-page + per-page size + debug overlay + streaming decode — M5

License

MIT.

S
Description
No description provided
Readme
180 KiB
Languages
Python 100%