Skip to content

Generate typed nodes

/object_info  →  snapshot  →  cwf codegen  →  typed specs
sh
cwf codegen --from object_info.json -o src/nodes/gen
cwf codegen --url http://127.0.0.1:8188 -o comfy-nodes --exact-combos

CLI codegen imports helpers from "@stepupgaming/comfy-workflows" so the output directory can live anywhere in your app.

What gets written

FileRole
<category>.tsSpecs grouped by /object_info category
registry.tsspecs map + named re-exports
defs.jsonParsed defs used by compile
catalog.json / NODES.mdSearchable catalog
identifiers.jsonclassType → export name

Header comment:

// GENERATED by comfy-workflows codegen — do not edit.
// objectInfoHash: …
// Regenerate with: cwf codegen

Why environment-specific

A VHS node exists only if that pack is installed. A combo of checkpoint filenames is that machine's disk. Default codegen widens file-backed combos to string[] so the types stay portable. --exact-combos emits literal unions. Those fail on another server's options. Use exact combos only when you regenerate per instance.

Built-in vs custom

The published @stepupgaming/comfy-workflows/nodes registry is the bundled core snapshot (Checkpoint, KSampler, VAE, LoadImage, …). It is not your custom nodes.

After codegen:

ts
import { VHS_LoadVideo, VHS_VideoCombine } from "./comfy-nodes/registry";

Those names come from the snapshot. Do not invent them. If the class is absent from /object_info, codegen will not emit it. Use rawNode only then.

Regeneration and drift

Install a pack, restart Comfy, recapture /object_info, rerun codegen, commit. If generated types are stale, g.add will not know the new class, or compile will fail E_UNKNOWN_NODE_TYPE against live defs.

CI pattern: Drift gates.

What codegen cannot express

Dynamic / autogrow inputs, nodes whose /object_info is a lie, and classes that are missing entirely. Those are rawNode or unsafe. Prefer fixing the snapshot over spreading escape hatches.

Node catalog is the bundled core list, not a universal catalog.

Released under the MIT License. Unofficial project. Not affiliated with or endorsed by Comfy Org.