comfy-ts 0.4.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 (158) hide show
  1. package/README.md +385 -255
  2. package/dist/DefinedWorkflow-BYyu5dK9.js +669 -0
  3. package/dist/DefinedWorkflow-BYyu5dK9.js.map +1 -0
  4. package/dist/cli.js +4106 -152
  5. package/dist/cli.js.map +1 -1
  6. package/dist/index.cjs +1560 -333
  7. package/dist/index.cjs.map +1 -1
  8. package/dist/index.d.cts +7826 -467
  9. package/dist/index.d.ts +7808 -449
  10. package/dist/index.js +1550 -333
  11. package/dist/index.js.map +1 -1
  12. package/dist/{run-tui-SDSJo1Qf.js → run-tui-DZ22HDHI.js} +631 -657
  13. package/dist/run-tui-DZ22HDHI.js.map +1 -0
  14. package/examples/01-txt2img.cflow.ts +50 -0
  15. package/examples/02-img2img-upload.cflow.ts +55 -0
  16. package/examples/03-export-workflow-json.cflow.ts +56 -0
  17. package/examples/04-krea2-turbo-t2i.cflow.ts +125 -0
  18. package/examples/05-comfy-cloud.cflow.ts +51 -0
  19. package/examples/README.md +30 -0
  20. package/examples/comfy-cloud/ace-step-t2a.cflow.ts +79 -0
  21. package/examples/comfy-cloud/anima-t2i.cflow.ts +57 -0
  22. package/examples/comfy-cloud/boogu-i2i.cflow.ts +76 -0
  23. package/examples/comfy-cloud/capybara-i2i.cflow.ts +85 -0
  24. package/examples/comfy-cloud/capybara-i2v.cflow.ts +90 -0
  25. package/examples/comfy-cloud/capybara-t2i.cflow.ts +67 -0
  26. package/examples/comfy-cloud/chatterbox-t2a.cflow.ts +79 -0
  27. package/examples/comfy-cloud/chroma-t2i.cflow.ts +62 -0
  28. package/examples/comfy-cloud/cloudHost.ts +41 -0
  29. package/examples/comfy-cloud/ernie-t2i.cflow.ts +59 -0
  30. package/examples/comfy-cloud/firered-i2i.cflow.ts +74 -0
  31. package/examples/comfy-cloud/flux1-i2i.cflow.ts +76 -0
  32. package/examples/comfy-cloud/flux1-t2i.cflow.ts +63 -0
  33. package/examples/comfy-cloud/flux2-i2i.cflow.ts +80 -0
  34. package/examples/comfy-cloud/flux2-t2i.cflow.ts +57 -0
  35. package/examples/comfy-cloud/hidream-i2i.cflow.ts +89 -0
  36. package/examples/comfy-cloud/hidream-t2i.cflow.ts +65 -0
  37. package/examples/comfy-cloud/hunyuan-video-i2v.cflow.ts +93 -0
  38. package/examples/comfy-cloud/hunyuan-video-t2v.cflow.ts +74 -0
  39. package/examples/comfy-cloud/ideogram4-t2i.cflow.ts +80 -0
  40. package/examples/comfy-cloud/kandinsky5-i2v.cflow.ts +95 -0
  41. package/examples/comfy-cloud/kandinsky5-t2i.cflow.ts +60 -0
  42. package/examples/comfy-cloud/kandinsky5-t2v.cflow.ts +78 -0
  43. package/examples/comfy-cloud/krea2-t2i.cflow.ts +59 -0
  44. package/examples/comfy-cloud/lens-t2i.cflow.ts +62 -0
  45. package/examples/comfy-cloud/longcat-i2i.cflow.ts +74 -0
  46. package/examples/comfy-cloud/longcat-t2i.cflow.ts +65 -0
  47. package/examples/comfy-cloud/ltxv-i2v.cflow.ts +92 -0
  48. package/examples/comfy-cloud/ltxv-t2v.cflow.ts +78 -0
  49. package/examples/comfy-cloud/newbie-t2i.cflow.ts +67 -0
  50. package/examples/comfy-cloud/omnigen2-i2i.cflow.ts +86 -0
  51. package/examples/comfy-cloud/omnigen2-t2i.cflow.ts +62 -0
  52. package/examples/comfy-cloud/ovis-t2i.cflow.ts +56 -0
  53. package/examples/comfy-cloud/pixeldit-t2i.cflow.ts +63 -0
  54. package/examples/comfy-cloud/qwen-image-i2i.cflow.ts +69 -0
  55. package/examples/comfy-cloud/qwen-image-t2i.cflow.ts +55 -0
  56. package/examples/comfy-cloud/sd35-t2i.cflow.ts +48 -0
  57. package/examples/comfy-cloud/sdk.d.ts +123062 -0
  58. package/examples/comfy-cloud/sdxl-t2i.cflow.ts +69 -0
  59. package/examples/comfy-cloud/stable-audio-t2a.cflow.ts +53 -0
  60. package/examples/comfy-cloud/svd-i2v.cflow.ts +75 -0
  61. package/examples/comfy-cloud/wan21-i2v.cflow.ts +83 -0
  62. package/examples/comfy-cloud/wan21-t2v.cflow.ts +64 -0
  63. package/examples/comfy-cloud/wan22-5b-t2v.cflow.ts +69 -0
  64. package/examples/comfy-cloud/wan22-i2v.cflow.ts +107 -0
  65. package/examples/comfy-cloud/wan22-t2v.cflow.ts +98 -0
  66. package/examples/comfy-cloud/z-image-t2i.cflow.ts +62 -0
  67. package/examples/images/README.md +18 -0
  68. package/examples/images/bear_1024x1024.jpg +0 -0
  69. package/examples/images/deer_768x1344.jpg +0 -0
  70. package/examples/images/dog_512x512.jpg +0 -0
  71. package/examples/images/lioness_768x768.jpg +0 -0
  72. package/examples/images/pug_200x300.jpg +0 -0
  73. package/examples/images/walrus_1344x768.jpg +0 -0
  74. package/guide-for-agents.md +172 -0
  75. package/package.json +20 -4
  76. package/src/cli/comfy-ts-cli.ts +19 -2
  77. package/src/cli/gen.ts +21 -12
  78. package/src/cli/tui/components/PreviewPanel.tsx +9 -8
  79. package/src/cli/tui/components/StatusBar.tsx +11 -0
  80. package/src/cli/tui/components/TreePanel.tsx +15 -2
  81. package/src/cli/tui/components/TuiApp.tsx +18 -0
  82. package/src/cli/tui/discoverWorkflows.ts +45 -0
  83. package/src/cli/tui/imagePicker/ImagePickerOverlay.tsx +72 -0
  84. package/src/cli/tui/imagePicker/ImagePickerSt.ts +288 -0
  85. package/src/cli/tui/imagePicker/fsListing.ts +46 -0
  86. package/src/cli/tui/imagePicker/pickerPrefs.ts +78 -0
  87. package/src/cli/tui/run-tui.tsx +52 -23
  88. package/src/cli/tui/state/HostSt.ts +2 -3
  89. package/src/cli/tui/state/LorasSt.ts +14 -36
  90. package/src/cli/tui/state/PreviewSt.ts +28 -2
  91. package/src/cli/tui/state/TreeSt.ts +30 -6
  92. package/src/cli/tui/state/TuiSt.ts +27 -3
  93. package/src/cli/tui/state/WorkflowsSt.ts +15 -1
  94. package/src/exampleAssets.ts +56 -0
  95. package/src/graph/ComfyNode.ts +4 -1
  96. package/src/host/ComfyHost.ts +203 -77
  97. package/src/host/ComfyManager.ts +10 -9
  98. package/src/host/ComfyUploader.ts +1 -2
  99. package/src/host/ResilientWebsocket.ts +3 -1
  100. package/src/host/hostUrl.ts +59 -0
  101. package/src/host/loraManagerApi.ts +5 -4
  102. package/src/index.ts +27 -1
  103. package/src/litegraph/CanonicalWorkflow.ts +77 -0
  104. package/src/litegraph/LiteGraphGroup.ts +9 -7
  105. package/src/litegraph/LiteGraphJSON.ts +34 -13
  106. package/src/litegraph/LiteGraphLink.ts +32 -2
  107. package/src/litegraph/LiteGraphNode.ts +18 -33
  108. package/src/litegraph/LiteGraphNodeInput.ts +10 -8
  109. package/src/litegraph/LiteGraphNodeOutput.ts +2 -3
  110. package/src/litegraph/LiteGraphSubgraphDef.ts +74 -0
  111. package/src/litegraph/convertFlowToLiteGraphJSON.ts +4 -4
  112. package/src/litegraph/expandSubgraphs.ts +352 -0
  113. package/src/litegraph/normalizeWorkflow.ts +141 -0
  114. package/src/manager/ComfyRegistry.ts +37 -9
  115. package/src/manager/generated/KnownComfyCustomNodeName.ts +23852 -1926
  116. package/src/manager/generated/KnownComfyPluginTitle.ts +6854 -236
  117. package/src/manager/generated/KnownComfyPluginURL.ts +3425 -111
  118. package/src/manager/generated/KnownModel_Base.ts +23 -7
  119. package/src/manager/generated/KnownModel_FileName.ts +421 -0
  120. package/src/manager/generated/KnownModel_Name.ts +421 -0
  121. package/src/manager/generated/KnownModel_SavePath.ts +34 -8
  122. package/src/manager/generated/KnownModel_Type.ts +18 -14
  123. package/src/manager/json/alter-list.json +221 -221
  124. package/src/manager/json/custom-node-list.json +61020 -21946
  125. package/src/manager/json/extension-node-map.json +81077 -31176
  126. package/src/manager/json/github-stats.json +29321 -12601
  127. package/src/manager/json/model-list.json +5935 -4997
  128. package/src/manager/loaders/parseReport.ts +55 -0
  129. package/src/manager/loaders/step1_downloadComfyManagerJSONs.ts +15 -49
  130. package/src/manager/loaders/step2_custom-node-list-loader.ts +38 -83
  131. package/src/manager/loaders/step3_extension-node-map-loader.ts +36 -142
  132. package/src/manager/loaders/step4_model-list-loader.ts +25 -36
  133. package/src/manager/loaders/step5_alter-list-loader.ts +29 -0
  134. package/src/manager/loaders/step6_github-stats-loader.ts +23 -0
  135. package/src/manager/script-update-manager.bun.ts +9 -1
  136. package/src/manager/types/ComfyManagerAlterInfo.ts +13 -0
  137. package/src/manager/types/ComfyManagerFileModelInfo.ts +7 -3
  138. package/src/manager/types/ComfyManagerFilePluginContent.ts +6 -9
  139. package/src/manager/types/ComfyManagerFilePluginList.ts +3 -3
  140. package/src/manager/types/ComfyManagerGithubStats.ts +9 -0
  141. package/src/manager/types/ComfyManagerPluginContentMetadata.ts +2 -3
  142. package/src/manager/types/ComfyManagerPluginInfo.ts +48 -34
  143. package/src/runner/ComfyExecution.ts +4 -5
  144. package/src/runner/ComfyWorkflow.ts +2 -2
  145. package/src/runner/wsBinaryFrame.ts +48 -0
  146. package/src/sdk-generator/ComfySchema.ts +14 -1
  147. package/src/sdk-generator/Primitives.ts +6 -24
  148. package/src/sdk-generator/comfy-api-json.ts +3 -1
  149. package/src/sdk-generator/comfyui-sdk-codegen.ts +15 -0
  150. package/src/sdk-generator/inputWidgetKind.ts +196 -0
  151. package/src/sdk-generator/litegraphToApiRequestPayload.ts +372 -96
  152. package/src/state.ts +13 -2
  153. package/src/vars/ComfyVars.ts +82 -2
  154. package/src/vars/DefinedWorkflow.ts +7 -2
  155. package/dist/log-CdfgILde.js +0 -10
  156. package/dist/log-CdfgILde.js.map +0 -1
  157. package/dist/run-tui-SDSJo1Qf.js.map +0 -1
  158. package/src/utils/tryExtracting.ts +0 -41
@@ -0,0 +1,55 @@
1
+ import { ansi as chalk } from 'src/utils/ansi.ts'
2
+
3
+ /** root shape of a manager mirror file is broken: nothing to salvage, fail loud */
4
+ export class ManagerParseError extends Error {
5
+ constructor(
6
+ public file: string,
7
+ public detail: string,
8
+ ) {
9
+ super(`🔴 [manager] ${file} root shape invalid: ${detail}`)
10
+ this.name = 'ManagerParseError'
11
+ }
12
+ }
13
+
14
+ export class FileParseCounter {
15
+ total = 0
16
+ accepted = 0
17
+ skipped = new Map<string, { count: number; firstError: string }>()
18
+
19
+ constructor(public file: string) {}
20
+
21
+ ok(): void {
22
+ this.total++
23
+ this.accepted++
24
+ }
25
+
26
+ skip(reason: string, firstError: string): void {
27
+ this.total++
28
+ const prev = this.skipped.get(reason)
29
+ if (prev == null) this.skipped.set(reason, { count: 1, firstError })
30
+ else prev.count++
31
+ }
32
+ }
33
+
34
+ /** per-file row accounting for the manager mirror parse; printed on every registry build so upstream drift stays visible */
35
+ export class ManagerParseReport {
36
+ counters: FileParseCounter[] = []
37
+
38
+ file(name: string): FileParseCounter {
39
+ const counter = new FileParseCounter(name)
40
+ this.counters.push(counter)
41
+ return counter
42
+ }
43
+
44
+ print(): void {
45
+ console.log(chalk.bold(`[📘 registry] parse report:`))
46
+ for (const c of this.counters) {
47
+ const skippedTotal = [...c.skipped.values()].reduce((acc, cur) => acc + cur.count, 0)
48
+ const headline = ` ${c.file}: ${c.total} rows, ${c.accepted} accepted, ${skippedTotal} skipped`
49
+ console.log(skippedTotal === 0 ? headline : chalk.red(headline))
50
+ for (const [reason, info] of c.skipped) {
51
+ console.log(chalk.red(` - ${reason} x${info.count}, first: ${info.firstError}`))
52
+ }
53
+ }
54
+ }
55
+ }
@@ -1,56 +1,22 @@
1
1
  import { ansi as chalk } from 'src/utils/ansi.ts'
2
-
3
2
  import { downloadFile } from 'src/utils/downloadFile.ts'
4
3
 
5
- export async function DownloadComfyManagerJSONs(): Promise<void> {
6
- await SYNC_modelList()
7
- await SYNC_customNodeList()
8
- await SYNC_extensionNodeMap()
9
- await SYNC_alterList()
10
- await SYNC_githubStats()
11
-
12
- async function SYNC_modelList(): Promise<void> {
13
- await downloadFile(
14
- 'https://raw.githubusercontent.com/ltdrdata/ComfyUI-Manager/main/model-list.json',
15
- 'src/manager/json/model-list.json',
16
- `- downloading ynchronizing model-list.json...`,
17
- )
18
- console.log(` saved at ${chalk.blue('src/manager/json/model-list.json')}`)
19
- }
20
-
21
- async function SYNC_customNodeList(): Promise<void> {
22
- await downloadFile(
23
- 'https://raw.githubusercontent.com/ltdrdata/ComfyUI-Manager/main/custom-node-list.json',
24
- 'src/manager/json/custom-node-list.json',
25
- `- downloading synchronizing custom-node-list.json...`,
26
- )
27
- console.log(` saved at ${chalk.blue('src/manager/json/custom-node-list.json')}`)
28
- }
4
+ // canonical repo since the ltdrdata → Comfy-Org move; the old ltdrdata raw
5
+ // urls still redirect here but that is goodwill, not contract (2026-07-30)
6
+ const MANAGER_RAW_BASE = 'https://raw.githubusercontent.com/Comfy-Org/ComfyUI-Manager/main'
29
7
 
30
- async function SYNC_extensionNodeMap(): Promise<void> {
31
- await downloadFile(
32
- 'https://raw.githubusercontent.com/ltdrdata/ComfyUI-Manager/main/extension-node-map.json',
33
- 'src/manager/json/extension-node-map.json',
34
- `- downloading synchronizing extension-node-map.json...`,
35
- )
36
- console.log(` saved at ${chalk.blue('src/manager/json/extension-node-map.json')}`)
37
- }
8
+ const MANAGER_MIRROR_FILES = [
9
+ 'custom-node-list.json',
10
+ 'model-list.json',
11
+ 'extension-node-map.json',
12
+ 'alter-list.json',
13
+ 'github-stats.json',
14
+ ] as const
38
15
 
39
- async function SYNC_alterList(): Promise<void> {
40
- await downloadFile(
41
- 'https://raw.githubusercontent.com/ltdrdata/ComfyUI-Manager/main/alter-list.json',
42
- 'src/manager/json/alter-list.json',
43
- `- downloading synchronizing alter-list.json...`,
44
- )
45
- console.log(` saved at ${chalk.blue('src/manager/json/alter-list.json')}`)
46
- }
47
-
48
- async function SYNC_githubStats(): Promise<void> {
49
- await downloadFile(
50
- 'https://raw.githubusercontent.com/ltdrdata/ComfyUI-Manager/refs/heads/main/github-stats.json',
51
- 'src/manager/json/github-stats.json',
52
- `- downloading ynchronizing githubStats.json...`,
53
- )
54
- console.log(` saved at ${chalk.blue('src/manager/json/github-stats.json')}`)
16
+ export async function DownloadComfyManagerJSONs(): Promise<void> {
17
+ for (const file of MANAGER_MIRROR_FILES) {
18
+ const dest = `src/manager/json/${file}`
19
+ await downloadFile(`${MANAGER_RAW_BASE}/${file}`, dest, `- downloading ${file}...`)
20
+ console.log(` saved at ${chalk.blue(dest)}`)
55
21
  }
56
22
  }
@@ -1,58 +1,46 @@
1
+ import { readFileSync, writeFileSync } from 'node:fs'
1
2
  import { type } from 'arktype'
2
3
  import { ansi as chalk } from 'src/utils/ansi.ts'
3
- import { readFileSync, writeFileSync } from 'fs'
4
- import type { Maybe } from 'src/types/index.ts'
5
4
  import { githubRegexpV1 } from 'src/utils/githubRegexes.ts'
6
- import { printArkResultInConsole } from 'src/utils/printArkResultInConsole.ts'
7
- import { RecoveryVerbosity, tryRecovering } from 'src/utils/tryExtracting.ts'
8
5
  import type { ComfyRegistry } from 'src/manager/ComfyRegistry.ts'
9
- import type { KnownComfyPluginTitle } from 'src/manager/generated/KnownComfyPluginTitle.ts'
10
6
  import { ComfyPluginExtra } from 'src/manager/json/custom-node-list.extra.ts'
7
+ import { ManagerParseError } from 'src/manager/loaders/parseReport.ts'
8
+ import { ComfyManagerFilePluginListRoot_ark } from 'src/manager/types/ComfyManagerFilePluginList.ts'
11
9
  import {
12
- type ComfyManagerFilePluginList,
13
- ComfyManagerFilePluginList_ark,
14
- } from 'src/manager/types/ComfyManagerFilePluginList.ts'
15
- import type { ComfyManagerPluginID } from 'src/manager/types/ComfyManagerPluginEnums.ts'
16
- import type { ComfyManagerPluginInfo } from 'src/manager/types/ComfyManagerPluginInfo.ts'
17
-
18
- export type GetKnownPluginProps = {
19
- //
20
- updateCache?: boolean
21
- check?: boolean
22
- genTypes?: boolean
23
- }
10
+ type ComfyManagerRawPluginInfo,
11
+ ComfyManagerRawPluginInfo_ark,
12
+ type ComfyManagerPluginInfo,
13
+ } from 'src/manager/types/ComfyManagerPluginInfo.ts'
24
14
 
25
15
  export const _getKnownPlugins = (DB: ComfyRegistry): void => {
16
+ const counter = DB.report.file('custom-node-list.json')
26
17
  let totalFileSeen = 0
27
- let totalPluginSeen = 0
28
-
29
- // load raw json
30
- const knownPluginFile: ComfyManagerFilePluginList = JSON.parse(
31
- readFileSync('src/manager/json/custom-node-list.json', 'utf8'),
32
- )
33
18
 
34
- // merge with extra
35
- const knownPluginList: ComfyManagerPluginInfo[] = knownPluginFile.custom_nodes.concat(ComfyPluginExtra)
36
-
37
- // auto-fix the (more often than not) json file
38
- // please... add validation or CI check or something!
39
- for (const plugin of knownPluginList) {
40
- plugin.id ??= tryRecoveringPluginId(plugin, RecoveryVerbosity.info)
41
- plugin.title ??= tryRecoveringPluginTitle(plugin, RecoveryVerbosity.info)
42
- }
19
+ // parse rows: loose raw schema per row, skip+report failures, normalize survivors
20
+ const raw: unknown = JSON.parse(readFileSync('src/manager/json/custom-node-list.json', 'utf8'))
21
+ const root = ComfyManagerFilePluginListRoot_ark(raw)
22
+ if (root instanceof type.errors) throw new ManagerParseError('custom-node-list.json', root.summary)
43
23
 
44
- // validate file is well-formed
45
- const res = ComfyManagerFilePluginList_ark(knownPluginFile)
46
- if (DB.opts.check) {
24
+ const canonical: ComfyManagerPluginInfo[] = []
25
+ for (const row of root.custom_nodes) {
26
+ const res = ComfyManagerRawPluginInfo_ark(row)
47
27
  if (res instanceof type.errors) {
48
- printArkResultInConsole(res)
49
- process.exit(1)
28
+ counter.skip('schema', res.summary)
29
+ continue
30
+ }
31
+ const plugin = normalizePluginInfo(res)
32
+ if (plugin == null) {
33
+ counter.skip('id-unrecoverable', res.reference)
34
+ continue
50
35
  }
36
+ canonical.push(plugin)
37
+ counter.ok()
51
38
  }
52
39
 
40
+ // hand-maintained extras are compile-checked canonical rows, not upstream data: no counting
41
+ const knownPluginList: ComfyManagerPluginInfo[] = canonical.concat(ComfyPluginExtra)
42
+
53
43
  for (const plugin of knownPluginList) {
54
- // INITIALIZATION ------------------------------------------------------------
55
- totalPluginSeen++
56
44
  if (DB.opts.check && DB.plugins_byTitle.has(plugin.title))
57
45
  console.log(` ❌ plugin.title: "${plugin.title}" is duplicated`)
58
46
  DB.plugins_byTitle.set(plugin.title, plugin)
@@ -70,7 +58,7 @@ export const _getKnownPlugins = (DB: ComfyRegistry): void => {
70
58
  // TitleType
71
59
  const allPlugins = [...DB.plugins_byTitle.values()]
72
60
  const allPluginsSortedByTitles = allPlugins.sort((a, b) =>
73
- (a.title ?? '❌missing-title').toLowerCase().localeCompare((b.title ?? '❌missing-title').toLowerCase()),
61
+ a.title.toLowerCase().localeCompare(b.title.toLowerCase()),
74
62
  )
75
63
  out1 += '// prettier-ignore\n'
76
64
  out1 += 'export type KnownComfyPluginTitle =\n'
@@ -90,7 +78,6 @@ export const _getKnownPlugins = (DB: ComfyRegistry): void => {
90
78
  out2 += '// prettier-ignore\n'
91
79
  out2 += 'export type KnownComfyPluginURL =\n'
92
80
  for (const fileName of sortedFileNames) out2 += ` | ${JSON.stringify(fileName)}\n`
93
- // out2 += '\n'
94
81
  const out2Path = 'src/manager/generated/KnownComfyPluginURL.ts'
95
82
  writeFileSync(out2Path, out2, 'utf-8')
96
83
  console.log(` > generated: ${chalk.blue.underline(out2Path)}`)
@@ -98,52 +85,20 @@ export const _getKnownPlugins = (DB: ComfyRegistry): void => {
98
85
 
99
86
  // INDEXING CHECKS ------------------------------------------------------------
100
87
  if (DB.opts.check) {
101
- // console.log(`${knownModelList.length} models found`)
102
- console.log(` - ${totalPluginSeen} CustomNodes in file`)
88
+ console.log(` - ${knownPluginList.length} CustomNodes in file`)
103
89
  console.log(` - ${DB.plugins_byTitle.size} CustomNodes registered in map`)
104
90
  console.log(` - ${totalFileSeen} CustomNodes-File Seen`)
105
91
  console.log(` - ${DB.plugins_byFile.size} CustomNodes-File registered in map`)
106
92
  }
107
93
  }
108
94
 
109
- function tryRecoveringPluginTitle(
110
- plugin: ComfyManagerPluginInfo,
111
- verbose = RecoveryVerbosity.Quiet,
112
- ): KnownComfyPluginTitle {
113
- return tryRecovering<KnownComfyPluginTitle>({
114
- property: 'plugin.title',
115
- verbose,
116
- hacks: [
117
- {
118
- attempt: 'id',
119
- fn: (): Maybe<KnownComfyPluginTitle> => plugin.id as KnownComfyPluginTitle,
120
- },
121
- {
122
- attempt: 'github repo name',
123
- fn: (): Maybe<KnownComfyPluginTitle> => plugin.reference as KnownComfyPluginTitle,
124
- },
125
- ],
126
- })
127
- }
128
-
129
- function tryRecoveringPluginId(
130
- //
131
- plugin: ComfyManagerPluginInfo,
132
- verbose = RecoveryVerbosity.Quiet,
133
- ): string {
134
- return tryRecovering<ComfyManagerPluginID>({
135
- property: 'plugin.id',
136
- verbose,
137
- hacks: [
138
- {
139
- level: RecoveryVerbosity.Verbose,
140
- attempt: 'title',
141
- fn: (): Maybe<ComfyManagerPluginID> => plugin.title as ComfyManagerPluginInfo['title'],
142
- },
143
- {
144
- attempt: 'github repo name',
145
- fn: (): Maybe<string> => plugin.reference.match(githubRegexpV1)?.[2],
146
- },
147
- ],
148
- })
95
+ /**
96
+ * raw → canonical: recover the missing `id` (absent on ~76% of upstream rows)
97
+ * from the title, else the github repo name. null = unrecoverable, caller
98
+ * reports and skips the row.
99
+ */
100
+ function normalizePluginInfo(p: ComfyManagerRawPluginInfo): ComfyManagerPluginInfo | null {
101
+ const id = p.id ?? p.title ?? p.reference.match(githubRegexpV1)?.[2]
102
+ if (id == null) return null
103
+ return { ...p, id }
149
104
  }
@@ -1,125 +1,64 @@
1
- import { readFileSync, writeFileSync } from 'node:fs'
1
+ import { writeFileSync, readFileSync } from 'node:fs'
2
2
  import { type } from 'arktype'
3
3
  import { ansi as chalk } from 'src/utils/ansi.ts'
4
4
  import { toQualifiedNodeKey } from 'src/sdk-generator/_toQualifiedNodeKey.ts'
5
- import type { NodeNameInComfy } from 'src/sdk-generator/comfyui-types.ts'
6
5
  import { githubRegexpV2 } from 'src/utils/githubRegexes.ts'
7
- import { printArkResultInConsole } from 'src/utils/printArkResultInConsole.ts'
8
6
  import type { ComfyRegistry } from 'src/manager/ComfyRegistry.ts'
9
7
  import type { KnownComfyCustomNodeName } from 'src/manager/generated/KnownComfyCustomNodeName.ts'
10
8
  import type { KnownComfyPluginURL } from 'src/manager/generated/KnownComfyPluginURL.ts'
11
- import {
12
- type ComfyManagerFilePluginContent,
13
- ComfyManagerFilePluginContent_ark,
14
- } from 'src/manager/types/ComfyManagerFilePluginContent.ts'
15
- import type { ComfyManagerPluginContentMetadata } from 'src/manager/types/ComfyManagerPluginContentMetadata.ts'
9
+ import { ManagerParseError } from 'src/manager/loaders/parseReport.ts'
10
+ import { ComfyManagerExtensionNodeMapEntry_ark } from 'src/manager/types/ComfyManagerFilePluginContent.ts'
16
11
  import type { ComfyManagerPluginInfo } from 'src/manager/types/ComfyManagerPluginInfo.ts'
17
12
 
18
13
  export const _getCustomNodeRegistry = (DB: ComfyRegistry): void => {
14
+ const counter = DB.report.file('extension-node-map.json')
19
15
  let totalCustomNodeSeen: number = 0
20
16
 
21
- // 1. read file
22
- const extensionNodeMapFile: ComfyManagerFilePluginContent = JSON.parse(
23
- readFileSync('src/manager/json/extension-node-map.json', 'utf8'),
24
- )
17
+ const raw: unknown = JSON.parse(readFileSync('src/manager/json/extension-node-map.json', 'utf8'))
18
+ const root = type('Record<string, unknown>')(raw)
19
+ if (root instanceof type.errors) throw new ManagerParseError('extension-node-map.json', root.summary)
25
20
 
26
- // validate file is well-formed
27
- const res = ComfyManagerFilePluginContent_ark(extensionNodeMapFile)
28
-
29
- if (DB.opts.check) {
21
+ for (const [url, value] of Object.entries(root)) {
22
+ // row shape: [nodeNames, meta]
23
+ const res = ComfyManagerExtensionNodeMapEntry_ark(value)
30
24
  if (res instanceof type.errors) {
31
- printArkResultInConsole(res)
32
- process.exit(1)
25
+ counter.skip('schema', `${url}: ${res.summary}`)
26
+ continue
33
27
  }
34
- }
35
-
36
- // 2. process file into something slightly more practical to use
37
- type ComfyManagerFilePluginContent_asObject = {
38
- url: string
39
- comfyNodeNames: NodeNameInComfy[]
40
- meta: ComfyManagerPluginContentMetadata
41
- /** should be what we will received once the plugin in installed */
42
- pythonModule: string
43
- /** plugin that contains this url listed in files */
44
- plugin: ComfyManagerPluginInfo
45
- }
46
-
47
- const enmEntries: ComfyManagerFilePluginContent_asObject[] = Object.entries(extensionNodeMapFile).map(
48
- (
49
- x: [url: string, infos: [NodeNameInComfy[], ComfyManagerPluginContentMetadata]],
50
- ): ComfyManagerFilePluginContent_asObject => {
51
- const url = x[0]
52
- const [comfyNodeNames, meta] = x[1]
53
- const confyPlugin = DB.plugins_byFile.get(url as KnownComfyPluginURL)
54
- if (confyPlugin == null) throw new Error(`[❌] plugin not found for ${url}`)
55
- return {
56
- url,
57
- comfyNodeNames,
58
- meta,
59
- plugin: confyPlugin,
60
- pythonModule: reverseEngineerWhatComfyWillSendAsPythonModuleValueOnceInstalled(confyPlugin, url, meta),
61
- }
62
- },
63
- )
28
+ // cross-reference: the url must be a file of a known plugin (upstream ships a few orphans)
29
+ const plugin = DB.plugins_byFile.get(url as KnownComfyPluginURL)
30
+ if (plugin == null) {
31
+ counter.skip('unknown-plugin-url', url)
32
+ continue
33
+ }
34
+ counter.ok()
64
35
 
65
- // 3. for each file
66
- for (const enmEntry of enmEntries) {
67
- totalCustomNodeSeen += enmEntry.comfyNodeNames.length
68
- // JSON CHECKS ------------------------------------------------------------
69
- // if (!hasErrors && DB.opts.check) {
70
- // const valid = Value.Check(ComfyManagerPluginContentMetadata_typebox, enmEntry.meta)
71
- // if (!valid) {
72
- // const errors: ValueError[] = [
73
- // ...Value.Errors(ComfyManagerPluginContentMetadata_typebox, enmEntry.meta),
74
- // ]
75
- // console.error(`❌ extensionNodeMap doesn't match schema:`, enmEntry.meta)
76
- // // console.error(`❌ errors`, errors)
77
- // for (const i of errors) console.log(`❌`, JSON.stringify(i))
78
- // hasErrors = true
79
- // }
80
- // }
36
+ // meta (res[1]) is validated so drift stays visible, but consumed by nothing today
37
+ const comfyNodeNames = res[0]
38
+ totalCustomNodeSeen += comfyNodeNames.length
39
+ const pythonModule = reverseEngineerWhatComfyWillSendAsPythonModuleValueOnceInstalled(plugin)
81
40
 
82
- // 3 ensure we have a list of nodes for this plugin
83
- const plugin = enmEntry.plugin
41
+ // ensure we have a list of nodes for this plugin
84
42
  const nodesInPlugin: KnownComfyCustomNodeName[] = DB.customNodes_byPluginName.get(plugin.title) ?? []
85
43
  DB.customNodes_byPluginName.set(plugin.title, nodesInPlugin)
86
44
 
87
- // INITIALIZATION ------------------------------------------------------------
88
- // 4. for each node in file
89
- for (const nodeNameInComfy of enmEntry.comfyNodeNames) {
90
- // 4.1. index the plugin for this node name
91
- // const prevEntry1 = DB.plugins_byNodeNameInComfy.get(nodeNameInComfy)
92
- // if (prevEntry1 == null) DB.plugins_byNodeNameInComfy.set(nodeNameInComfy, [plugin])
93
- // else prevEntry1.push(plugin)
94
-
95
- // 4.2 index by nodeKey
96
- // const nodeKey = convertComfyNodeNameToCushyNodeNameValidInJS(nodeNameInComfy)
97
-
98
- const nodeKey = toQualifiedNodeKey(enmEntry.pythonModule, nodeNameInComfy)
99
- // console.log(`[🤠] nodeKey=`, JSON.stringify(nodeKey), enmEntry.pythonModule)
100
- // process.exit(2)
101
- const prevEntry2 = DB.plugins_byNodeKey.get(nodeKey)
102
- if (prevEntry2 == null) DB.plugins_byNodeKey.set(nodeKey, [plugin])
103
- else prevEntry2.push(plugin)
104
-
105
- // 4.3. index the node in the plugin (file is only giving index by files...)
45
+ for (const nodeNameInComfy of comfyNodeNames) {
46
+ const nodeKey = toQualifiedNodeKey(pythonModule, nodeNameInComfy)
47
+ const prevEntry = DB.plugins_byNodeKey.get(nodeKey)
48
+ if (prevEntry == null) DB.plugins_byNodeKey.set(nodeKey, [plugin])
49
+ else prevEntry.push(plugin)
106
50
  nodesInPlugin.push(nodeKey as KnownComfyCustomNodeName)
107
51
  }
108
52
  }
109
53
 
110
- // 6. CODEGEN ------------------------------------------------------------
54
+ // CODEGEN ------------------------------------------------------------
111
55
  if (DB.opts.genTypes) {
112
56
  let out = ''
113
-
114
- // NameInCushy
115
57
  const allNodeKeys = [...DB.plugins_byNodeKey.keys()]
116
58
  const sortedNodeKeys = allNodeKeys.sort((a, b) => a.toLowerCase().localeCompare(b.toLowerCase()))
117
59
  out += '// prettier-ignore\n'
118
60
  out += 'export type KnownComfyCustomNodeName =\n'
119
61
  for (const nodeName of sortedNodeKeys) {
120
- if (nodeName === 'sd_perturbed_attention.PerturbedAttention') {
121
- console.log(`[🤠] 🔴`, DB.plugins_byNodeKey.get(nodeName))
122
- }
123
62
  out += ` | ${JSON.stringify(nodeName)}\n`
124
63
  }
125
64
  out += '\n'
@@ -129,61 +68,16 @@ export const _getCustomNodeRegistry = (DB: ComfyRegistry): void => {
129
68
  console.log(` > generated: ${chalk.blue.underline(outPath)}`)
130
69
  }
131
70
 
132
- // // INDEXING CHECKS ------------------------------------------------------------
71
+ // INDEXING CHECKS ------------------------------------------------------------
133
72
  if (DB.opts.check) {
134
- //
135
- // console.log(`${knownModelList.length} models found`)
136
- console.log(` - ${totalCustomNodeSeen} CustomNodes unique names processed`)
137
- // console.log(`${CustomNodeURL.byNodeNameInComfy.size} CustomNodes registered in map`)
138
- // if (totalPluginSeen !== CustomNodeURL.byNodeNameInComfy.size)
139
- // console.log(`❌ some customNodes are either duplicated or have overlapping titles`)
140
-
141
- // console.log(`${totalCustomNodeSeen} CustomNodes-File Seen`)
142
- // console.log(`${CustomNodeURL.byNodeNameInCushy.size} CustomNodes-File registered in map`)
143
- // if (totalCustomNodeSeen !== CustomNodeURL.byNodeNameInCushy.size)
144
- // console.log(`❌ some customNodes are either duplicated or have overlapping files`)
145
-
146
- // if (hasErrors) console.log(`❌ some CustomNodes don't match schema`)
147
- // else console.log(`✅ all CustomNodes match schema`)
73
+ console.log(` - ${totalCustomNodeSeen} CustomNodes names processed`)
74
+ console.log(` - ${DB.plugins_byNodeKey.size} unique node keys registered in map`)
148
75
  }
149
-
150
- // return DB
151
76
  }
152
77
 
153
- // // need to be an array, because multiple custom nodes can have the same name
154
- // type CustomNodeURL_by_NodeNameInComfy = Map<NodeNameInComfy, KnownComfyPluginURL[]>
155
- // type CustomNodeURL_by_NodeNameInCushy = Map<QualifiedNodeKey, KnownComfyPluginURL[]>
156
- // type CustomNodes_by_PluginTitle = Map<KnownComfyPluginURL, QualifiedNodeKey[]>
157
-
158
- // type CustomNodeRegistry = {
159
- // byNodeNameInComfy: CustomNodeURL_by_NodeNameInComfy
160
- // byNodeNameInCushy: CustomNodeURL_by_NodeNameInCushy
161
- // byPluginName: CustomNodes_by_PluginTitle
162
- // }
163
-
164
- // let DB: Maybe<CustomNodeRegistry> = null // = knownCustomNodesFile.custom_nodes
165
-
166
- function reverseEngineerWhatComfyWillSendAsPythonModuleValueOnceInstalled(
167
- plugin: ComfyManagerPluginInfo,
168
- _url: string,
169
- _meta: ComfyManagerPluginContentMetadata,
170
- ): string {
78
+ function reverseEngineerWhatComfyWillSendAsPythonModuleValueOnceInstalled(plugin: ComfyManagerPluginInfo): string {
171
79
  if (plugin.id === 'nodes' && plugin.reference === 'https://github.com/comfyanonymous/ComfyUI') return 'nodes'
172
-
173
- // if (meta.pythonModule) {
174
- // // console.log(`[🤠] got via pythonModule`, meta.pythonModule)
175
- // return meta.pythonModule
176
- // }
177
80
  const repoName = plugin.reference.match(githubRegexpV2)?.[2]
178
- // console.log(`[🤠] ${plugin.reference} => ${repoName}`)
179
- if (repoName) {
180
- // console.log(`[🤠] got via repoName`, plugin.reference, `custom_nodes.${repoName}`)
181
- return `custom_nodes.${repoName}`
182
- }
183
- if (plugin.id) {
184
- // console.log(`[🤠] got via repoName`, plugin.id, `custom_nodes.${plugin.id}`)
185
- return `custom_nodes.${plugin.id}`
186
- }
187
- const pythonModule = '🔴'
188
- return pythonModule
81
+ if (repoName) return `custom_nodes.${repoName}`
82
+ return `custom_nodes.${plugin.id}`
189
83
  }
@@ -1,40 +1,35 @@
1
- import { type ArkErrors, type } from 'arktype'
1
+ import { readFileSync, writeFileSync } from 'node:fs'
2
+ import { type } from 'arktype'
2
3
  import { ansi as chalk } from 'src/utils/ansi.ts'
3
- // https://github.com/ltdrdata/ComfyUI-Manager/blob/main/model-list.json
4
- import { readFileSync, writeFileSync } from 'fs'
5
- import { printArkResultInConsole } from 'src/utils/printArkResultInConsole.ts'
6
4
  import type { ComfyRegistry } from 'src/manager/ComfyRegistry.ts'
7
- import type { KnownModel_Name } from 'src/manager/generated/KnownModel_Name.ts'
8
5
  import { extraModels } from 'src/manager/json/model-list.extra.ts'
9
- import type { ComfyManagerFileModelInfo } from 'src/manager/types/ComfyManagerFileModelInfo.ts'
10
- import { ComfyManagerModelInfo_ark } from 'src/manager/types/ComfyManagerModelInfo.ts'
6
+ import { ManagerParseError } from 'src/manager/loaders/parseReport.ts'
7
+ import { ComfyManagerFileModelInfoRoot_ark } from 'src/manager/types/ComfyManagerFileModelInfo.ts'
8
+ import { type ComfyManagerModelInfo, ComfyManagerModelInfo_ark } from 'src/manager/types/ComfyManagerModelInfo.ts'
11
9
 
12
- export const _getKnownModels = (
13
- DB: ComfyRegistry /* {
14
- } */,
15
- ): void => {
16
- const knownModelsFile: ComfyManagerFileModelInfo = JSON.parse(
17
- readFileSync('src/manager/json/model-list.json', 'utf8'),
18
- )
19
- const knownModelList = knownModelsFile.models.concat(extraModels.models)
10
+ export const _getKnownModels = (DB: ComfyRegistry): void => {
11
+ const counter = DB.report.file('model-list.json')
20
12
 
21
- let hasErrors = false
13
+ const raw: unknown = JSON.parse(readFileSync('src/manager/json/model-list.json', 'utf8'))
14
+ const root = ComfyManagerFileModelInfoRoot_ark(raw)
15
+ if (root instanceof type.errors) throw new ManagerParseError('model-list.json', root.summary)
22
16
 
23
- for (const modelInfo of knownModelList) {
24
- // INITIALIZATION ------------------------------------------------------------
25
- DB.knownModels.set(modelInfo.name as KnownModel_Name, modelInfo)
26
-
27
- // JSON CHECKS -----------------------------------------------------------
28
- if (!hasErrors && DB.opts.check) {
29
- const res = ComfyManagerModelInfo_ark(modelInfo)
30
- if (res instanceof type.errors) {
31
- const errors: ArkErrors = res
32
- console.error(`❌ model doesn't match schema:`, modelInfo)
33
- printArkResultInConsole(errors)
34
- hasErrors = true
35
- // debugger
36
- }
17
+ const canonical: ComfyManagerModelInfo[] = []
18
+ for (const row of root.models) {
19
+ const res = ComfyManagerModelInfo_ark(row)
20
+ if (res instanceof type.errors) {
21
+ counter.skip('schema', res.summary)
22
+ continue
37
23
  }
24
+ canonical.push(res)
25
+ counter.ok()
26
+ }
27
+
28
+ // hand-maintained extras are compile-checked canonical rows, not upstream data: no counting
29
+ const knownModelList = canonical.concat(extraModels.models)
30
+
31
+ for (const modelInfo of knownModelList) {
32
+ DB.knownModels.set(modelInfo.name, modelInfo)
38
33
  }
39
34
 
40
35
  // CODEGEN ------------------------------------------------------------
@@ -145,15 +140,9 @@ export const _getKnownModels = (
145
140
 
146
141
  // INDEXING CHECKS ------------------------------------------------------------
147
142
  if (DB.opts.check) {
148
- //
149
143
  console.log(`${knownModelList.length} models found`)
150
144
  console.log(`${DB.knownModels.size} models registered map`)
151
145
  if (knownModelList.length !== DB.knownModels.size)
152
146
  console.log(`❌ some models are either duplicated or have overlapping indexing keys`)
153
- //
154
- if (hasErrors) console.log(`❌ some models don't match schema`)
155
- else console.log(`✅ all models match schema`)
156
147
  }
157
-
158
- // return DB.knownModels
159
148
  }
@@ -0,0 +1,29 @@
1
+ import { readFileSync } from 'node:fs'
2
+ import { type } from 'arktype'
3
+ import type { ComfyRegistry } from 'src/manager/ComfyRegistry.ts'
4
+ import { ManagerParseError } from 'src/manager/loaders/parseReport.ts'
5
+ import {
6
+ type ComfyManagerAlterInfo,
7
+ ComfyManagerAlterInfo_ark,
8
+ ComfyManagerFileAlterListRoot_ark,
9
+ } from 'src/manager/types/ComfyManagerAlterInfo.ts'
10
+
11
+ export const _getAlterList = (DB: ComfyRegistry): void => {
12
+ const counter = DB.report.file('alter-list.json')
13
+
14
+ const raw: unknown = JSON.parse(readFileSync('src/manager/json/alter-list.json', 'utf8'))
15
+ const root = ComfyManagerFileAlterListRoot_ark(raw)
16
+ if (root instanceof type.errors) throw new ManagerParseError('alter-list.json', root.summary)
17
+
18
+ const canonical: ComfyManagerAlterInfo[] = []
19
+ for (const row of root.items) {
20
+ const res = ComfyManagerAlterInfo_ark(row)
21
+ if (res instanceof type.errors) {
22
+ counter.skip('schema', res.summary)
23
+ continue
24
+ }
25
+ canonical.push(res)
26
+ counter.ok()
27
+ }
28
+ DB.alterations = canonical
29
+ }
@@ -0,0 +1,23 @@
1
+ import { readFileSync } from 'node:fs'
2
+ import { type } from 'arktype'
3
+ import type { ComfyRegistry } from 'src/manager/ComfyRegistry.ts'
4
+ import { ManagerParseError } from 'src/manager/loaders/parseReport.ts'
5
+ import { ComfyManagerGithubStatEntry_ark } from 'src/manager/types/ComfyManagerGithubStats.ts'
6
+
7
+ export const _getGithubStats = (DB: ComfyRegistry): void => {
8
+ const counter = DB.report.file('github-stats.json')
9
+
10
+ const raw: unknown = JSON.parse(readFileSync('src/manager/json/github-stats.json', 'utf8'))
11
+ const root = type('Record<string, unknown>')(raw)
12
+ if (root instanceof type.errors) throw new ManagerParseError('github-stats.json', root.summary)
13
+
14
+ for (const [url, value] of Object.entries(root)) {
15
+ const res = ComfyManagerGithubStatEntry_ark(value)
16
+ if (res instanceof type.errors) {
17
+ counter.skip('schema', `${url}: ${res.summary}`)
18
+ continue
19
+ }
20
+ DB.githubStats.set(url, res)
21
+ counter.ok()
22
+ }
23
+ }