comfy-ts 1.0.0 → 1.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (124) hide show
  1. package/README.md +42 -6
  2. package/dist/{DefinedWorkflow-O3ynII3Y.js → DefinedWorkflow-BYyu5dK9.js} +76 -5
  3. package/dist/DefinedWorkflow-BYyu5dK9.js.map +1 -0
  4. package/dist/cli.js +421 -308
  5. package/dist/cli.js.map +1 -1
  6. package/dist/index.cjs +394 -162
  7. package/dist/index.cjs.map +1 -1
  8. package/dist/index.d.cts +7426 -353
  9. package/dist/index.d.ts +7408 -335
  10. package/dist/index.js +393 -162
  11. package/dist/index.js.map +1 -1
  12. package/dist/{run-tui-BFhba_oG.js → run-tui-DZ22HDHI.js} +529 -78
  13. package/dist/run-tui-DZ22HDHI.js.map +1 -0
  14. package/examples/02-img2img-upload.cflow.ts +6 -17
  15. package/examples/05-comfy-cloud.cflow.ts +19 -35
  16. package/examples/README.md +30 -0
  17. package/examples/comfy-cloud/ace-step-t2a.cflow.ts +79 -0
  18. package/examples/comfy-cloud/anima-t2i.cflow.ts +57 -0
  19. package/examples/comfy-cloud/boogu-i2i.cflow.ts +76 -0
  20. package/examples/comfy-cloud/capybara-i2i.cflow.ts +85 -0
  21. package/examples/comfy-cloud/capybara-i2v.cflow.ts +90 -0
  22. package/examples/comfy-cloud/capybara-t2i.cflow.ts +67 -0
  23. package/examples/comfy-cloud/chatterbox-t2a.cflow.ts +79 -0
  24. package/examples/comfy-cloud/chroma-t2i.cflow.ts +62 -0
  25. package/examples/comfy-cloud/cloudHost.ts +41 -0
  26. package/examples/comfy-cloud/ernie-t2i.cflow.ts +59 -0
  27. package/examples/comfy-cloud/firered-i2i.cflow.ts +74 -0
  28. package/examples/comfy-cloud/flux1-i2i.cflow.ts +76 -0
  29. package/examples/comfy-cloud/flux1-t2i.cflow.ts +63 -0
  30. package/examples/comfy-cloud/flux2-i2i.cflow.ts +80 -0
  31. package/examples/comfy-cloud/flux2-t2i.cflow.ts +57 -0
  32. package/examples/comfy-cloud/hidream-i2i.cflow.ts +89 -0
  33. package/examples/comfy-cloud/hidream-t2i.cflow.ts +65 -0
  34. package/examples/comfy-cloud/hunyuan-video-i2v.cflow.ts +93 -0
  35. package/examples/comfy-cloud/hunyuan-video-t2v.cflow.ts +74 -0
  36. package/examples/comfy-cloud/ideogram4-t2i.cflow.ts +80 -0
  37. package/examples/comfy-cloud/kandinsky5-i2v.cflow.ts +95 -0
  38. package/examples/comfy-cloud/kandinsky5-t2i.cflow.ts +60 -0
  39. package/examples/comfy-cloud/kandinsky5-t2v.cflow.ts +78 -0
  40. package/examples/comfy-cloud/krea2-t2i.cflow.ts +59 -0
  41. package/examples/comfy-cloud/lens-t2i.cflow.ts +62 -0
  42. package/examples/comfy-cloud/longcat-i2i.cflow.ts +74 -0
  43. package/examples/comfy-cloud/longcat-t2i.cflow.ts +65 -0
  44. package/examples/comfy-cloud/ltxv-i2v.cflow.ts +92 -0
  45. package/examples/comfy-cloud/ltxv-t2v.cflow.ts +78 -0
  46. package/examples/comfy-cloud/newbie-t2i.cflow.ts +67 -0
  47. package/examples/comfy-cloud/omnigen2-i2i.cflow.ts +86 -0
  48. package/examples/comfy-cloud/omnigen2-t2i.cflow.ts +62 -0
  49. package/examples/comfy-cloud/ovis-t2i.cflow.ts +56 -0
  50. package/examples/comfy-cloud/pixeldit-t2i.cflow.ts +63 -0
  51. package/examples/comfy-cloud/qwen-image-i2i.cflow.ts +69 -0
  52. package/examples/comfy-cloud/qwen-image-t2i.cflow.ts +55 -0
  53. package/examples/comfy-cloud/sd35-t2i.cflow.ts +48 -0
  54. package/examples/comfy-cloud/sdk.d.ts +445 -57
  55. package/examples/comfy-cloud/sdxl-t2i.cflow.ts +69 -0
  56. package/examples/comfy-cloud/stable-audio-t2a.cflow.ts +53 -0
  57. package/examples/comfy-cloud/svd-i2v.cflow.ts +75 -0
  58. package/examples/comfy-cloud/wan21-i2v.cflow.ts +83 -0
  59. package/examples/comfy-cloud/wan21-t2v.cflow.ts +64 -0
  60. package/examples/comfy-cloud/wan22-5b-t2v.cflow.ts +69 -0
  61. package/examples/comfy-cloud/wan22-i2v.cflow.ts +107 -0
  62. package/examples/comfy-cloud/wan22-t2v.cflow.ts +98 -0
  63. package/examples/comfy-cloud/z-image-t2i.cflow.ts +62 -0
  64. package/examples/images/README.md +18 -0
  65. package/examples/images/bear_1024x1024.jpg +0 -0
  66. package/examples/images/deer_768x1344.jpg +0 -0
  67. package/examples/images/dog_512x512.jpg +0 -0
  68. package/examples/images/lioness_768x768.jpg +0 -0
  69. package/examples/images/pug_200x300.jpg +0 -0
  70. package/examples/images/walrus_1344x768.jpg +0 -0
  71. package/guide-for-agents.md +7 -1
  72. package/package.json +15 -4
  73. package/src/cli/tui/components/PreviewPanel.tsx +9 -8
  74. package/src/cli/tui/components/StatusBar.tsx +11 -0
  75. package/src/cli/tui/components/TuiApp.tsx +18 -0
  76. package/src/cli/tui/discoverWorkflows.ts +7 -41
  77. package/src/cli/tui/imagePicker/ImagePickerOverlay.tsx +72 -0
  78. package/src/cli/tui/imagePicker/ImagePickerSt.ts +288 -0
  79. package/src/cli/tui/imagePicker/fsListing.ts +46 -0
  80. package/src/cli/tui/imagePicker/pickerPrefs.ts +78 -0
  81. package/src/cli/tui/run-tui.tsx +2 -1
  82. package/src/cli/tui/state/LorasSt.ts +14 -36
  83. package/src/cli/tui/state/PreviewSt.ts +28 -2
  84. package/src/cli/tui/state/TuiSt.ts +6 -0
  85. package/src/exampleAssets.ts +56 -0
  86. package/src/graph/ComfyNode.ts +4 -1
  87. package/src/index.ts +7 -0
  88. package/src/manager/ComfyRegistry.ts +37 -9
  89. package/src/manager/generated/KnownComfyCustomNodeName.ts +23852 -1926
  90. package/src/manager/generated/KnownComfyPluginTitle.ts +6854 -236
  91. package/src/manager/generated/KnownComfyPluginURL.ts +3425 -111
  92. package/src/manager/generated/KnownModel_Base.ts +23 -7
  93. package/src/manager/generated/KnownModel_FileName.ts +421 -0
  94. package/src/manager/generated/KnownModel_Name.ts +421 -0
  95. package/src/manager/generated/KnownModel_SavePath.ts +34 -8
  96. package/src/manager/generated/KnownModel_Type.ts +18 -14
  97. package/src/manager/json/alter-list.json +221 -221
  98. package/src/manager/json/custom-node-list.json +61020 -21946
  99. package/src/manager/json/extension-node-map.json +81077 -31176
  100. package/src/manager/json/github-stats.json +29321 -12601
  101. package/src/manager/json/model-list.json +5935 -4997
  102. package/src/manager/loaders/parseReport.ts +55 -0
  103. package/src/manager/loaders/step1_downloadComfyManagerJSONs.ts +15 -49
  104. package/src/manager/loaders/step2_custom-node-list-loader.ts +38 -83
  105. package/src/manager/loaders/step3_extension-node-map-loader.ts +36 -142
  106. package/src/manager/loaders/step4_model-list-loader.ts +25 -36
  107. package/src/manager/loaders/step5_alter-list-loader.ts +29 -0
  108. package/src/manager/loaders/step6_github-stats-loader.ts +23 -0
  109. package/src/manager/script-update-manager.bun.ts +9 -1
  110. package/src/manager/types/ComfyManagerAlterInfo.ts +13 -0
  111. package/src/manager/types/ComfyManagerFileModelInfo.ts +7 -3
  112. package/src/manager/types/ComfyManagerFilePluginContent.ts +6 -9
  113. package/src/manager/types/ComfyManagerFilePluginList.ts +3 -3
  114. package/src/manager/types/ComfyManagerGithubStats.ts +9 -0
  115. package/src/manager/types/ComfyManagerPluginContentMetadata.ts +2 -3
  116. package/src/manager/types/ComfyManagerPluginInfo.ts +48 -34
  117. package/src/sdk-generator/ComfySchema.ts +14 -1
  118. package/src/sdk-generator/comfyui-sdk-codegen.ts +15 -0
  119. package/src/sdk-generator/inputWidgetKind.ts +17 -0
  120. package/src/vars/ComfyVars.ts +82 -2
  121. package/src/vars/DefinedWorkflow.ts +7 -2
  122. package/dist/DefinedWorkflow-O3ynII3Y.js.map +0 -1
  123. package/dist/run-tui-BFhba_oG.js.map +0 -1
  124. package/src/utils/tryExtracting.ts +0 -41
package/dist/cli.js CHANGED
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env node
2
- import { d as logInfo, f as logSuccess, l as isQuiet, o as extractErrorMessage, s as ansi, t as DefinedWorkflow, u as logError } from "./DefinedWorkflow-O3ynII3Y.js";
2
+ import { d as logInfo, f as logSuccess, l as isQuiet, o as extractErrorMessage, s as ansi, t as DefinedWorkflow, u as logError } from "./DefinedWorkflow-BYyu5dK9.js";
3
3
  import { spawnSync } from "node:child_process";
4
4
  import { fileURLToPath } from "node:url";
5
5
  import fs, { existsSync, mkdirSync, readFileSync, readdirSync, statSync, writeFile, writeFileSync } from "node:fs";
@@ -12,7 +12,6 @@ import { imageMeta } from "image-meta";
12
12
  import WebSocket from "ws";
13
13
  import https from "node:https";
14
14
  import { stdout } from "node:process";
15
- import { readFileSync as readFileSync$1, writeFileSync as writeFileSync$1 } from "fs";
16
15
  //#region src/sdk-generator/_getUnionNameBasedOnFirstFoundEnumName.ts
17
16
  /** having a bunch of sensible default will help slightly */
18
17
  function getUnionNameBasedOnFirstFoundEnumName(enumName, hash, hashContent) {
@@ -194,6 +193,170 @@ const wrapQuote = (s) => {
194
193
  return `'${s}'`;
195
194
  };
196
195
  //#endregion
196
+ //#region src/sdk-generator/inputWidgetKind.ts
197
+ const isRecord = (x) => typeof x === "object" && x != null && !Array.isArray(x);
198
+ /**
199
+ * seed phantom: a TRUTHY `control_after_generate` adds one consumed value.
200
+ * The frontend creates the control widget on truthiness, and real 2026 hosts
201
+ * spell it as `true` OR as a string mode like `'fixed'` (PrimitiveInt.value,
202
+ * SeedNode.seed). When the KEY is absent (2024 era) the INT-named-seed
203
+ * heuristic applies.
204
+ */
205
+ const controlConsumes = (o, typeName, name) => {
206
+ if (o != null && "control_after_generate" in o) return o["control_after_generate"] ? 2 : 1;
207
+ if (typeName === "INT" && (name === "seed" || name === "noise_seed")) return 2;
208
+ return 1;
209
+ };
210
+ const flattenInputSections = (inputs) => {
211
+ const out = [];
212
+ for (const section of ["required", "optional"]) {
213
+ const sec = inputs[section];
214
+ if (!isRecord(sec)) continue;
215
+ for (const [name, spec] of Object.entries(sec)) {
216
+ if (!Array.isArray(spec) || spec.length === 0) continue;
217
+ const t = spec[0];
218
+ if (typeof t !== "string" && !Array.isArray(t)) continue;
219
+ out.push({
220
+ name,
221
+ type: t,
222
+ opts: spec[1],
223
+ required: section === "required"
224
+ });
225
+ }
226
+ }
227
+ return out;
228
+ };
229
+ /** null when the options array is NOT the dynamic `{key, inputs}` family (then it is a plain combo) */
230
+ const parseDynamicOptions = (options) => {
231
+ if (options.length === 0) return null;
232
+ const out = [];
233
+ for (const entry of options) {
234
+ if (!isRecord(entry)) return null;
235
+ const key = entry["key"];
236
+ const inputs = entry["inputs"];
237
+ if (typeof key !== "string" || !isRecord(inputs)) return null;
238
+ out.push({
239
+ key,
240
+ inputs: flattenInputSections(inputs)
241
+ });
242
+ }
243
+ return out;
244
+ };
245
+ /**
246
+ * autogrow (`template` WITH a nested `input` section): instances are always
247
+ * link slots named `decl.<name_i>` (the backend force-inputs widget
248
+ * templates), the first `min` of them required WHEN the template input
249
+ * section is `required` — mirrors `_io.py Autogrow._expand_schema_for_dynamic`.
250
+ */
251
+ const parseContainer = (template) => {
252
+ const input = template["input"];
253
+ const min = typeof template["min"] === "number" ? template["min"] : 1;
254
+ const prefix = typeof template["prefix"] === "string" ? template["prefix"] : "";
255
+ const max = typeof template["max"] === "number" ? template["max"] : 100;
256
+ const rawNames = template["names"];
257
+ const names = Array.isArray(rawNames) ? rawNames.filter((n) => typeof n === "string") : Array.from({ length: max }, (_, i) => `${prefix}${i}`);
258
+ return {
259
+ kind: "dynamic-container",
260
+ instanceNames: names,
261
+ requiredCount: isRecord(input) && isRecord(input["required"]) && Object.keys(input["required"]).length > 0 ? Math.min(min, names.length) : 0
262
+ };
263
+ };
264
+ /**
265
+ * the single template sub-input's slot type of an autogrow container
266
+ * (`'IMAGE'` for TextEncodeBooguEdit.images). null when opts are not an
267
+ * autogrow template or the template has several sub-inputs (corpus-absent
268
+ * 2026-07-30, 27/27 single on the cloud catalog) — then codegen emits no
269
+ * typed instance keys and the container stays builderBase territory.
270
+ */
271
+ const containerInstanceSlotType = (opts) => {
272
+ const template = (isRecord(opts) ? opts : null)?.["template"];
273
+ if (!isRecord(template) || !isRecord(template["input"])) return null;
274
+ const subs = flattenInputSections(template["input"]);
275
+ const first = subs[0];
276
+ if (subs.length !== 1 || first == null || typeof first.type !== "string") return null;
277
+ return first.type;
278
+ };
279
+ const classifyWidgetInput = (p) => {
280
+ const o = isRecord(p.opts) ? p.opts : null;
281
+ if (o?.["forceInput"] === true) return { kind: "slot" };
282
+ if (Array.isArray(p.type) || p.isEnumUnion === true) {
283
+ const tn = typeof p.type === "string" ? p.type : "COMBO";
284
+ return {
285
+ kind: "widget",
286
+ consumes: controlConsumes(o, tn, p.name),
287
+ strictValues: true
288
+ };
289
+ }
290
+ if (typeof p.type !== "string") return { kind: "slot" };
291
+ const widgetTypeName = typeof o?.["widgetType"] === "string" ? o["widgetType"] : p.type;
292
+ if (ComfyPrimitiveMapping[widgetTypeName] != null) return {
293
+ kind: "widget",
294
+ consumes: controlConsumes(o, widgetTypeName, p.name),
295
+ strictValues: true
296
+ };
297
+ const options = o?.["options"];
298
+ if (Array.isArray(options)) {
299
+ const dynOptions = parseDynamicOptions(options);
300
+ if (dynOptions != null) {
301
+ const first = dynOptions[0];
302
+ if (first == null) return { kind: "slot" };
303
+ return {
304
+ kind: "dynamic-combo",
305
+ options: dynOptions,
306
+ defaultKey: typeof o?.["default"] === "string" ? o["default"] : first.key
307
+ };
308
+ }
309
+ return {
310
+ kind: "widget",
311
+ consumes: controlConsumes(o, p.type, p.name),
312
+ strictValues: true
313
+ };
314
+ }
315
+ const template = o?.["template"];
316
+ if (isRecord(template)) {
317
+ if (isRecord(template["input"])) return parseContainer(template);
318
+ return { kind: "slot" };
319
+ }
320
+ if (o?.["socketless"] === true) return {
321
+ kind: "widget",
322
+ consumes: 1,
323
+ strictValues: false
324
+ };
325
+ return { kind: "slot" };
326
+ };
327
+ const classifySchemaInput = (input) => classifyWidgetInput({
328
+ name: input.nameInComfy,
329
+ type: input.typeName,
330
+ opts: input.opts,
331
+ isEnumUnion: input.isEnum
332
+ });
333
+ /** how many widgets_values entries this schema input consumes (export path + positional walks) */
334
+ const howManyWidgetValuesForThisSchemaType = (input) => {
335
+ const kind = classifySchemaInput(input);
336
+ return kind.kind === "widget" ? kind.consumes : 0;
337
+ };
338
+ /**
339
+ * what ComfyUI's frontend gives a widget created with no serialized value
340
+ * (`getWidgetDefaultValue` semantics), used when a positional array is
341
+ * shorter than the schema's widget list. `null` for custom widgets — the
342
+ * backend accepts an explicit null but errors on an ABSENT required key.
343
+ */
344
+ const defaultValueForWidget = (p) => {
345
+ const o = isRecord(p.opts) ? p.opts : null;
346
+ if (o != null && o["default"] !== void 0) return o["default"];
347
+ const widgetTypeName = typeof o?.["widgetType"] === "string" ? o["widgetType"] : p.type;
348
+ if (widgetTypeName === "INT" || widgetTypeName === "FLOAT") return 0;
349
+ if (widgetTypeName === "BOOLEAN") return false;
350
+ if (widgetTypeName === "STRING") return "";
351
+ const options = o?.["options"];
352
+ if (Array.isArray(options) && options.length > 0) {
353
+ const first = options[0];
354
+ if (typeof first === "string" || typeof first === "number" || typeof first === "boolean") return first;
355
+ }
356
+ if (p.enumValues != null && p.enumValues.length > 0) return p.enumValues[0];
357
+ return null;
358
+ };
359
+ //#endregion
197
360
  //#region src/sdk-generator/comfyui-sdk-codegen.ts
198
361
  /**
199
362
  * convert a host id to the namespace name it gets inside the global `Comfy` namespace
@@ -248,6 +411,15 @@ function codegenSDK(opts) {
248
411
  for (const n of nodes) {
249
412
  p(`${escapeJSKey(n.nodeKey)}: {`);
250
413
  for (const i of n.inputs) {
414
+ const kind = classifySchemaInput(i);
415
+ if (kind.kind === "dynamic-container") {
416
+ const instType = containerInstanceSlotType(i.opts);
417
+ if (instType != null) kind.instanceNames.forEach((instName, ix) => {
418
+ const opt = ix >= kind.requiredCount ? "?" : "";
419
+ p(` ${escapeJSKey(`${i.nameInComfy}.${instName}`)}${opt}: Accepts[${JSON.stringify(instType)}]`);
420
+ });
421
+ continue;
422
+ }
251
423
  const opts_ = typeof i.opts === "string" ? null : i.opts;
252
424
  let type = `Accepts[${JSON.stringify(i.typeName)}]`;
253
425
  const comboOptions = i.typeName === "COMBO" && Array.isArray(opts_?.options) ? opts_.options.filter((o) => typeof o === "string" || typeof o === "number" || typeof o === "boolean") : [];
@@ -567,9 +739,18 @@ var ComfySchema = class {
567
739
  comfyUnionDef: slotType
568
740
  }).unionName);
569
741
  else throw new Error(`invalid schema (${JSON.stringify(slotType)}) for input "${ipt.name}" in node "${nodeNameInComfy}" (type: ${typeof slotType}; expected: Array | string)`);
742
+ const isAutogrowContainer = typeof slotType === "string" && classifyWidgetInput({
743
+ name: ipt.name,
744
+ type: slotType,
745
+ opts: slotOpts
746
+ }).kind === "dynamic-container";
747
+ if (isAutogrowContainer) {
748
+ const instType = containerInstanceSlotType(slotOpts);
749
+ if (instType != null) this.knownSlotTypes.add(asComfyNodeSlotTypeName(instType));
750
+ }
570
751
  node.inputs.push({
571
752
  slotName: inputSlotName,
572
- required: ipt.required,
753
+ required: ipt.required && !isAutogrowContainer,
573
754
  nameInComfy: inputNameInComfy,
574
755
  nameInComfyEscaped: escapeJSKey(inputNameInComfy),
575
756
  typeName: inputTypeName,
@@ -617,7 +798,7 @@ var ComfySchema = class {
617
798
  };
618
799
  //#endregion
619
800
  //#region package.json
620
- var version = "1.0.0";
801
+ var version = "1.1.0";
621
802
  //#endregion
622
803
  //#region src/litegraph/LiteGraphLinkID.ts
623
804
  const asLiteGraphLinkID = (id) => id;
@@ -1209,155 +1390,6 @@ function parseBinaryWsFrame(data) {
1209
1390
  };
1210
1391
  }
1211
1392
  //#endregion
1212
- //#region src/sdk-generator/inputWidgetKind.ts
1213
- const isRecord = (x) => typeof x === "object" && x != null && !Array.isArray(x);
1214
- /**
1215
- * seed phantom: a TRUTHY `control_after_generate` adds one consumed value.
1216
- * The frontend creates the control widget on truthiness, and real 2026 hosts
1217
- * spell it as `true` OR as a string mode like `'fixed'` (PrimitiveInt.value,
1218
- * SeedNode.seed). When the KEY is absent (2024 era) the INT-named-seed
1219
- * heuristic applies.
1220
- */
1221
- const controlConsumes = (o, typeName, name) => {
1222
- if (o != null && "control_after_generate" in o) return o["control_after_generate"] ? 2 : 1;
1223
- if (typeName === "INT" && (name === "seed" || name === "noise_seed")) return 2;
1224
- return 1;
1225
- };
1226
- const flattenInputSections = (inputs) => {
1227
- const out = [];
1228
- for (const section of ["required", "optional"]) {
1229
- const sec = inputs[section];
1230
- if (!isRecord(sec)) continue;
1231
- for (const [name, spec] of Object.entries(sec)) {
1232
- if (!Array.isArray(spec) || spec.length === 0) continue;
1233
- const t = spec[0];
1234
- if (typeof t !== "string" && !Array.isArray(t)) continue;
1235
- out.push({
1236
- name,
1237
- type: t,
1238
- opts: spec[1],
1239
- required: section === "required"
1240
- });
1241
- }
1242
- }
1243
- return out;
1244
- };
1245
- /** null when the options array is NOT the dynamic `{key, inputs}` family (then it is a plain combo) */
1246
- const parseDynamicOptions = (options) => {
1247
- if (options.length === 0) return null;
1248
- const out = [];
1249
- for (const entry of options) {
1250
- if (!isRecord(entry)) return null;
1251
- const key = entry["key"];
1252
- const inputs = entry["inputs"];
1253
- if (typeof key !== "string" || !isRecord(inputs)) return null;
1254
- out.push({
1255
- key,
1256
- inputs: flattenInputSections(inputs)
1257
- });
1258
- }
1259
- return out;
1260
- };
1261
- /**
1262
- * autogrow (`template` WITH a nested `input` section): instances are always
1263
- * link slots named `decl.<name_i>` (the backend force-inputs widget
1264
- * templates), the first `min` of them required WHEN the template input
1265
- * section is `required` — mirrors `_io.py Autogrow._expand_schema_for_dynamic`.
1266
- */
1267
- const parseContainer = (template) => {
1268
- const input = template["input"];
1269
- const min = typeof template["min"] === "number" ? template["min"] : 1;
1270
- const prefix = typeof template["prefix"] === "string" ? template["prefix"] : "";
1271
- const max = typeof template["max"] === "number" ? template["max"] : 100;
1272
- const rawNames = template["names"];
1273
- const names = Array.isArray(rawNames) ? rawNames.filter((n) => typeof n === "string") : Array.from({ length: max }, (_, i) => `${prefix}${i}`);
1274
- return {
1275
- kind: "dynamic-container",
1276
- instanceNames: names,
1277
- requiredCount: isRecord(input) && isRecord(input["required"]) && Object.keys(input["required"]).length > 0 ? Math.min(min, names.length) : 0
1278
- };
1279
- };
1280
- const classifyWidgetInput = (p) => {
1281
- const o = isRecord(p.opts) ? p.opts : null;
1282
- if (o?.["forceInput"] === true) return { kind: "slot" };
1283
- if (Array.isArray(p.type) || p.isEnumUnion === true) {
1284
- const tn = typeof p.type === "string" ? p.type : "COMBO";
1285
- return {
1286
- kind: "widget",
1287
- consumes: controlConsumes(o, tn, p.name),
1288
- strictValues: true
1289
- };
1290
- }
1291
- if (typeof p.type !== "string") return { kind: "slot" };
1292
- const widgetTypeName = typeof o?.["widgetType"] === "string" ? o["widgetType"] : p.type;
1293
- if (ComfyPrimitiveMapping[widgetTypeName] != null) return {
1294
- kind: "widget",
1295
- consumes: controlConsumes(o, widgetTypeName, p.name),
1296
- strictValues: true
1297
- };
1298
- const options = o?.["options"];
1299
- if (Array.isArray(options)) {
1300
- const dynOptions = parseDynamicOptions(options);
1301
- if (dynOptions != null) {
1302
- const first = dynOptions[0];
1303
- if (first == null) return { kind: "slot" };
1304
- return {
1305
- kind: "dynamic-combo",
1306
- options: dynOptions,
1307
- defaultKey: typeof o?.["default"] === "string" ? o["default"] : first.key
1308
- };
1309
- }
1310
- return {
1311
- kind: "widget",
1312
- consumes: controlConsumes(o, p.type, p.name),
1313
- strictValues: true
1314
- };
1315
- }
1316
- const template = o?.["template"];
1317
- if (isRecord(template)) {
1318
- if (isRecord(template["input"])) return parseContainer(template);
1319
- return { kind: "slot" };
1320
- }
1321
- if (o?.["socketless"] === true) return {
1322
- kind: "widget",
1323
- consumes: 1,
1324
- strictValues: false
1325
- };
1326
- return { kind: "slot" };
1327
- };
1328
- const classifySchemaInput = (input) => classifyWidgetInput({
1329
- name: input.nameInComfy,
1330
- type: input.typeName,
1331
- opts: input.opts,
1332
- isEnumUnion: input.isEnum
1333
- });
1334
- /** how many widgets_values entries this schema input consumes (export path + positional walks) */
1335
- const howManyWidgetValuesForThisSchemaType = (input) => {
1336
- const kind = classifySchemaInput(input);
1337
- return kind.kind === "widget" ? kind.consumes : 0;
1338
- };
1339
- /**
1340
- * what ComfyUI's frontend gives a widget created with no serialized value
1341
- * (`getWidgetDefaultValue` semantics), used when a positional array is
1342
- * shorter than the schema's widget list. `null` for custom widgets — the
1343
- * backend accepts an explicit null but errors on an ABSENT required key.
1344
- */
1345
- const defaultValueForWidget = (p) => {
1346
- const o = isRecord(p.opts) ? p.opts : null;
1347
- if (o != null && o["default"] !== void 0) return o["default"];
1348
- const widgetTypeName = typeof o?.["widgetType"] === "string" ? o["widgetType"] : p.type;
1349
- if (widgetTypeName === "INT" || widgetTypeName === "FLOAT") return 0;
1350
- if (widgetTypeName === "BOOLEAN") return false;
1351
- if (widgetTypeName === "STRING") return "";
1352
- const options = o?.["options"];
1353
- if (Array.isArray(options) && options.length > 0) {
1354
- const first = options[0];
1355
- if (typeof first === "string" || typeof first === "number" || typeof first === "boolean") return first;
1356
- }
1357
- if (p.enumValues != null && p.enumValues.length > 0) return p.enumValues[0];
1358
- return null;
1359
- };
1360
- //#endregion
1361
1393
  //#region src/sdk-generator/litegraphToApiRequestPayload.ts
1362
1394
  /** a canonical workflow the converter cannot turn into a prompt — the code NAMES the feature that failed */
1363
1395
  var WorkflowConvertError = class extends Error {
@@ -1784,7 +1816,7 @@ var ComfyNode = class ComfyNode {
1784
1816
  for (const i of this.$schema.inputs) {
1785
1817
  _done.add(i.nameInComfy);
1786
1818
  const value = this.serializeValue(i.nameInComfy, promptExt.inputs[i.nameInComfy]);
1787
- inputs[i.nameInComfy] = value;
1819
+ if (value !== void 0) inputs[i.nameInComfy] = value;
1788
1820
  }
1789
1821
  for (const [nameInComfy, rawVal] of Object.entries(promptExt.inputs)) {
1790
1822
  if (_done.has(nameInComfy)) continue;
@@ -3892,31 +3924,19 @@ function downloadFile(url, outputPath, logPrefix = " - ") {
3892
3924
  }
3893
3925
  //#endregion
3894
3926
  //#region src/manager/loaders/step1_downloadComfyManagerJSONs.ts
3927
+ const MANAGER_RAW_BASE = "https://raw.githubusercontent.com/Comfy-Org/ComfyUI-Manager/main";
3928
+ const MANAGER_MIRROR_FILES = [
3929
+ "custom-node-list.json",
3930
+ "model-list.json",
3931
+ "extension-node-map.json",
3932
+ "alter-list.json",
3933
+ "github-stats.json"
3934
+ ];
3895
3935
  async function DownloadComfyManagerJSONs() {
3896
- await SYNC_modelList();
3897
- await SYNC_customNodeList();
3898
- await SYNC_extensionNodeMap();
3899
- await SYNC_alterList();
3900
- await SYNC_githubStats();
3901
- async function SYNC_modelList() {
3902
- await downloadFile("https://raw.githubusercontent.com/ltdrdata/ComfyUI-Manager/main/model-list.json", "src/manager/json/model-list.json", `- downloading ynchronizing model-list.json...`);
3903
- console.log(` saved at ${ansi.blue("src/manager/json/model-list.json")}`);
3904
- }
3905
- async function SYNC_customNodeList() {
3906
- await downloadFile("https://raw.githubusercontent.com/ltdrdata/ComfyUI-Manager/main/custom-node-list.json", "src/manager/json/custom-node-list.json", `- downloading synchronizing custom-node-list.json...`);
3907
- console.log(` saved at ${ansi.blue("src/manager/json/custom-node-list.json")}`);
3908
- }
3909
- async function SYNC_extensionNodeMap() {
3910
- await downloadFile("https://raw.githubusercontent.com/ltdrdata/ComfyUI-Manager/main/extension-node-map.json", "src/manager/json/extension-node-map.json", `- downloading synchronizing extension-node-map.json...`);
3911
- console.log(` saved at ${ansi.blue("src/manager/json/extension-node-map.json")}`);
3912
- }
3913
- async function SYNC_alterList() {
3914
- await downloadFile("https://raw.githubusercontent.com/ltdrdata/ComfyUI-Manager/main/alter-list.json", "src/manager/json/alter-list.json", `- downloading synchronizing alter-list.json...`);
3915
- console.log(` saved at ${ansi.blue("src/manager/json/alter-list.json")}`);
3916
- }
3917
- async function SYNC_githubStats() {
3918
- await downloadFile("https://raw.githubusercontent.com/ltdrdata/ComfyUI-Manager/refs/heads/main/github-stats.json", "src/manager/json/github-stats.json", `- downloading ynchronizing githubStats.json...`);
3919
- console.log(` saved at ${ansi.blue("src/manager/json/github-stats.json")}`);
3936
+ for (const file of MANAGER_MIRROR_FILES) {
3937
+ const dest = `src/manager/json/${file}`;
3938
+ await downloadFile(`${MANAGER_RAW_BASE}/${file}`, dest, `- downloading ${file}...`);
3939
+ console.log(` saved at ${ansi.blue(dest)}`);
3920
3940
  }
3921
3941
  }
3922
3942
  //#endregion
@@ -3924,24 +3944,6 @@ async function DownloadComfyManagerJSONs() {
3924
3944
  const githubRegexpV1 = /https:\/\/github.com\/(.+?)\/(.+?)\/?/;
3925
3945
  const githubRegexpV2 = /https:\/\/github.com\/(.+?)\/([a-zA-Z0-9-_]+)?/;
3926
3946
  //#endregion
3927
- //#region src/utils/tryExtracting.ts
3928
- function tryRecovering({ verbose = 0, property, hacks, onFail, onSuccess }) {
3929
- if (verbose >= 2) console.log(`[🔶] trying to find a suitable value for ${property}...`);
3930
- for (const hack of hacks) {
3931
- if (verbose >= 2) console.log(` > trying to use ${hack.attempt}...`);
3932
- const value = hack.fn();
3933
- if (value != null) {
3934
- if (verbose >= (hack.level ?? 1)) {
3935
- if (verbose) console.log(` 🔶 recovered ${property} using ${hack.attempt}.`);
3936
- }
3937
- onSuccess?.(property, value);
3938
- return value;
3939
- }
3940
- }
3941
- onFail?.(property);
3942
- throw new Error(`[🔶] ${property} could not be recovered`);
3943
- }
3944
- //#endregion
3945
3947
  //#region src/manager/json/custom-node-list.extra.ts
3946
3948
  const ComfyPluginExtra = [{
3947
3949
  id: "TEMP_ComfyUI-BRIA_AI-RMBG",
@@ -3953,43 +3955,111 @@ const ComfyPluginExtra = [{
3953
3955
  description: "better rembg ?"
3954
3956
  }];
3955
3957
  //#endregion
3958
+ //#region src/manager/loaders/parseReport.ts
3959
+ /** root shape of a manager mirror file is broken: nothing to salvage, fail loud */
3960
+ var ManagerParseError = class extends Error {
3961
+ constructor(file, detail) {
3962
+ super(`🔴 [manager] ${file} root shape invalid: ${detail}`);
3963
+ this.file = file;
3964
+ this.detail = detail;
3965
+ this.name = "ManagerParseError";
3966
+ }
3967
+ };
3968
+ var FileParseCounter = class {
3969
+ constructor(file) {
3970
+ this.file = file;
3971
+ this.total = 0;
3972
+ this.accepted = 0;
3973
+ this.skipped = /* @__PURE__ */ new Map();
3974
+ }
3975
+ ok() {
3976
+ this.total++;
3977
+ this.accepted++;
3978
+ }
3979
+ skip(reason, firstError) {
3980
+ this.total++;
3981
+ const prev = this.skipped.get(reason);
3982
+ if (prev == null) this.skipped.set(reason, {
3983
+ count: 1,
3984
+ firstError
3985
+ });
3986
+ else prev.count++;
3987
+ }
3988
+ };
3989
+ /** per-file row accounting for the manager mirror parse; printed on every registry build so upstream drift stays visible */
3990
+ var ManagerParseReport = class {
3991
+ constructor() {
3992
+ this.counters = [];
3993
+ }
3994
+ file(name) {
3995
+ const counter = new FileParseCounter(name);
3996
+ this.counters.push(counter);
3997
+ return counter;
3998
+ }
3999
+ print() {
4000
+ console.log(ansi.bold(`[📘 registry] parse report:`));
4001
+ for (const c of this.counters) {
4002
+ const skippedTotal = [...c.skipped.values()].reduce((acc, cur) => acc + cur.count, 0);
4003
+ const headline = ` ${c.file}: ${c.total} rows, ${c.accepted} accepted, ${skippedTotal} skipped`;
4004
+ console.log(skippedTotal === 0 ? headline : ansi.red(headline));
4005
+ for (const [reason, info] of c.skipped) console.log(ansi.red(` - ${reason} x${info.count}, first: ${info.firstError}`));
4006
+ }
4007
+ }
4008
+ };
4009
+ //#endregion
3956
4010
  //#region src/manager/types/ComfyManagerFilePluginList.ts
3957
- const ComfyManagerFilePluginList_ark = type({ custom_nodes: type({
4011
+ const ComfyManagerFilePluginListRoot_ark = type({ custom_nodes: "unknown[]" });
4012
+ //#endregion
4013
+ //#region src/manager/types/ComfyManagerPluginInfo.ts
4014
+ const ComfyManagerRawPluginInfo_ark = type({
3958
4015
  author: "string",
3959
4016
  title: type.string.as(),
3960
4017
  reference: "string",
3961
4018
  files: type.string.as().array(),
3962
4019
  install_type: "string",
3963
4020
  description: "string",
3964
- id: type.string.as(),
4021
+ "id?": type.string.as(),
3965
4022
  "preemptions?": "string[]",
3966
4023
  "pip?": "string[]",
3967
4024
  "nodename_pattern?": "string",
3968
4025
  "apt_dependency?": "string[]",
3969
4026
  "js_path?": "string",
3970
4027
  "version?": "string",
3971
- "tags?": "string[]"
3972
- }).array() });
4028
+ "tags?": "string[]",
4029
+ "reference2?": "string",
4030
+ "category?": "string",
4031
+ "name?": "string",
4032
+ "license?": "string",
4033
+ "nickname?": "string",
4034
+ "stars?": "number",
4035
+ "last_update?": "string",
4036
+ "badges?": "string[]",
4037
+ "dependencies?": "string[]"
4038
+ });
3973
4039
  //#endregion
3974
4040
  //#region src/manager/loaders/step2_custom-node-list-loader.ts
3975
4041
  const _getKnownPlugins = (DB) => {
4042
+ const counter = DB.report.file("custom-node-list.json");
3976
4043
  let totalFileSeen = 0;
3977
- let totalPluginSeen = 0;
3978
- const knownPluginFile = JSON.parse(readFileSync$1("src/manager/json/custom-node-list.json", "utf8"));
3979
- const knownPluginList = knownPluginFile.custom_nodes.concat(ComfyPluginExtra);
3980
- for (const plugin of knownPluginList) {
3981
- plugin.id ??= tryRecoveringPluginId(plugin, 1);
3982
- plugin.title ??= tryRecoveringPluginTitle(plugin, 1);
3983
- }
3984
- const res = ComfyManagerFilePluginList_ark(knownPluginFile);
3985
- if (DB.opts.check) {
4044
+ const root = ComfyManagerFilePluginListRoot_ark(JSON.parse(readFileSync("src/manager/json/custom-node-list.json", "utf8")));
4045
+ if (root instanceof type.errors) throw new ManagerParseError("custom-node-list.json", root.summary);
4046
+ const canonical = [];
4047
+ for (const row of root.custom_nodes) {
4048
+ const res = ComfyManagerRawPluginInfo_ark(row);
3986
4049
  if (res instanceof type.errors) {
3987
- printArkResultInConsole(res);
3988
- process.exit(1);
4050
+ counter.skip("schema", res.summary);
4051
+ continue;
4052
+ }
4053
+ const plugin = normalizePluginInfo(res);
4054
+ if (plugin == null) {
4055
+ counter.skip("id-unrecoverable", res.reference);
4056
+ continue;
3989
4057
  }
4058
+ canonical.push(plugin);
4059
+ counter.ok();
3990
4060
  }
4061
+ const knownPluginList = canonical.concat(ComfyPluginExtra);
3991
4062
  for (const plugin of knownPluginList) {
3992
- totalPluginSeen++;
3993
4063
  if (DB.opts.check && DB.plugins_byTitle.has(plugin.title)) console.log(` ❌ plugin.title: "${plugin.title}" is duplicated`);
3994
4064
  DB.plugins_byTitle.set(plugin.title, plugin);
3995
4065
  for (const pluginURI of plugin.files) {
@@ -4000,7 +4070,7 @@ const _getKnownPlugins = (DB) => {
4000
4070
  }
4001
4071
  if (DB.opts.genTypes) {
4002
4072
  let out1 = "";
4003
- const allPluginsSortedByTitles = [...DB.plugins_byTitle.values()].sort((a, b) => (a.title ?? "❌missing-title").toLowerCase().localeCompare((b.title ?? "❌missing-title").toLowerCase()));
4073
+ const allPluginsSortedByTitles = [...DB.plugins_byTitle.values()].sort((a, b) => a.title.toLowerCase().localeCompare(b.title.toLowerCase()));
4004
4074
  out1 += "// prettier-ignore\n";
4005
4075
  out1 += "export type KnownComfyPluginTitle =\n";
4006
4076
  for (const plugin of allPluginsSortedByTitles) {
@@ -4009,7 +4079,7 @@ const _getKnownPlugins = (DB) => {
4009
4079
  }
4010
4080
  out1 += "\n";
4011
4081
  const out1Path = "src/manager/generated/KnownComfyPluginTitle.ts";
4012
- writeFileSync$1(out1Path, out1 + "\n", "utf-8");
4082
+ writeFileSync(out1Path, out1 + "\n", "utf-8");
4013
4083
  console.log(` > generated: ${ansi.blue.underline(out1Path)}`);
4014
4084
  let out2 = "";
4015
4085
  const sortedFileNames = [...DB.plugins_byFile.keys()].sort((a, b) => a.toLowerCase().localeCompare(b.toLowerCase()));
@@ -4017,47 +4087,33 @@ const _getKnownPlugins = (DB) => {
4017
4087
  out2 += "export type KnownComfyPluginURL =\n";
4018
4088
  for (const fileName of sortedFileNames) out2 += ` | ${JSON.stringify(fileName)}\n`;
4019
4089
  const out2Path = "src/manager/generated/KnownComfyPluginURL.ts";
4020
- writeFileSync$1(out2Path, out2, "utf-8");
4090
+ writeFileSync(out2Path, out2, "utf-8");
4021
4091
  console.log(` > generated: ${ansi.blue.underline(out2Path)}`);
4022
4092
  }
4023
4093
  if (DB.opts.check) {
4024
- console.log(` - ${totalPluginSeen} CustomNodes in file`);
4094
+ console.log(` - ${knownPluginList.length} CustomNodes in file`);
4025
4095
  console.log(` - ${DB.plugins_byTitle.size} CustomNodes registered in map`);
4026
4096
  console.log(` - ${totalFileSeen} CustomNodes-File Seen`);
4027
4097
  console.log(` - ${DB.plugins_byFile.size} CustomNodes-File registered in map`);
4028
4098
  }
4029
4099
  };
4030
- function tryRecoveringPluginTitle(plugin, verbose = 0) {
4031
- return tryRecovering({
4032
- property: "plugin.title",
4033
- verbose,
4034
- hacks: [{
4035
- attempt: "id",
4036
- fn: () => plugin.id
4037
- }, {
4038
- attempt: "github repo name",
4039
- fn: () => plugin.reference
4040
- }]
4041
- });
4042
- }
4043
- function tryRecoveringPluginId(plugin, verbose = 0) {
4044
- return tryRecovering({
4045
- property: "plugin.id",
4046
- verbose,
4047
- hacks: [{
4048
- level: 2,
4049
- attempt: "title",
4050
- fn: () => plugin.title
4051
- }, {
4052
- attempt: "github repo name",
4053
- fn: () => plugin.reference.match(githubRegexpV1)?.[2]
4054
- }]
4055
- });
4100
+ /**
4101
+ * raw → canonical: recover the missing `id` (absent on ~76% of upstream rows)
4102
+ * from the title, else the github repo name. null = unrecoverable, caller
4103
+ * reports and skips the row.
4104
+ */
4105
+ function normalizePluginInfo(p) {
4106
+ const id = p.id ?? p.title ?? p.reference.match(githubRegexpV1)?.[2];
4107
+ if (id == null) return null;
4108
+ return {
4109
+ ...p,
4110
+ id
4111
+ };
4056
4112
  }
4057
4113
  //#endregion
4058
4114
  //#region src/manager/types/ComfyManagerPluginContentMetadata.ts
4059
4115
  const ComfyManagerPluginContentMetadata_ark = type({
4060
- title_aux: type.string.or(type.null),
4116
+ "title_aux?": type.string.or(type.null),
4061
4117
  "author?": "string",
4062
4118
  "nickname?": "string",
4063
4119
  "description?": "string",
@@ -4071,42 +4127,37 @@ const ComfyManagerPluginContentNodeName_ark = type.string.as();
4071
4127
  type("string");
4072
4128
  //#endregion
4073
4129
  //#region src/manager/types/ComfyManagerFilePluginContent.ts
4074
- const ComfyManagerFilePluginContent_ark = type.Record("string", type([ComfyManagerPluginContentNodeName_ark.array(), ComfyManagerPluginContentMetadata_ark]));
4130
+ const ComfyManagerExtensionNodeMapEntry_ark = type([ComfyManagerPluginContentNodeName_ark.array(), ComfyManagerPluginContentMetadata_ark]);
4075
4131
  //#endregion
4076
4132
  //#region src/manager/loaders/step3_extension-node-map-loader.ts
4077
4133
  const _getCustomNodeRegistry = (DB) => {
4134
+ const counter = DB.report.file("extension-node-map.json");
4078
4135
  let totalCustomNodeSeen = 0;
4079
- const extensionNodeMapFile = JSON.parse(readFileSync("src/manager/json/extension-node-map.json", "utf8"));
4080
- const res = ComfyManagerFilePluginContent_ark(extensionNodeMapFile);
4081
- if (DB.opts.check) {
4136
+ const raw = JSON.parse(readFileSync("src/manager/json/extension-node-map.json", "utf8"));
4137
+ const root = type("Record<string, unknown>")(raw);
4138
+ if (root instanceof type.errors) throw new ManagerParseError("extension-node-map.json", root.summary);
4139
+ for (const [url, value] of Object.entries(root)) {
4140
+ const res = ComfyManagerExtensionNodeMapEntry_ark(value);
4082
4141
  if (res instanceof type.errors) {
4083
- printArkResultInConsole(res);
4084
- process.exit(1);
4142
+ counter.skip("schema", `${url}: ${res.summary}`);
4143
+ continue;
4085
4144
  }
4086
- }
4087
- const enmEntries = Object.entries(extensionNodeMapFile).map((x) => {
4088
- const url = x[0];
4089
- const [comfyNodeNames, meta] = x[1];
4090
- const confyPlugin = DB.plugins_byFile.get(url);
4091
- if (confyPlugin == null) throw new Error(`[❌] plugin not found for ${url}`);
4092
- return {
4093
- url,
4094
- comfyNodeNames,
4095
- meta,
4096
- plugin: confyPlugin,
4097
- pythonModule: reverseEngineerWhatComfyWillSendAsPythonModuleValueOnceInstalled(confyPlugin, url, meta)
4098
- };
4099
- });
4100
- for (const enmEntry of enmEntries) {
4101
- totalCustomNodeSeen += enmEntry.comfyNodeNames.length;
4102
- const plugin = enmEntry.plugin;
4145
+ const plugin = DB.plugins_byFile.get(url);
4146
+ if (plugin == null) {
4147
+ counter.skip("unknown-plugin-url", url);
4148
+ continue;
4149
+ }
4150
+ counter.ok();
4151
+ const comfyNodeNames = res[0];
4152
+ totalCustomNodeSeen += comfyNodeNames.length;
4153
+ const pythonModule = reverseEngineerWhatComfyWillSendAsPythonModuleValueOnceInstalled(plugin);
4103
4154
  const nodesInPlugin = DB.customNodes_byPluginName.get(plugin.title) ?? [];
4104
4155
  DB.customNodes_byPluginName.set(plugin.title, nodesInPlugin);
4105
- for (const nodeNameInComfy of enmEntry.comfyNodeNames) {
4106
- const nodeKey = toQualifiedNodeKey(enmEntry.pythonModule, nodeNameInComfy);
4107
- const prevEntry2 = DB.plugins_byNodeKey.get(nodeKey);
4108
- if (prevEntry2 == null) DB.plugins_byNodeKey.set(nodeKey, [plugin]);
4109
- else prevEntry2.push(plugin);
4156
+ for (const nodeNameInComfy of comfyNodeNames) {
4157
+ const nodeKey = toQualifiedNodeKey(pythonModule, nodeNameInComfy);
4158
+ const prevEntry = DB.plugins_byNodeKey.get(nodeKey);
4159
+ if (prevEntry == null) DB.plugins_byNodeKey.set(nodeKey, [plugin]);
4160
+ else prevEntry.push(plugin);
4110
4161
  nodesInPlugin.push(nodeKey);
4111
4162
  }
4112
4163
  }
@@ -4115,23 +4166,22 @@ const _getCustomNodeRegistry = (DB) => {
4115
4166
  const sortedNodeKeys = [...DB.plugins_byNodeKey.keys()].sort((a, b) => a.toLowerCase().localeCompare(b.toLowerCase()));
4116
4167
  out += "// prettier-ignore\n";
4117
4168
  out += "export type KnownComfyCustomNodeName =\n";
4118
- for (const nodeName of sortedNodeKeys) {
4119
- if (nodeName === "sd_perturbed_attention.PerturbedAttention") console.log(`[🤠] 🔴`, DB.plugins_byNodeKey.get(nodeName));
4120
- out += ` | ${JSON.stringify(nodeName)}\n`;
4121
- }
4169
+ for (const nodeName of sortedNodeKeys) out += ` | ${JSON.stringify(nodeName)}\n`;
4122
4170
  out += "\n";
4123
4171
  const outPath = "src/manager/generated/KnownComfyCustomNodeName.ts";
4124
4172
  writeFileSync(outPath, out + "\n", "utf-8");
4125
4173
  console.log(` > generated: ${ansi.blue.underline(outPath)}`);
4126
4174
  }
4127
- if (DB.opts.check) console.log(` - ${totalCustomNodeSeen} CustomNodes unique names processed`);
4175
+ if (DB.opts.check) {
4176
+ console.log(` - ${totalCustomNodeSeen} CustomNodes names processed`);
4177
+ console.log(` - ${DB.plugins_byNodeKey.size} unique node keys registered in map`);
4178
+ }
4128
4179
  };
4129
- function reverseEngineerWhatComfyWillSendAsPythonModuleValueOnceInstalled(plugin, _url, _meta) {
4180
+ function reverseEngineerWhatComfyWillSendAsPythonModuleValueOnceInstalled(plugin) {
4130
4181
  if (plugin.id === "nodes" && plugin.reference === "https://github.com/comfyanonymous/ComfyUI") return "nodes";
4131
4182
  const repoName = plugin.reference.match(githubRegexpV2)?.[2];
4132
4183
  if (repoName) return `custom_nodes.${repoName}`;
4133
- if (plugin.id) return `custom_nodes.${plugin.id}`;
4134
- return "🔴";
4184
+ return `custom_nodes.${plugin.id}`;
4135
4185
  }
4136
4186
  //#endregion
4137
4187
  //#region src/manager/json/model-list.extra.ts
@@ -4155,6 +4205,9 @@ const extraModels = { models: [{
4155
4205
  url: "https://huggingface.co/gemasai/4x_NMKD-Siax_200k/resolve/main/4xRealWebPhoto_v4_dat2.pth"
4156
4206
  }] };
4157
4207
  //#endregion
4208
+ //#region src/manager/types/ComfyManagerFileModelInfo.ts
4209
+ const ComfyManagerFileModelInfoRoot_ark = type({ models: "unknown[]" });
4210
+ //#endregion
4158
4211
  //#region src/manager/types/ComfyManagerModelInfo.ts
4159
4212
  const ComfyManagerModelInfo_ark = type({
4160
4213
  name: type.string.as(),
@@ -4170,20 +4223,21 @@ const ComfyManagerModelInfo_ark = type({
4170
4223
  //#endregion
4171
4224
  //#region src/manager/loaders/step4_model-list-loader.ts
4172
4225
  const _getKnownModels = (DB) => {
4173
- const knownModelList = JSON.parse(readFileSync$1("src/manager/json/model-list.json", "utf8")).models.concat(extraModels.models);
4174
- let hasErrors = false;
4175
- for (const modelInfo of knownModelList) {
4176
- DB.knownModels.set(modelInfo.name, modelInfo);
4177
- if (!hasErrors && DB.opts.check) {
4178
- const res = ComfyManagerModelInfo_ark(modelInfo);
4179
- if (res instanceof type.errors) {
4180
- const errors = res;
4181
- console.error(`❌ model doesn't match schema:`, modelInfo);
4182
- printArkResultInConsole(errors);
4183
- hasErrors = true;
4184
- }
4226
+ const counter = DB.report.file("model-list.json");
4227
+ const root = ComfyManagerFileModelInfoRoot_ark(JSON.parse(readFileSync("src/manager/json/model-list.json", "utf8")));
4228
+ if (root instanceof type.errors) throw new ManagerParseError("model-list.json", root.summary);
4229
+ const canonical = [];
4230
+ for (const row of root.models) {
4231
+ const res = ComfyManagerModelInfo_ark(row);
4232
+ if (res instanceof type.errors) {
4233
+ counter.skip("schema", res.summary);
4234
+ continue;
4185
4235
  }
4236
+ canonical.push(res);
4237
+ counter.ok();
4186
4238
  }
4239
+ const knownModelList = canonical.concat(extraModels.models);
4240
+ for (const modelInfo of knownModelList) DB.knownModels.set(modelInfo.name, modelInfo);
4187
4241
  if (DB.opts.genTypes) {
4188
4242
  let out1 = "";
4189
4243
  const uniqCategories = knownModelList.reduce((acc, cur) => {
@@ -4199,7 +4253,7 @@ const _getKnownModels = (DB) => {
4199
4253
  for (const [cat, count] of Object.entries(uniqCategories)) out1 += ` ${JSON.stringify(cat).padEnd(20)}, // x ${count.toString().padStart(3)}\n`;
4200
4254
  out1 += "]\n";
4201
4255
  const out1Path = "src/manager/generated/KnownModel_Type.ts";
4202
- writeFileSync$1(out1Path, out1 + "\n", "utf-8");
4256
+ writeFileSync(out1Path, out1 + "\n", "utf-8");
4203
4257
  console.log(` > generated: ${ansi.blue.underline(out1Path)}`);
4204
4258
  let out4 = "";
4205
4259
  const uniqSavePath = knownModelList.reduce((acc, cur) => {
@@ -4215,7 +4269,7 @@ const _getKnownModels = (DB) => {
4215
4269
  for (const [cat, count] of Object.entries(uniqSavePath)) out4 += ` ${JSON.stringify(cat).padEnd(50)}, // x ${count.toString().padStart(3)}\n`;
4216
4270
  out4 += "]\n";
4217
4271
  const out4Path = "src/manager/generated/KnownModel_SavePath.ts";
4218
- writeFileSync$1(out4Path, out4 + "\n", "utf-8");
4272
+ writeFileSync(out4Path, out4 + "\n", "utf-8");
4219
4273
  console.log(` > generated: ${ansi.blue.underline(out4Path)}`);
4220
4274
  let out2 = "";
4221
4275
  const uniqBases = knownModelList.reduce((acc, cur) => {
@@ -4232,7 +4286,7 @@ const _getKnownModels = (DB) => {
4232
4286
  for (const [cat, count] of Object.entries(uniqBases)) out2 += ` ${JSON.stringify(cat).padEnd(20)}, // x ${count.toString().padStart(3)}\n`;
4233
4287
  out2 += "]\n";
4234
4288
  const out2Path = "src/manager/generated/KnownModel_Base.ts";
4235
- writeFileSync$1(out2Path, out2 + "\n", "utf-8");
4289
+ writeFileSync(out2Path, out2 + "\n", "utf-8");
4236
4290
  console.log(` > generated: ${ansi.blue.underline(out2Path)}`);
4237
4291
  let out3 = "";
4238
4292
  const sortedModels = knownModelList.sort((a, b) => a.name.toLowerCase().localeCompare(b.name.toLowerCase()));
@@ -4247,7 +4301,7 @@ const _getKnownModels = (DB) => {
4247
4301
  }
4248
4302
  out3 += "\n";
4249
4303
  const out3Path = "src/manager/generated/KnownModel_Name.ts";
4250
- writeFileSync$1(out3Path, out3 + "\n", "utf-8");
4304
+ writeFileSync(out3Path, out3 + "\n", "utf-8");
4251
4305
  console.log(` > generated: ${ansi.blue.underline(out3Path)}`);
4252
4306
  let out99 = "";
4253
4307
  out99 += `// prettier-ignore\n`;
@@ -4261,20 +4315,78 @@ const _getKnownModels = (DB) => {
4261
4315
  }
4262
4316
  out99 += "\n";
4263
4317
  const out99Path = "src/manager/generated/KnownModel_FileName.ts";
4264
- writeFileSync$1(out99Path, out99 + "\n", "utf-8");
4318
+ writeFileSync(out99Path, out99 + "\n", "utf-8");
4265
4319
  console.log(` > generated: ${ansi.blue.underline(out99Path)}`);
4266
4320
  }
4267
4321
  if (DB.opts.check) {
4268
4322
  console.log(`${knownModelList.length} models found`);
4269
4323
  console.log(`${DB.knownModels.size} models registered map`);
4270
4324
  if (knownModelList.length !== DB.knownModels.size) console.log(`❌ some models are either duplicated or have overlapping indexing keys`);
4271
- if (hasErrors) console.log(`❌ some models don't match schema`);
4272
- else console.log(`✅ all models match schema`);
4325
+ }
4326
+ };
4327
+ //#endregion
4328
+ //#region src/manager/types/ComfyManagerAlterInfo.ts
4329
+ const ComfyManagerAlterInfo_ark = type({
4330
+ id: "string",
4331
+ tags: "string",
4332
+ description: "string"
4333
+ });
4334
+ const ComfyManagerFileAlterListRoot_ark = type({ items: "unknown[]" });
4335
+ //#endregion
4336
+ //#region src/manager/loaders/step5_alter-list-loader.ts
4337
+ const _getAlterList = (DB) => {
4338
+ const counter = DB.report.file("alter-list.json");
4339
+ const root = ComfyManagerFileAlterListRoot_ark(JSON.parse(readFileSync("src/manager/json/alter-list.json", "utf8")));
4340
+ if (root instanceof type.errors) throw new ManagerParseError("alter-list.json", root.summary);
4341
+ const canonical = [];
4342
+ for (const row of root.items) {
4343
+ const res = ComfyManagerAlterInfo_ark(row);
4344
+ if (res instanceof type.errors) {
4345
+ counter.skip("schema", res.summary);
4346
+ continue;
4347
+ }
4348
+ canonical.push(res);
4349
+ counter.ok();
4350
+ }
4351
+ DB.alterations = canonical;
4352
+ };
4353
+ //#endregion
4354
+ //#region src/manager/types/ComfyManagerGithubStats.ts
4355
+ const ComfyManagerGithubStatEntry_ark = type({
4356
+ stars: "number",
4357
+ last_update: "string",
4358
+ author_account_age_days: "number"
4359
+ });
4360
+ //#endregion
4361
+ //#region src/manager/loaders/step6_github-stats-loader.ts
4362
+ const _getGithubStats = (DB) => {
4363
+ const counter = DB.report.file("github-stats.json");
4364
+ const raw = JSON.parse(readFileSync("src/manager/json/github-stats.json", "utf8"));
4365
+ const root = type("Record<string, unknown>")(raw);
4366
+ if (root instanceof type.errors) throw new ManagerParseError("github-stats.json", root.summary);
4367
+ for (const [url, value] of Object.entries(root)) {
4368
+ const res = ComfyManagerGithubStatEntry_ark(value);
4369
+ if (res instanceof type.errors) {
4370
+ counter.skip("schema", `${url}: ${res.summary}`);
4371
+ continue;
4372
+ }
4373
+ DB.githubStats.set(url, res);
4374
+ counter.ok();
4273
4375
  }
4274
4376
  };
4275
4377
  //#endregion
4276
4378
  //#region src/manager/ComfyRegistry.ts
4277
4379
  const log = (...args) => console.log(`[📘 registry]`, ...args);
4380
+ const BUILTIN_URL = "https://github.com/comfyanonymous/ComfyUI";
4381
+ const BUILTIN_PLUGIN = {
4382
+ id: "nodes",
4383
+ author: "comfyanonymous",
4384
+ description: "built-in",
4385
+ title: "built-in",
4386
+ files: [BUILTIN_URL],
4387
+ reference: "https://github.com/comfyanonymous/ComfyUI",
4388
+ install_type: ""
4389
+ };
4278
4390
  var ComfyRegistry = class ComfyRegistry {
4279
4391
  static async DownloadAndUpdate(download) {
4280
4392
  if (download) {
@@ -4294,6 +4406,9 @@ var ComfyRegistry = class ComfyRegistry {
4294
4406
  this.plugins_byNodeKey = /* @__PURE__ */ new Map();
4295
4407
  this.customNodes_byPluginName = /* @__PURE__ */ new Map();
4296
4408
  this.knownModels = /* @__PURE__ */ new Map();
4409
+ this.alterations = [];
4410
+ this.githubStats = /* @__PURE__ */ new Map();
4411
+ this.report = new ManagerParseReport();
4297
4412
  this.getKnownCheckpoints = () => {
4298
4413
  return [...this.knownModels.values()].filter((i) => i.type === "checkpoint");
4299
4414
  };
@@ -4333,21 +4448,19 @@ var ComfyRegistry = class ComfyRegistry {
4333
4448
  nix: isUnderPrefix ? nixPath.slice(nixPrefix.length) : mi.filename
4334
4449
  };
4335
4450
  };
4336
- this.plugins_byFile.set("https://github.com/comfyanonymous/ComfyUI", {
4337
- id: "nodes",
4338
- author: "comfyanonymous",
4339
- description: "built-in",
4340
- title: "built-in",
4341
- files: [],
4342
- reference: "https://github.com/comfyanonymous/ComfyUI",
4343
- install_type: ""
4344
- });
4451
+ this.plugins_byTitle.set(BUILTIN_PLUGIN.title, BUILTIN_PLUGIN);
4452
+ this.plugins_byFile.set(BUILTIN_URL, BUILTIN_PLUGIN);
4345
4453
  log(`loading src/manager/json/${ansi.yellow("custom-node-list.json")}...`);
4346
4454
  _getKnownPlugins(this);
4347
4455
  log(`loading src/manager/json/${ansi.yellow("extension-node-map.json")}...`);
4348
4456
  _getCustomNodeRegistry(this);
4349
4457
  log(`loading src/manager/json/${ansi.yellow("model-list.json")}...`);
4350
4458
  _getKnownModels(this);
4459
+ log(`loading src/manager/json/${ansi.yellow("alter-list.json")}...`);
4460
+ _getAlterList(this);
4461
+ log(`loading src/manager/json/${ansi.yellow("github-stats.json")}...`);
4462
+ _getGithubStats(this);
4463
+ this.report.print();
4351
4464
  }
4352
4465
  };
4353
4466
  //#endregion
@@ -4592,7 +4705,7 @@ async function main() {
4592
4705
  if (res.error == null) return res.status ?? 1;
4593
4706
  console.error(`[comfy-ts tui] bun not found (${res.error.message}) — continuing under node: the examples packaged in node_modules cannot load here, and your own .cflow.ts modules rely on node's type stripping`);
4594
4707
  }
4595
- const { runTui } = await import("./run-tui-BFhba_oG.js");
4708
+ const { runTui } = await import("./run-tui-DZ22HDHI.js");
4596
4709
  return runTui(rest);
4597
4710
  }
4598
4711
  console.log(HELP);