Nodes/comfyui-adaptiveprompts/📦 Prompt Repack 📦
ComfyUI Node

📦 Prompt Repack 📦

Turn a hand-written prompt back into wildcards

By Alectriciti·Created 12 months ago·Updated 23 days ago· 87
📦 Prompt Repack 📦
  • context
  • repacked_prompt
  • generated_prompt
  • context
string
detection_prioritytrue
matching_modeflexible
index_bracketsfalse
chance1.00
seed0
blacklist_fileblacklist.txt
refresh_cachefalse
categorywildcards

This is the strangest node in the pack, and the author flags it as experimental in the README. PromptRepack runs prompt generation in reverse: instead of expanding __wildcards__ into words, it scans plain natural-language or tag text and wraps matched words or phrases back into whichever wildcard file they belong to. Write a normal prompt, get a re-randomizable template back - genuinely useful for turning a one-off prompt you liked into something you can keep re-rolling, or for discovering what else lives in a word's category. The README's own example: "chicken" can belong to both an __animal__ wildcard and a __food__ wildcard, and repacking it can surface either, depending on which file gets matched.

How it works

detection_priority decides whether whole underscore-joined phrases get matched first before falling back to individual words, or whether matching is word-only. matching_mode controls how forgiving the text comparison is: exact is case-sensitive with no space-to-underscore conversion, ignore_case lowercases the input only, and flexible (the default) lowercases and converts spaces to underscores - which is what lets natural phrasing like "harry potter" match an underscore-style wildcard filename entry like harry_potter.

The README states a real, current limitation here: matching currently only works if the phrase equals a literal line in the wildcard file. A bracket-choice line inside a wildcard file, like {harry_potter|ron_weasly}, won't get matched against plain "harry_potter" text unless index_brackets is turned on, which expands those combos into indexed variants purely for matching purposes; leave it off and any wildcard line containing braces gets skipped from the index entirely. blacklist_file exists because common connector words tend to get swallowed accidentally - the README's own example is an __and__ wildcard used purely as a separator token, which without a blacklist would get every instance of the word "and" wrapped into it. Point blacklist_file at blacklist.txt (or nothing.txt to disable blacklisting outright).

The inputs and outputs that matter

  • string - the hand-written text to repack.
  • detection_priority - phrase-first vs. word-only matching.
  • matching_mode - exact, ignore_case, or flexible.
  • index_brackets - whether bracket-choice wildcard lines participate in matching.
  • chance - per-match probability of actually repacking.
  • blacklist_file, refresh_cache, category.
  • Outputs: repacked_prompt (your text with matched phrases wrapped as wildcard tokens), generated_prompt (the pack immediately re-rolls that repacked prompt as a bonus second output), context.

How to install it

Ships with the rest of the pack. Search comfyui-adaptiveprompts in ComfyUI Manager, or clone manually:

cd ComfyUI/custom_nodes
git clone https://github.com/Alectriciti/comfyui-adaptiveprompts

Restart ComfyUI. No models, no extra dependencies.

Common issues & troubleshooting

Edited a wildcard file and the repack results didn't change. The README explicitly warns about this: Prompt Repack pre-caches wildcards on startup for lookup speed, so edits made after ComfyUI is already running won't be picked up until you either restart ComfyUI or turn refresh_cache on for that run.

A word that "should" match isn't matching. Check matching_mode first - if your wildcard file entries use underscores but your source text uses spaces, exact mode won't bridge that gap; you need flexible. Then check whether the wildcard line in question contains a bracket choice, which needs index_brackets on to be matchable at all.

A common word keeps getting swallowed into an unrelated wildcard. That's exactly what blacklist_file is for - add the word to comfyui-adaptiveprompts/repack_files/blacklist.txt so it's excluded from matching.

Treat it as genuinely experimental. The author calls it out as such in the README, and the matching-on-exact-line-only limitation is a known, stated gap rather than something you're doing wrong - expect some rough edges, especially around long or unusual wildcard filenames.

Categoryadaptiveprompts/generation

Inputs (10)

NameTypeDefaultDescription
stringSTRING
detection_priorityBOOLEANtrueDetection priority: - prioritize_words: replace individual words only. - prioritize_phrase: replace longest underscore-joined phrases first, then words.
matching_modeCOMBOflexibleMatching rules: - exact: no case folding; no space→underscore. - ignore_case: lower-case input only. - flexible (default): lower-case + spaces→underscores.
index_bracketsBOOLEANfalseIf true, expand {a|b} combos into all indexed variants. Otherwise, lines with braces are skipped from indexing.
chanceFLOAT1.000–1
seedINT00–18446744073709550000
blacklist_fileCOMBOblacklist.txt2 options: blacklist.txt, nothing.txt
refresh_cacheBOOLEANfalseReload wildcards and blacklist caches.
categoryCOMBOwildcardsSelect which wildcards folder to use. Create alternate folders named 'wildcards_*' (eg. 'wildcards_fresh') inside the package root. defaults to the global '/wildcards/ if a file is missing'
contextoptDICTOptional upstream context to build upon.

Outputs (3)

NameTypeDescription
repacked_promptSTRING
generated_promptSTRING
contextDICT