README.md

LUKI - Luki's Universal Kollection Interface #

A trait-driven generative collection IDE for ComfyUI.

LUKI helps you design, balance, render, and ship generative art collections. Define your categories, write a main prompt with __PLACEHOLDER__ tokens, add traits per category, mark rarity tiers, and let LUKI handle the math, the renders, and the metadata.

Features #

  • Trait-driven prompts with __CATEGORY__ placeholder substitution and dynamic syntax ({a|b|c}, weight expressions).
  • ComfyUI rendering pipeline with automatic workflow inspection — drop in any workflow JSON (editor or API format, subgraphs included) and LUKI detects the prompt input, save nodes, and seed nodes for you. A /wizard page lets you fix the mapping by hand if auto-detection misses anything.
  • Rarity math to balance supply across categories and traits.
  • Live state in the browser with autosave; user-added categories survive restarts.
  • No hardcoded paths or node IDs — everything is configurable via config.json.

Requirements #

  • Python 3.10+
  • A running ComfyUI instance (defaults to 127.0.0.1:8188)
  • A ComfyUI workflow exported as JSON (either editor format or API format)

Install #

git clone https://codeberg.org/karmicgrid/luki.git
cd luki
python3.10 -m venv .venv
source .venv/bin/activate
pip install -e ".[dev]"

Configure #

Copy the example config and edit it:

cp config.example.json config.json

Three things you must set:

  1. comfyui.workflow_path — path to your ComfyUI workflow JSON (use ComfyUI's "Save (API Format)" or just save the editor JSON; LUKI handles both).
  2. paths.comfy_image_output_dir — must point at ComfyUI's actual output directory (e.g. /home/you/ComfyUI/output). ComfyUI refuses to write outside this directory, and LUKI scans it to retrieve rendered images.
  3. collection.categories — list your trait categories. Each name becomes a __NAME__ placeholder you can reference in main_prompt.

For production, set LUKI_USERNAME and LUKI_PASSWORD environment variables instead of relying on the fallback credentials.

Run #

luki

Or, if you prefer not to install the entry point:

python -m luki

Then open http://localhost:8080 in your browser. Log in with the configured credentials (default user / changeme from the example config).

On first run, if workflow_mapping.json doesn't exist or its node IDs don't match your workflow, LUKI auto-detects the bindings. If detection fails or you want to override it, visit http://localhost:8080/wizard.

Usage flow #

  1. Master Prompt tab — write the template using __CATEGORY__ placeholders.
  2. Add traits per category. Each trait can carry its own modifiers that override the main prompt locally (__EXPRESSION__ etc.).
  3. Render previews from each trait row. Up to 3 sample renders per trait. Click ⬆️ to upload your own.
  4. Stats tab — set target supply, tune rarity tiers, and watch LUKI distribute counts.
  5. Builder tab — combine specific traits and render one-offs.
  6. Save — your work autosaves to data/saves/<timestamp>/state.json.

Project layout #

src/luki/
  config.py           # config loading + validation
  models.py           # pydantic models
  server.py           # FastAPI app + lifecycle
  __main__.py         # CLI entry point
  core/
    comfyui.py        # ComfyUI client + workflow injection
    prompt.py         # placeholder + dynamic syntax resolver
    state_manager.py  # save/load state
    workflow_inspector.py  # auto-detect node mapping; editor→API conversion
    images.py
  routes/             # FastAPI routers
  templates/          # Jinja2
  static/             # JS + CSS
tests/                # 80 passing tests
config.example.json
workflow_mapping.example.json

Development #

pip install -e ".[dev]"
ruff check src/ tests/
pytest

License #

MIT — see LICENSE.